Wednesday 23 July 2014

Various ways of implementing Security in Broker

To use the security profile from Broker registry:
Check these steps

1. Register the u/p
mqsisetdbparms brokerName -n securityIdName -u username -p password
eg:mqsisetdbparms RadBRK  -n TestId  -u  MyName -p MyPass

2. Create a Security Profile configurable service by using the mqsicreateconfigurableservice command:
mqsicreateconfigurableservice brokerName -c SecurityProfiles -o securityProfileName -n "propagation,idToPropagateToTransport,transportPropagationConfig" -v "TRUE,STATIC ID,securityIdName"
eg:mqsicreateconfigurableservice RadBRK  -c SecurityProfiles -o MySecurityProfile  -n "propagation,idToPropagateToTransport,transportPropagationConfig" -v "TRUE,STATIC ID,TestId"
3. Register securityProfileName with the request node, either in the bar editor or by using mqsiapplybaroverride.
========================================================
If to use direct hardcoding of Security credentials,
CREATE COMPUTE MODULE SomeCompute
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      CALL CopyEntireMessage();
      SET OutputRoot.HTTPRequestHeader."Authorization" = 'Basic '||base64Encode(CAST('admin:admin123' as BLOB CCSID InputRoot.Properties.CodedCharSetId));
      RETURN TRUE;
   END;

   CREATE PROCEDURE CopyEntireMessage() BEGIN
      SET OutputRoot = InputRoot;
   END;

   CREATE PROCEDURE base64Encode(IN source BLOB)
   RETURNS CHARACTER
   LANGUAGE JAVA
   EXTERNAL NAME "com.ibm.broker.javacompute.Base64.encode";
END MODULE;


Another way is using Identity Security Token:
Before sending request to HTTPRequest node,code as below in a compute node,

SET OutputRoot.Properties.IdentitySourceType='usernameAndPassword';
SET OutputRoot.Properties.IdentitySourceToken = 'myUser';
SET OutputRoot.Properties.IdentitySourcePassword = 'myPassw0rd';

And In the HTTPRequest node ,to pass the Headers,you need to set as below in the bar file



Output is shown as below,

No comments:

Post a Comment