Source:
protected void doAddUser(User user, Object credential, String[] roleList, Map<String, String> claims, String profileName, boolean requirePasswordChange) throws UserStoreException { String userName = user.getName(); DirContext dirContext = getSearchBaseDirectoryContext(); BasicAttributes basicAttributes = getAddUserBasicAttributes(escapeSpecialCharactersForDN(userName)); BasicAttribute userPassword = new BasicAttribute("userPassword"); String passwordHashMethod = this.realmConfig.getUserStoreProperty(PASSWORD_HASH_METHOD); if (passwordHashMethod == null) { passwordHashMethod = realmConfig.getUserStoreProperty("passwordHashMethod"); } byte[] passwordToStore = UserCoreUtil.getPasswordToStore(credential, this.realmConfig.getUserStoreProperty (PASSWORD_HASH_METHOD), kdcEnabled); userPassword.add(passwordToStore); basicAttributes.put(userPassword); setUserClaims(claims, basicAttributes, userName); try { NameParser ldapParser = dirContext.getNameParser(""); Name compoundName = ldapParser.parse(realmConfig .getUserStoreProperty(LDAPConstants.USER_NAME_ATTRIBUTE) + "=" + escapeSpecialCharactersForDN(userName)); if (log.isDebugEnabled()) { log.debug("Binding user: " + compoundName); } dirContext.bind(compoundName, null, basicAttributes); } catch (NamingException e) { String errorMessage = "Cannot access the directory context or " + "user already exists in the system for user :" + userName; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { JNDIUtil.closeContext(dirContext); UserCoreUtil.clearSensitiveBytes(passwordToStore); } if(roleList != null && roleList.length > 0) { try { doUpdateRoleListOfUser(userName, null, roleList); if (log.isDebugEnabled()) { log.debug("Roles are added for user : " + userName + " successfully."); } } catch (UserStoreException e) { String errorMessage = "User is added. But error while updating role list of user : " + userName; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } } }

Target:
protected void doAddUser(User user, Object credential, String[] roleList, Map<String, String> claims, String profileName, boolean requirePasswordChange) throws UserStoreException { String userName = user.getName(); DirContext dirContext = getSearchBaseDirectoryContext(); BasicAttributes basicAttributes = getAddUserBasicAttributes(escapeSpecialCharactersForDN(userName)); BasicAttribute userPassword = new BasicAttribute("userPassword"); String passwordHashMethod = this.realmConfig.getUserStoreProperty(PASSWORD_HASH_METHOD); if (passwordHashMethod == null) { passwordHashMethod = realmConfig.getUserStoreProperty("passwordHashMethod"); } byte[] passwordToStore = UserCoreUtil.getPasswordToStore(credential, this.realmConfig.getUserStoreProperty (PASSWORD_HASH_METHOD), kdcEnabled); userPassword.add(passwordToStore); basicAttributes.put(userPassword); setUserClaims(claims, basicAttributes, userName); try { NameParser ldapParser = dirContext.getNameParser(""); Name compoundName = ldapParser.parse(realmConfig .getUserStoreProperty(LDAPConstants.USER_NAME_ATTRIBUTE) + "=" + escapeSpecialCharactersForDN (userName)); if (log.isDebugEnabled()) { log.debug("Binding user: " + compoundName); } dirContext.bind(compoundName, null, basicAttributes); } catch (NamingException e) { String errorMessage = "Cannot access the directory context or user already exists in the system for " + "user with id:" + user.getId(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { JNDIUtil.closeContext(dirContext); UserCoreUtil.clearSensitiveBytes(passwordToStore); } if (roleList != null && roleList.length > 0) { try { doUpdateRoleListOfUser(userName, null, roleList); if (log.isDebugEnabled()) { log.debug("Roles are added for user : " + userName + " successfully."); } } catch (UserStoreException e) { String errorMessage = "User is added. But error while updating role list of user : " + userName; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } } }