Search in sources :

Example 86 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class EntityEditViewBean method getEntitiesID.

protected Set getEntitiesID(Set entities) {
    Set ids = new HashSet(entities.size() * 2);
    for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
        AMIdentity entity = (AMIdentity) iter.next();
        ids.add(IdUtils.getUniversalId(entity));
    }
    return ids;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 87 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class EntityEditViewBean method getEntityDisplayNames.

protected List getEntityDisplayNames(Collection entities) {
    List displayNames = null;
    if ((entities != null) && !entities.isEmpty()) {
        EntitiesModel model = (EntitiesModel) getModel();
        Set names = new HashSet(entities.size() * 2);
        for (Iterator iter = entities.iterator(); iter.hasNext(); ) {
            AMIdentity entity = (AMIdentity) iter.next();
            names.add(AMFormatUtils.getIdentityDisplayName(model, entity));
        }
        displayNames = AMFormatUtils.sortItems(names, model.getUserLocale());
    }
    return (displayNames != null) ? displayNames : Collections.EMPTY_LIST;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel) HashSet(java.util.HashSet)

Example 88 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class UMChangeUserPasswordModelImpl method getPassword.

/** 
     * Returns user password.
     *
     * @param userId Universal ID of user.
     * @return user password.
     * @throws AMConsoleException if password cannot be obtained.
     */
public String getPassword(String userId) throws AMConsoleException {
    String password = "";
    String[] params = { userId, AMAdminConstants.ATTR_USER_PASSWORD };
    try {
        logEvent("ATTEMPT_READ_IDENTITY_ATTRIBUTE_VALUE", params);
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
        Set set = amid.getAttribute(AMAdminConstants.ATTR_USER_PASSWORD);
        if ((set != null) && !set.isEmpty()) {
            password = (String) set.iterator().next();
        }
        logEvent("SUCCEED_READ_IDENTITY_ATTRIBUTE_VALUE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
        logEvent("SSO_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
        logEvent("IDM_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    }
    return password;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 89 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class UMChangeUserPasswordModelImpl method changePassword.

/**
     * Modifies user password.
     *
     * @param userId Universal ID of user.
     * @param password New password.
     * @throws AMConsoleException if password cannot be modified.
     */
public void changePassword(String userId, String password) throws AMConsoleException {
    String[] params = { userId, AMAdminConstants.ATTR_USER_PASSWORD };
    try {
        logEvent("ATTEMPT_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
        Map map = new HashMap(2);
        Set set = new HashSet(2);
        set.add(password);
        map.put(AMAdminConstants.ATTR_USER_PASSWORD, set);
        amid.setAttributes(map);
        amid.store();
        logEvent("SUCCEED_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
        logEvent("SSO_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_PASSWORD, strError };
        logEvent("IDM_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        if (e.getErrorCode().equals(IdRepoErrorCode.LDAP_EXCEPTION)) {
            throw new AMConsoleException(e.getConstraintViolationDetails());
        }
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 90 with AMIdentity

use of com.sun.identity.idm.AMIdentity in project OpenAM by OpenRock.

the class UMChangeUserPasswordModelImpl method changePwd.

/**
      * Modifies user password after validating old password.
      *
      * @param userId Universal ID of user.
      * @param oldpwd old password.
      * @param newpwd New password.
      * @throws AMConsoleException if password cannot be modified.
      */
public void changePwd(String userId, String oldpwd, String newpwd) throws AMConsoleException {
    String[] params = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD };
    try {
        logEvent("ATTEMPT_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), userId);
        amid.changePassword(oldpwd, newpwd);
        logEvent("SUCCEED_MODIFY_IDENTITY_ATTRIBUTE_VALUE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD, strError };
        logEvent("SSO_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { userId, AMAdminConstants.ATTR_USER_OLD_PASSWORD, strError };
        logEvent("IDM_EXCEPTION_MODIFY_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

AMIdentity (com.sun.identity.idm.AMIdentity)373 IdRepoException (com.sun.identity.idm.IdRepoException)243 SSOException (com.iplanet.sso.SSOException)215 Set (java.util.Set)170 HashSet (java.util.HashSet)150 SSOToken (com.iplanet.sso.SSOToken)112 Iterator (java.util.Iterator)91 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)85 Map (java.util.Map)83 HashMap (java.util.HashMap)78 IdType (com.sun.identity.idm.IdType)52 SMSException (com.sun.identity.sm.SMSException)52 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)44 CLIException (com.sun.identity.cli.CLIException)43 IOutput (com.sun.identity.cli.IOutput)42 IdSearchResults (com.sun.identity.idm.IdSearchResults)39 IdSearchControl (com.sun.identity.idm.IdSearchControl)35 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)23 Test (org.testng.annotations.Test)23 List (java.util.List)22