Search in sources :

Example 16 with PolicyModel

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

the class SubjectOpViewBeanBase method getCachedPolicy.

protected CachedPolicy getCachedPolicy() throws AMConsoleException {
    CachedPolicy policy = null;
    String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
    if (cacheID != null) {
        PolicyCache cache = PolicyCache.getInstance();
        PolicyModel model = (PolicyModel) getModel();
        policy = model.getCachedPolicy(cacheID);
    }
    return policy;
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) PolicyCache(com.sun.identity.console.policy.model.PolicyCache)

Example 17 with PolicyModel

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

the class SubjectOpViewBeanBase method createOptionList.

protected OptionList createOptionList(Set values) {
    OptionList optList = new OptionList();
    if ((values != null) && !values.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String subjectType = (String) propertySheetModel.getValue(SUBJECT_TYPE);
        Map mapLabels = model.getDisplayNameForSubjectValues(realmName, subjectType, values);
        List tmp = AMFormatUtils.sortItems(values, model.getUserLocale());
        for (Iterator iter = tmp.iterator(); iter.hasNext(); ) {
            String value = (String) iter.next();
            optList.add((String) mapLabels.get(value), value);
        }
    }
    return optList;
}
Also used : Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList)

Example 18 with PolicyModel

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

the class SelectReferralTypeViewBean method handleButton2Request.

/**
     * Handles next button request.
     *
     * @param event Request invocation event.
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String referralType = (String) propertySheetModel.getValue(ATTR_REFERRAL_TYPE);
    setPageSessionAttribute(ReferralOpViewBeanBase.CALLING_VIEW_BEAN, (String) getPageSessionAttribute(CALLING_VIEW_BEAN));
    String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    String viewBeanURL = model.getReferralViewBeanURL(realmName, referralType);
    unlockPageTrailForSwapping();
    if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
        forwardToURL(viewBeanURL, referralType, realmName);
    } else {
        forwardToViewBean(model, referralType, realmName);
    }
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel)

Example 19 with PolicyModel

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

the class SelectServiceTypeViewBean method getTypeOptions.

protected OptionList getTypeOptions() {
    PolicyModel model = (PolicyModel) getModel();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        Policy policy = getCachedPolicy().getPolicy();
        Map map = model.getServiceTypeNames();
        Map options = new HashMap();
        for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
            String name = (String) iter.next();
            String label = (String) map.get(name);
            if (model.requiredResourceName(policy, curRealm, name)) {
                String[] param = { label };
                String lbl = MessageFormat.format(model.getLocalizedString("policy.rules.withResourceName"), (Object[]) param);
                options.put(name + "|" + WITH_RESOURCE_SUFFIX, lbl);
            }
            if (model.notRequiredResourceName(policy, curRealm, name)) {
                String[] param = { label };
                String lbl = MessageFormat.format(model.getLocalizedString("policy.rules.withoutResourceName"), (Object[]) param);
                options.put(name + "|" + WITHOUT_RESOURCE_SUFFIX, lbl);
            }
        }
        return AMFormatUtils.getSortedOptionList(options, model.getUserLocale());
    } catch (AMConsoleException e) {
        debug.message("SelectServiceTypeViewBean.getTypeOptions " + "creating empty option list");
        return new OptionList();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) HashMap(java.util.HashMap) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList)

Example 20 with PolicyModel

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

the class SelectServiceTypeViewBean method handleButton2Request.

/**
     * Handles next button request.
     *
     * @param event Request invocation event.
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String formatServiceType = (String) propertySheetModel.getValue(ATTR_SERVICE_TYPE);
    int idx = formatServiceType.indexOf("|");
    String serviceType = formatServiceType.substring(0, idx);
    boolean withResource = formatServiceType.substring(idx + 1).equals(WITH_RESOURCE_SUFFIX);
    setPageSessionAttribute(RuleOpViewBeanBase.CALLING_VIEW_BEAN, (String) getPageSessionAttribute(CALLING_VIEW_BEAN));
    setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, withResource ? Boolean.TRUE : Boolean.FALSE);
    RuleAddViewBean vb = null;
    if (withResource) {
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        if (model.canCreateNewResource(realmName, serviceType)) {
            vb = (RuleAddViewBean) getViewBean(RuleAddViewBean.class);
        } else {
            vb = (RuleAddViewBean) getViewBean(RuleWithPrefixAddViewBean.class);
        }
    } else {
        vb = (RuleNoResourceAddViewBean) getViewBean(RuleNoResourceAddViewBean.class);
    }
    unlockPageTrailForSwapping();
    passPgSessionMap(vb);
    vb.serviceType = serviceType;
    vb.forwardTo(getRequestContext());
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel)

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