I've created a custom authentication plugin and login plugin to allow users from my other system automatically login to nuxeo as long as they have an active cookie but we don't have user accounts for all users from my other system.
I am trying to create user accounts in the login plugin during the validateUserIdentity function but I can't figure out exactly how to go about doing this. Does anyone have the code I'm missing?
@Override
public String validatedUserIdentity(UserIdentificationInfo userIdent)
{
log.info("validate user id");
try
{
log.info("get user manager");
UserManager userManager = Framework.getService(UserManager.class);
log.info("try to get user principal from: " + userIdent.getUserName());
NuxeoPrincipal principal = userManager.getPrincipal(userIdent.getUserName());
if ( principal != null )
{
log.info("found pricipal, returning username");
//found an existing user, just return the username?
return userIdent.getUserName();
}
else
{
log.info("principal was null, create a new user");
UserSession user_session = WebEngine.getActiveContext().getUserSession();
CoreSession core_session = user_session.getCoreSession();
//Was attempting to find a way to get a user doc ref but couldn't figure it out
//TODO get the user doc model and fill it out somehow?
DocumentModel user_doc_model = new something();
userManager.createUser(user);
}
}
catch ( Exception ex )
{
log.error("error getting pricipal",ex);
}
return null;
}
Any help would be much appreciated!