Search in sources :

Example 41 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    try {
        populateRulesTable();
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        PolicyModel model = (PolicyModel) getModel();
        CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
        if (!model.canCreateRule(policy, realmName)) {
            btn.setDisabled(true);
        }
        btn = (CCButton) getChild("tblRulesButtonDelete");
        btn.setDisabled(true);
        Map serviceTypes = model.getServiceTypeNames();
        if ((serviceTypes == null) || serviceTypes.isEmpty()) {
            ((CCButton) getChild("tblRulesButtonDelete")).setDisabled(true);
            setDisplayFieldValue("tblRulesNote", model.getLocalizedString("policy.no.service.types"));
        } else {
            setDisplayFieldValue("tblRulesNote", "");
        }
        if (!isInlineAlertMessageSet() && cachedPolicy.isPolicyModified() && isProfilePage()) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.unsaved.message");
        }
    } catch (AMConsoleException e) {
        CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
        btn.setDisabled(true);
        btn = (CCButton) getChild("tblRulesButtonDelete");
        btn.setDisabled(true);
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CCButton(com.sun.web.ui.view.html.CCButton) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 42 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method handleTblConditionsButtonAddRequest.

public void handleTblConditionsButtonAddRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    try {
        if (!reconstructPolicy()) {
            String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            Map activeConditionTypes = model.getActiveConditionTypes(curRealm);
            unlockPageTrail();
            if (activeConditionTypes.size() == 1) {
                String conditionType = (String) activeConditionTypes.keySet().iterator().next();
                String viewBeanURL = model.getConditionViewBeanURL(curRealm, conditionType);
                removePageSessionAttribute(WIZARD);
                setPageSessionAttribute(ConditionOpViewBeanBase.CALLING_VIEW_BEAN, getClass().getName());
                if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
                    forwardToConditionURL(viewBeanURL, "", conditionType, curRealm, "add");
                } else {
                    forwardToConditionAddViewBean(curRealm, conditionType);
                }
            } else {
                setPageSessionAttribute(SelectConditionTypeViewBean.CALLING_VIEW_BEAN, getClass().getName());
                SelectConditionTypeViewBean vb = (SelectConditionTypeViewBean) getViewBean(SelectConditionTypeViewBean.class);
                setPageSessionAttribute(WIZARD, "true");
                passPgSessionMap(vb);
                vb.forwardTo(getRequestContext());
            }
        } else {
            forwardTo();
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblConditionsButtonAddRequest", e);
        redirectToStartURL();
    }
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 43 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class IdentityMembershipConditionAddViewBean method beginDisplay.

/**
     * Sets the values to UI model.
     *
     * @param event Display Event.
     * @throws ModelControlException if the default UI model is not accessible.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    IdentitySubjectModel subjectModel = getSubjectModel();
    PolicyModel model = (PolicyModel) getModel();
    super.beginDisplay(event);
    CCDropDownMenu menu = (CCDropDownMenu) getChild(FILTER_TYPE);
    Map supportedEntityTypes = model.getSupportedEntityTypes(realmName);
    OptionList entityTypes = createOptionList(supportedEntityTypes);
    entityTypes.add(0, "policy.subject.select.identity.type", "");
    menu.setOptions(entityTypes);
    menu.setValue("");
    // initialize the available/selected component
    CCAddRemove child = (CCAddRemove) getChild(VALUES_MULTIPLE_CHOICE_VALUE);
    child.restoreStateData();
    OptionList selected = addRemoveModel.getSelectedOptionList();
    OptionList possible = helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, getPossibleValues(subjectModel, realmName));
    child.resetStateData();
    addRemoveModel.setAvailableOptionList(possible);
}
Also used : IdentitySubjectModel(com.sun.identity.console.policy.model.IdentitySubjectModel) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) Map(java.util.Map) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) OptionList(com.iplanet.jato.view.html.OptionList)

Example 44 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class IdentityMembershipConditionEditViewBean method beginDisplay.

/**
     * Sets the values to UI model.
     *
     * @param event Display Event.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    IdentitySubjectModel subjectModel = getSubjectModel();
    PolicyModel model = (PolicyModel) getModel();
    super.beginDisplay(event);
    if (!canModify) {
        Map mapValues = getDefaultValues();
        if ((mapValues != null) && !mapValues.isEmpty()) {
            Set values = (Set) mapValues.get(AMIdentityMembershipCondition.AM_IDENTITY_NAME);
            Set identityNames = helper.getAMIdentityNames(model.getUserSSOToken(), values);
            propertySheetModel.setValue(VALUES_MULTIPLE_CHOICE_VALUE, AMAdminUtils.getString(identityNames, ",", false));
        }
    } else {
        CCDropDownMenu menu = (CCDropDownMenu) getChild(FILTER_TYPE);
        Map supportedEntityTypes = model.getSupportedEntityTypes(realmName);
        OptionList entityTypes = createOptionList(supportedEntityTypes);
        entityTypes.add(0, "policy.subject.select.identity.type", "");
        menu.setOptions(entityTypes);
        menu.setValue("");
        CCAddRemove child = (CCAddRemove) getChild(VALUES_MULTIPLE_CHOICE_VALUE);
        child.restoreStateData();
        if (!submitCycle) {
            helper.setSelectedIdentities(child, model.getUserSSOToken(), model.getUserLocale(), this, getDefaultValues());
        } else {
            // initialize the available/selected component
            OptionList possible = helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, getPossibleValues(subjectModel, realmName));
            OptionList selected = addRemoveModel.getSelectedOptionList();
            List selectedIds = AMAdminUtils.toList(selected);
            child.resetStateData();
            addRemoveModel.setAvailableOptionList(possible);
            addRemoveModel.setSelectedOptionList(helper.createOptionList(model.getUserSSOToken(), model.getUserLocale(), this, selectedIds));
        }
    }
}
Also used : IdentitySubjectModel(com.sun.identity.console.policy.model.IdentitySubjectModel) Set(java.util.Set) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) Map(java.util.Map) CCDropDownMenu(com.sun.web.ui.view.html.CCDropDownMenu) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) OptionList(com.iplanet.jato.view.html.OptionList)

Example 45 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PMDefaultAuthLevelConditionEditViewBean method beginDisplay.

/**
     * Searches for realms and set up realm selectable list.
     *
     * @param event Display Event.
     * @throws ModelControlException if <code>JATO</code> default model fails.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    String filter = (String) getDisplayFieldValue(AuthLevelHelper.ATTR_FILTER);
    if ((filter == null) || (filter.trim().length() == 0)) {
        setDisplayFieldValue(AuthLevelHelper.ATTR_FILTER, "*");
    }
    PolicyModel model = (PolicyModel) getModel();
    try {
        Set realmNames = helper.getRealmNames(filter, model);
        if (realmNames.isEmpty()) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.authlevel.no.search.result.message");
        } else {
            realmNames.add("");
        }
        String realmValue = (String) propertySheetModel.getValue(AuthLevelHelper.ATTR_REALM);
        if (realmValue == null) {
            realmValue = "";
        }
        if (!bSearchForRealm) {
            if ((realmValue.length() > 0) && !realmNames.contains(realmValue)) {
                realmNames.add(realmValue);
                if (!isInlineAlertMessageSet()) {
                    String msg = model.getLocalizedString("policy.condition.authlevel.no.longer.exist.realm");
                    String[] param = { realmValue };
                    setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", MessageFormat.format(msg, (Object[]) param));
                }
            }
        }
        CCSelect sl = (CCSelect) getChild(AuthLevelHelper.ATTR_REALM);
        sl.setOptions(createOptionList(getLabelValueMap(realmNames)));
        if (sl.getValue() == null) {
            sl.setValue(realmValue);
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : Set(java.util.Set) CCSelect(com.sun.web.ui.view.html.CCSelect) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

PolicyModel (com.sun.identity.console.policy.model.PolicyModel)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 Map (java.util.Map)27 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)26 HashMap (java.util.HashMap)14 Policy (com.sun.identity.policy.Policy)12 Set (java.util.Set)12 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)11 Iterator (java.util.Iterator)8 OptionList (com.iplanet.jato.view.html.OptionList)7 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 QueryResults (com.sun.identity.console.base.model.QueryResults)5 Syntax (com.sun.identity.policy.Syntax)5 Rule (com.sun.identity.policy.Rule)3 Referral (com.sun.identity.policy.interfaces.Referral)3 CCButton (com.sun.web.ui.view.html.CCButton)3 List (java.util.List)3 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)2 ActionSchema (com.sun.identity.policy.ActionSchema)2 ValidValues (com.sun.identity.policy.ValidValues)2