Skip to content

Instantly share code, notes, and snippets.

View pglezen's full-sized avatar

Paul Glezen pglezen

View GitHub Profile
@pglezen
pglezen / gitLogAliases.md
Last active December 31, 2015 19:39
A few useful log aliases for Git.

This is a list of Git aliases that are really handy for me.

logdate

This alias logdate will list entries, one per line.

git config --global alias.logdate "log --pretty=format:'%h %cd [%an] %s' --graph --date=short"

By itself, it will list all commits for the repository. So you usually want to add a limiting parameter. So see only the last five entries:

@pglezen
pglezen / JerseyAuth.java
Last active August 29, 2015 14:06
Use Jersey to authenticate with WebSphere Application Server LTPA cookies.
package org.acme.cc.client.http;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
@pglezen
pglezen / ccConsumer.py
Created October 7, 2014 03:17
Script WAS WS-Security client policy set bindings
import sys
appName = "CCConsumerApp"
serviceName = "WebService:/CCConsumerWeb.war:{urn:issw:bare:wssec:cc:query}CCService"
policySetExport = "\\policySets\\Sign Timestamp.zip"
policySetName = "Sign Timestamp"
clientBindingExport = "\\policySets\\CCConsumerBindings.zip"
clientBindingName = "CCConsumerBindings"
print "Cell name", AdminControl.getCell()
@pglezen
pglezen / WSSubject.md
Created October 20, 2014 16:56
Obtain credential attributes from WSSubject in a WAS container.

The code sample below demonstrates how to obtain user and group information for an authenticated user from within WebSphere Application Server. It uses the WAS security API as documented in the Programming API section of the WAS 8.5.5 Knowledge Center (see packages starting with com.ibm.websphere.security.auth and com.ibm.websphere.security.cred.)

For more details on the WAS authentication model, please see Advanced WAS Authentication on IBM developerWorks. Yes, it's old; but most of it still applies.

@pglezen
pglezen / aDescription.md
Last active May 20, 2021 09:27
DataPower Dynamic Routing

The code sample below demonstrates how to implement a dynamic routing scheme in DataPower. It uses the inbound URI as the routing criterion. The routing logic is contained in the XSLT named computeRoute.xsl. The XSLT reads the route configuration from an XML file named routes.xsl.

All matches are logged to a log category named route-<domain> where represents the name of the application domain. Defining a log category with this name will enable you to fine tune the destination

@pglezen
pglezen / spmetagen.xsl
Created June 12, 2015 14:40
Generate SAML SP metadata for DataPower
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:sp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:sa="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
exclude-result-prefixes="dp"
extension-element-prefixes="dp"
version="1.0">
@pglezen
pglezen / DPLatency.ipynb
Created December 3, 2015 05:36
DataPower Latency Visualization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pglezen
pglezen / DPLatencyRegex.md
Created December 5, 2015 01:04
DataPower Latency Regular Expressions

This Gist is a small collection of regular expressions used to parse DataPower latency log entries. It only works for basic latency entries, not extended latency entries. Also, it may only work for MPGS; this hasn't been tested for WSPs.

reg = re.compile(r'\w\w\w (\w\w\w \d\d \d\d\d\d \d\d:\d\d:\d\d) \[0x80e00073\]\[latency\]\[info\] \w+\(([^)]+)\): tid\((\d+)\).+ Latency:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+\[(https?://[^/]+)([^?]+)?(\?.+)?\]')

Here is a description by groupings.

@pglezen
pglezen / RiskSimulation.ipynb
Created October 31, 2016 03:34
Risk Simulation Using Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pglezen
pglezen / console.log.R
Last active February 27, 2017 03:09
A console.log for R
console.log <- function(fmt,...) {
print(paste(format(Sys.time(), "%H:%M:%S"), sprintf(fmt, ...)))
}