|--------10--------20--------30--------40--------50--------60--------70--------80--------|
//LocalEnvironment/SOAP/Input/TransportSecurity/ClientAuth/Certificate/Subject
//or
//LocalEnvironment/HTTP/Input/TransportSecurity/ClientAuth/Certificate/Subject
String nodeType = localEnv.getFirstElementByPath("Destination").getFirstChild().getName();
MbElement transportSecurityElement = localEnv.getFirstElementByPath(nodeType+"/Input/TransportSecurity");
if (transportSecurityElement != null) {
MbElement clientAuthElement = transportSecurityElement.getFirstChild();
if (clientAuthElement != null) {
MbElement certificateElement = clientAuthElement.getFirstChild();
if (certificateElement != null && "Certificate".equals(certificateElement.getName())){
MbElement subjectElement = clientAuthElement.getFirstChild().getFirstChild().getNextSibling();
String subject = subjectElement.getValueAsString();
if (subject.indexOf(",") != -1) {
//Assume the subject is of the form CN=Philip Norton,OU=......
//(as set in the X509 certificate)
identity = subject.substring(subject.indexOf("CN=")+3, subject.indexOf(","));
} else {
//Assume the subject is of the form CN=Philip Norton
//(as set in the X509 certificate)
identity = subject.substring(subject.indexOf("CN=")+3);
}
}
}
}
//Store the manipulated identity in a new field in the LocalEnvironment
localEnv.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "IdentityToAuthorise", identity);
|--------10--------20--------30--------40--------50--------60--------70--------80--------|
The example in Code Listing 1 stores the common Name (CN) attribute from the full Distinguished Name (DN) defined in the client certificate, into a new Local Environment field called IdentityToAuthorise.
Using Certificate Information for LDAP Authorisation
Once the required identity has been extracted from the client's certificate it can be used by a Security PEP node to perform authorisation. Add a new Security PEP node to the message flow and in the properties view set the Identity token type to 'Username' and the Identity token location to an XPath that resolves to the location of the extracted identity, as shown in Figure 3.
Figure 3. Setting the Identity Token Location on a Security PEP Node
The Security PEP requires a configured Security Profile, set using the BAR editor, to enable the specified identity to be authorized using a directory service. The Security Profile can be configured to authorize against an LDAP server using Integration Bus Explorer, an example is shown in Figure 4, or the mqsicreateconfigurableservice command, an example is shown below:
mqsicreateconfigurableservice <node_name> -c SecurityProfiles -o BluepagesProfile -n authorization,authorizationConfig,propagation -v "LDAP,\"ldap://bluepages.ibm.com:389/cn=UK,ou=memberlist,ou=ibmgroups,o=ibm.com?uniquemember??x-userBaseDN=ou=bluepages%2co=ibm.com,x-uid_attr=cn\",TRUE"
This example uses LDAP to find a client by Common Name and authorizes them if they are a member of the group whose Common Name is UK.
For more information about configuring LDAP and configuring Integration Bus security see the referenced article in the Resources. section.
Figure 4. Configured Security Profile
If the user is successfully authorized the input message will be propagated to the out terminal of the Security PEP node, otherwise the failure terminal will be fired.
Resources