Search in sources :

Example 96 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException 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 97 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException 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)

Example 98 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class UMUserPasswordResetOptionsViewBean method getQuestions.

private void getQuestions() {
    UMUserPasswordResetOptionsModel model = (UMUserPasswordResetOptionsModel) getModel();
    String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
    try {
        List questionAnswers = model.getUserAnswers(userId);
        populateTableModel(questionAnswers);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) UMUserPasswordResetOptionsModel(com.sun.identity.console.user.model.UMUserPasswordResetOptionsModel)

Example 99 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class UMUserResourceOfferingAddViewBean method handleButton1Request.

protected void handleButton1Request(SMDiscoEntryData smData) {
    UMUserResourceOfferingViewBean vb = (UMUserResourceOfferingViewBean) getViewBean(UMUserResourceOfferingViewBean.class);
    UMUserResourceOfferingModel model = (UMUserResourceOfferingModel) getModel();
    DiscoveryDataCache cache = DiscoveryDataCache.getInstance();
    String cacheID = (String) getPageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
    SMDiscoveryServiceData data = (SMDiscoveryServiceData) cache.getData(model.getUserSSOToken(), cacheID);
    data.addResourceData(smData);
    String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
    try {
        model.setUserDiscoEntry(userId, data);
        removePageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        forwardTo();
    }
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) UMUserResourceOfferingModel(com.sun.identity.console.user.model.UMUserResourceOfferingModel) DiscoveryDataCache(com.sun.identity.console.service.model.DiscoveryDataCache)

Example 100 with AMConsoleException

use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.

the class UMUserResourceOfferingEditViewBean method handleButton1Request.

protected void handleButton1Request(SMDiscoEntryData smData) throws AMConsoleException {
    UMUserResourceOfferingModel model = (UMUserResourceOfferingModel) getModel();
    DiscoveryDataCache cache = DiscoveryDataCache.getInstance();
    String cacheID = (String) getPageSessionAttribute(UMUserResourceOfferingViewBean.DATA_ID);
    SMDiscoveryServiceData smEntry = cache.getData(model.getUserSSOToken(), cacheID);
    int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
    smEntry.replaceResourceData(index, smData);
    String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
    try {
        model.setUserDiscoEntry(userId, smEntry);
        removePageSessionAttribute(PG_SESSION_MODIFIED);
        removePageSessionAttribute(PGATTR_ORIG_MECH_ID);
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : SMDiscoveryServiceData(com.sun.identity.console.service.model.SMDiscoveryServiceData) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) UMUserResourceOfferingModel(com.sun.identity.console.user.model.UMUserResourceOfferingModel) DiscoveryDataCache(com.sun.identity.console.service.model.DiscoveryDataCache)

Aggregations

AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)701 Map (java.util.Map)255 Set (java.util.Set)206 HashMap (java.util.HashMap)193 HashSet (java.util.HashSet)148 SSOException (com.iplanet.sso.SSOException)126 Iterator (java.util.Iterator)122 List (java.util.List)97 SMSException (com.sun.identity.sm.SMSException)83 ArrayList (java.util.ArrayList)78 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)76 IdRepoException (com.sun.identity.idm.IdRepoException)58 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)47 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)46 AMIdentity (com.sun.identity.idm.AMIdentity)44 SAMLv2Model (com.sun.identity.console.federation.model.SAMLv2Model)41 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)41 CCActionTable (com.sun.web.ui.view.table.CCActionTable)40 TreeSet (java.util.TreeSet)39 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)38