Friday, November 26, 2010

Self Registration @ Oracle Access Manager using IdentityXML and Identity Web Services

Step 0: Minimum Steps in Workflow: Step 1 - Self Registration, Step 2 - Enable

Step 1: Create SOAP Request envelope i.e. soap.xml

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:oblix="http://www.oblix.com" xmlns:soapenv="http://schemas-xmlsoap.org/soap/envelope/">

<soapenv:Body>
<oblix:authentication>
<oblix:login>[useradmin]</oblix:login> <!-- Delegated Admin-->
<oblix:password>[useradmin_password]</oblix:password>
</oblix:authentication>
<oblix:request application="userservcenter" function="workflowSelfRegistrationSave" version="NPWSDL1.0">
<oblix:params>
<oblix:ObWorkflowName>obworkflowid=[workflowid],obcontainerId=workflowDefinitions,o=Oblix,dc=mycorp,dc=com</oblix:ObWorkflowName>
<oblix:ObDomainName>ou=People,dc=mycorp,dc=com</oblix:ObDomainName>
<oblix:noOfFields>7</oblix:noOfFields>
<oblix:AttributeParams>

<oblix:GenericAttribute>
<oblix:AttrName>uid</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:AttrNewValue>sunmoon3112@mycorp.com</oblix:AttrNewValue>
</oblix:GenericAttribute>

<oblix:GenericAttribute>
<oblix:AttrName>cn</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:AttrNewValue>SunMoon</oblix:AttrNewValue>
</oblix:GenericAttribute>

<oblix:GenericAttribute>
<oblix:AttrName>sn</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:AttrNewValue>B</oblix:AttrNewValue>
</oblix:GenericAttribute>

<oblix:GenericAttribute>
<oblix:AttrName>givenName</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:AttrNewValue>SunMoon</oblix:AttrNewValue>
</oblix:GenericAttribute>

<oblix:PasswordAttribute>
<oblix:AttrName>userPassword</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:AttrNewValue>password</oblix:AttrNewValue>
<oblix:AttrConfirmValue>password</oblix:AttrConfirmValue>
</oblix:PasswordAttribute>

<oblix:ChallengeAttribute>
<oblix:AttrName>ChallengeQuestion</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:ChallengeValue>
<oblix:AttrNewValue>What is your favorite color?</oblix:AttrNewValue>
</oblix:ChallengeValue>
</oblix:ChallengeAttribute>

<oblix:ResponseAttribute>
<oblix:AttrName>ChallengeAnswer</oblix:AttrName>
<oblix:AttrOperation>ADD</oblix:AttrOperation>
<oblix:ResponseValue>
<oblix:AttrNewValue>babypink</oblix:AttrNewValue>
<oblix:AttrConfirmValue>babypink</oblix:AttrConfirmValue>
</oblix:ResponseValue>
</oblix:ResponseAttribute>

</oblix:AttributeParams>
</oblix:params>
</oblix:request>
</soapenv:Body>
</soapenv:Envelope>

Step 2: Provide details of webpass host,port and input soap file

String hostname = "[webpass host]";
String filename = "soap.xml"; //Input SOAP Request
int port = [port];
String oburl = "/identity/oblix/apps/userservcenter/bin/userservcenter.cgi?/from_prog=workflowSelfRegistration";

Step 3: Get the request from soap.xml input file

Step 4: Access Oracle Access Manager identity services

//Create the connection
URL url = new URL(hostname+port+oburl);
URLConnection conn = url.openConnection();
conn.setRequestProperty("Content-Type", "text/xml");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);

// Post the Request
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
String bits = getRequestFromFile().toString();
System.out.println("***************Request Start****************");
System.out.println(getRequestFromFile().toString()); //print input SOAP request
System.out.println("***************Request End****************");
wr.writeBytes(bits);
wr.flush();

// Get the Response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
System.out.println("***************Response Start****************");
while ((line = rd.readLine()) != null) {
System.out.println(line); //print output SOAP response
}
System.out.println("***************Response End****************");
wr.close();
rd.close();

No comments: