Skip to Main Content

Security Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

set User default password while being created through OIM Console

idm1983May 1 2013 — edited May 3 2013
Hi,

I am trying to implement preprocess event handler for users created by OIM admins. The process does not throw any error but the problem is I am not able to login using the new password.

the new_pwd[] is getting printed in the logs, but is that write. Please help.



package com.ul.aim.eventhandler;

import Thor.API.Security.XLClientSecurityAssociation;

import java.io.Serializable;
import java.util.HashMap;

import com.thortech.util.logging.Logger;

import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.spi.PreProcessHandler;
import oracle.iam.platform.kernel.vo.AbstractGenericOrchestration;
import oracle.iam.platform.kernel.vo.BulkEventResult;
import oracle.iam.platform.kernel.vo.BulkOrchestration;
import oracle.iam.platform.kernel.vo.EventResult;
import oracle.iam.platform.kernel.vo.Orchestration;
import oracle.iam.passwordmgmt.domain.generator.RandomPasswordGeneratorImpl;
import oracle.iam.platform.Platform;


public class PasswordPreProcessEventHandlers implements PreProcessHandler{

private Logger logger=Logger.getLogger("JEF-OIM-LOGGER");

private String methodName="";
public PasswordPreProcessEventHandlers()
{
debug("Invoking NamePreProcessEventHandlers");
}
@Override
public boolean cancel(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub
return false;
}

@Override
public void compensate(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub

}

// Write Your implementation.
public EventResult execute(long processId, long eventId, Orchestration orchestration) {
// TODO Auto-generated method stub


this.methodName="execute";
// this method getting the Request parameters from the OIM form
HashMap parameters=orchestration.getParameters();

debug("Parameters "+parameters);
String operation=orchestration.getOperation();
debug("Pre Process Password Operation "+operation);

if(operation != null && operation.equalsIgnoreCase("create"))
{
String usrLogin= getParamaterValue(parameters,"User Login");
//User nuser = new User(usrLogin);
RandomPasswordGeneratorImpl randomPasswordGenerator = new RandomPasswordGeneratorImpl();
char new_pwd[] = randomPasswordGenerator.generatePassword(new User(null));

UserManager userManager = Platform.getService(UserManager.class);
try{
userManager.changePassword(usrLogin,new_pwd,true,false);
}
catch(Exception e)
{
debug("Inside Catch");
}
String usrPwd;
for (int i=0; i<new_pwd.length; i++)
debug("Password ==="+new_pwd.length+"========"+i+"===== "+new_pwd);




}
return new EventResult();
}

@Override
public BulkEventResult execute(long arg0, long arg1, BulkOrchestration arg2) {
// TODO Auto-generated method stub
return null;
}

@Override
public void initialize(HashMap arg0) {
// TODO Auto-generated method stub

}

/**
* Getting the Value from the Request Parameters
*/
private String getParamaterValue(HashMap parameters,
String key) {
String value = (parameters.get(key) instanceof ContextAware)
? (String) ((ContextAware) parameters.get(key)).getObjectValue()
: (String) parameters.get(key);
return value;
}

private void debug(String message)
{
logger.debug(this.getClass().getName()+" : "+methodName+" : "+message);
}

private class tcDataBaseClient {
}
}
This post has been answered by Kevin Pinsky on May 3 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2013
Added on May 1 2013
7 comments
294 views