Search in sources :

Example 91 with AMConsoleException

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

the class IDRepoAddViewBean method handleButton2Request.

/**
     * Handles create realm request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    IDRepoModel model = (IDRepoModel) getModel();
    AMPropertySheet prop = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    String idRepoType = (String) propertySheetModel.getValue(IDREPO_TYPE);
    String idRepoName = (String) propertySheetModel.getValue(IDREPO_NAME);
    Map defaultValues = model.getDefaultAttributeValues(idRepoType);
    if (idRepoName.trim().length() > 0) {
        try {
            boolean LoadSchema = false;
            Map values = prop.getAttributeValues(defaultValues.keySet());
            String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            Set set = (HashSet) values.get("idRepoLoadSchema");
            if (set != null) {
                Iterator i = set.iterator();
                if (i.hasNext()) {
                    String loadingSchemaFlag = (String) i.next();
                    if (loadingSchemaFlag.equals("true") && IdRepoUtils.hasIdRepoSchema(idRepoType)) {
                        LoadSchema = true;
                    }
                }
            }
            model.createIDRepo(realmName, idRepoName, idRepoType, values);
            if (LoadSchema == true) {
                ServletContext servletCtx = event.getRequestContext().getServletContext();
                model.loadIdRepoSchema(idRepoName, realmName, servletCtx);
            }
            forwardToIDRepoViewBean();
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "idrepo.missing.idRepoName");
        forwardTo();
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) Iterator(java.util.Iterator) ServletContext(javax.servlet.ServletContext) IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashSet(java.util.HashSet)

Example 92 with AMConsoleException

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

the class IDRepoViewBean method getIDRepoNames.

private void getIDRepoNames() {
    IDRepoModel model = (IDRepoModel) getModel();
    try {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        populateTableModel(model.getIDRepoNames(curRealm));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        // disable the button if the current location is invalid
        CCButton btnAdd = (CCButton) getChild(TBL_BUTTON_ADD);
        btnAdd.setDisabled(true);
    }
}
Also used : CCButton(com.sun.web.ui.view.html.CCButton) IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 93 with AMConsoleException

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

the class IDRepoViewBean method handleTblDataActionHrefRequest.

/**
     * Forwards request to edit ID Repo view bean.
     *
     * @param event Request Invocation Event.
     */
public void handleTblDataActionHrefRequest(RequestInvocationEvent event) {
    String idRepoName = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF));
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        IDRepoModel model = (IDRepoModel) getModel();
        setPageSessionAttribute(IDRepoOpViewBeanBase.IDREPO_NAME, idRepoName);
        setPageSessionAttribute(IDRepoOpViewBeanBase.IDREPO_TYPE, model.getIDRepoType(curRealm, idRepoName));
        IDRepoEditViewBean vb = (IDRepoEditViewBean) getViewBean(IDRepoEditViewBean.class);
        unlockPageTrail();
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        forwardTo();
    }
}
Also used : IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 94 with AMConsoleException

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

the class IDRepoEditViewBean method handleButton1Request.

/**
     * Handles save request when editing the properties of a data store 
     * entry for a realm.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    IDRepoModel model = (IDRepoModel) getModel();
    AMPropertySheet prop = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    String idRepoType = (String) propertySheetModel.getValue(IDREPO_TYPE);
    String idRepoName = (String) propertySheetModel.getValue(IDREPO_NAME);
    Map defaultValues = model.getDefaultAttributeValues(idRepoType);
    if (idRepoName.trim().length() > 0) {
        try {
            boolean LoadSchema = false;
            Map values = prop.getAttributeValues(defaultValues.keySet());
            String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            values.remove(IdConstants.SERVICE_ATTRS);
            Set set = (HashSet) values.get("idRepoLoadSchema");
            if (set != null) {
                Iterator i = set.iterator();
                if (i.hasNext()) {
                    String loadingSchemaFlag = (String) i.next();
                    if (loadingSchemaFlag.equals("true") && IdRepoUtils.hasIdRepoSchema(idRepoType)) {
                        LoadSchema = true;
                    }
                }
            }
            model.editIDRepo(realmName, idRepoName, values);
            if (LoadSchema == true) {
                ServletContext servletCtx = event.getRequestContext().getServletContext();
                model.loadIdRepoSchema(idRepoName, realmName, servletCtx);
            }
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "idrepo.missing.idRepoName");
    }
    forwardTo();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) Iterator(java.util.Iterator) ServletContext(javax.servlet.ServletContext) IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashSet(java.util.HashSet)

Example 95 with AMConsoleException

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

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