package com.massiveGaze.users; import java.util.Calendar; import java.util.HashMap; import java.util.Map; import oracle.iam.identity.usermgmt.api.UserManagerConstants.AttributeName; import oracle.iam.platform.context.ContextManager; import oracle.iam.selfservice.uself.uselfmgmt.api.UnauthenticatedSelfService; import com.massiveGaze.connection.Platform; public class CreateSelfRegistartionRequest { public static void main(String[] args) { CreateSelfRegistartionRequest selfRequest = new CreateSelfRegistartionRequest(); System.out.println("Calling registerUser Method..!"); selfRequest.registerUser(); System.out.println("End Of registerUser Method..!"); } public String registerUser() { System.out.println("Inside registerUser Method..!"); System.out.println("Connection Established Without Credentials ..!"); String requestId = null; if (ContextManager.getOIMUser() != null && !ContextManager.getOIMUser().toString().equalsIgnoreCase("anonymous")) { System.out.println ("Before pop context testSubmitRegistrationPasswordAutoGeneratedRequest loggedInUser : " + ContextManager.getOIMUser()); ContextManager.popContext(); ContextManager.clearContext(); } UnauthenticatedSelfService unauth = Platform .getService(UnauthenticatedSelfService.class); Map<String, String> mapAttrRef = new HashMap<String, String>(); mapAttrRef.put("Last Name", "Last Name"); mapAttrRef.put("First Name", "First Name"); mapAttrRef.put("Email", "Email"); mapAttrRef.put("User Login", "User Login"); mapAttrRef.put("Password", "Password"); mapAttrRef.put("act_key", "Organization"); mapAttrRef.put("Start Date", "Start Date"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1); Map<String, Object> mapRequest = new HashMap<String, Object>(); mapRequest.put("act_key", new Long("1")); mapRequest.put("Last Name", "USER"); mapRequest.put("First Name", "TEST"); mapRequest.put("Email", "TEST.USER@acme.com"); mapRequest.put("User Login", "TUSER"); mapRequest.put("Password", "Welcome1"); mapRequest.put("Start Date", cal.getTime()); Map<String, Object> mapQnA = new HashMap<String, Object>(); mapQnA.put("What is your favorite color?", "1"); mapQnA.put("What is your mother's maiden name?", "2"); mapQnA.put("What is the city of your birth?", "3"); mapRequest=addSuffixToAttribute(mapRequest); try { requestId = unauth.submitRegistrationRequest(mapRequest, mapQnA, "Self-Register User", mapAttrRef); System.out.println("requestId ->" + requestId); } catch (Exception e) { e.printStackTrace(); } return requestId; } public static Map<String, Object> addSuffixToAttribute(Map<String, Object> attrMap) { StringBuffer strBuf = new StringBuffer(); int suffix = getRandomNumber(); if (attrMap.get(AttributeName.USER_LOGIN.getId()) != null) { String login = attrMap.get(AttributeName.USER_LOGIN.getId()) .toString(); System.out.println("Before User Login :" + login); strBuf.append(login); strBuf.append(suffix); attrMap.put("User Login", strBuf.toString()); System.out.println("After User Login :" + strBuf.toString()); strBuf.setLength(0); } if (attrMap.get(AttributeName.FIRSTNAME.getId()) != null) { String firstName = attrMap.get(AttributeName.FIRSTNAME.getId()) .toString(); System.out.println("Before firstName :" + firstName); strBuf.append(firstName); strBuf.append(suffix); attrMap.put(AttributeName.FIRSTNAME.getId(), strBuf.toString()); System.out.println("After firstName :" + strBuf.toString()); strBuf.setLength(0); } if (attrMap.get(AttributeName.LASTNAME.getId()) != null) { String lastName = attrMap.get(AttributeName.LASTNAME.getId()) .toString(); System.out.println("Before Last Name :" + lastName); strBuf.append(lastName); strBuf.append(suffix); attrMap.put(AttributeName.LASTNAME.getId(), strBuf.toString()); System.out.println("After Last Name :" + strBuf.toString()); strBuf.setLength(0); } if (attrMap.get(AttributeName.EMAIL.getId()) != null) { String email = attrMap.get(AttributeName.EMAIL.getId()).toString(); System.out.println(" EMAIL Before Modify :" + email); strBuf.append(email.replace(".com", suffix + ".com")); attrMap.put(AttributeName.EMAIL.getId(), strBuf.toString()); System.out.println("EMAIL After Modify:" + strBuf.toString()); strBuf.setLength(0); } return attrMap; } public static int getRandomNumber() { java.util.Random r = new java.util.Random(Calendar.getInstance() .getTimeInMillis()); int randint = Math.abs(r.nextInt()) % 1000; return randint; } }
Oracle Identity Manager (OIM R2PS2/PS3/12C) is a highly flexible and scalable enterprise identity administration system that provides operational and business efficiency by providing centralized administration & complete automation of identity and user provisioning events across enterprise as well as extranet applications.
OIM API to Create SelfRegistartion Request
Subscribe to:
Posts (Atom)
About OIM
Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...
Popular Posts
-
OIM API's Sample Code : Videos: Massive Gaze Videos Connection Related API's : OIM DB Connection/ Data Source connection ...
-
Videos: Massive Gaze Videos 1. Basic OIM Information 2. MDS Export/Import 3. Steps For R2PS2 / R2PS3 Custom Pre-processor Ev...
-
Videos: Massive Gaze Videos 1. Query to get OIM Provsioned/provisioning Account details 2. Query to get usr keys For Rejected / ...
No comments:
Post a Comment