Search in sources :

Example 41 with CachedPolicy

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

the class PolicyOpViewBeanBase method handleTblConditionsButtonDeleteRequest.

/**
     * Handles delete condition request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblConditionsButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_CONDITIONS);
    table.restoreStateData();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Integer[] selected = tblConditionsModel.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            tblConditionsModel.setRowIndex(selected[i].intValue());
            String conditionName = (String) tblConditionsModel.getValue(TBL_CONDITIONS_DATA_NAME);
            policy.removeCondition(conditionName);
        }
        cachedPolicy.setPolicyModified(true);
        populateConditionsTable();
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblConditionsButtonDeleteRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 42 with CachedPolicy

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

the class PolicyOpViewBeanBase method populateResponseProvidersTable.

protected void populateResponseProvidersTable() throws AMConsoleException {
    tblResponseProvidersModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set responseProviderNames = policy.getResponseProviderNames();
    if ((responseProviderNames != null) && !responseProviderNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map localizedRespAttrTypeNames = model.getActiveResponseProviderTypes(realmName);
        boolean firstEntry = true;
        for (Iterator i = responseProviderNames.iterator(); i.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblResponseProvidersModel.appendRow();
            }
            try {
                String name = (String) i.next();
                ResponseProvider provider = policy.getResponseProvider(name);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME, name);
                String respAttrTypeName = model.getResponseProviderTypeName(realmName, provider);
                String displayName = (String) localizedRespAttrTypeNames.get(respAttrTypeName);
                if (displayName == null) {
                    displayName = respAttrTypeName;
                }
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_TYPE, displayName);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateResponseProvidersTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 43 with CachedPolicy

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

the class PolicyOpViewBeanBase method handleTblRulesEditLinkRequest.

/**
     * Handles edit rule request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblRulesEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_RULES_ACTION_HREF));
    setPageSessionAttribute(RuleEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(RuleEditViewBean.EDIT_RULE_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Rule rule = policy.getRule(name);
        RuleEditViewBean vb = null;
        String resName = rule.getResourceName();
        if ((resName == null) || (resName.length() == 0)) {
            vb = (RuleNoResourceEditViewBean) getViewBean(RuleNoResourceEditViewBean.class);
            setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.FALSE);
        } else {
            String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            String serviceType = rule.getServiceTypeName();
            if (model.canCreateNewResource(realmName, serviceType)) {
                vb = (RuleEditViewBean) getViewBean(RuleEditViewBean.class);
            } else {
                vb = (RuleEditViewBean) getViewBean(RuleWithPrefixEditViewBean.class);
            }
            setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.TRUE);
        }
        unlockPageTrail();
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblRulesEditLinkRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 44 with CachedPolicy

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

the class SelectTypeViewBeanBase method getCachedPolicy.

protected CachedPolicy getCachedPolicy() throws AMConsoleException {
    CachedPolicy policy = null;
    String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
    if (cacheID != null) {
        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)

Example 45 with CachedPolicy

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

the class RuleAddViewBean method handleButton2Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    Rule rule = createRule();
    if (rule != null) {
        try {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            policy.addRule(rule);
            backTrail();
            cachedPolicy.setPolicyModified(true);
            forwardToPolicyViewBean();
        } catch (NameAlreadyExistsException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
            forwardTo();
        } catch (InvalidNameException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
            forwardTo();
        } catch (AMConsoleException e) {
            debug.warning("RuleAddViewBean.handleButton2Request", e);
            redirectToStartURL();
        }
    } else {
        forwardTo();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)53 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)38 Policy (com.sun.identity.policy.Policy)37 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)26 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)21 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)10 InvalidNameException (com.sun.identity.policy.InvalidNameException)9 Map (java.util.Map)9 Set (java.util.Set)9 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 Condition (com.sun.identity.policy.interfaces.Condition)6 Subject (com.sun.identity.policy.interfaces.Subject)6 HashMap (java.util.HashMap)6 Iterator (java.util.Iterator)6 Referral (com.sun.identity.policy.interfaces.Referral)5 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)5 CCActionTable (com.sun.web.ui.view.table.CCActionTable)5 Rule (com.sun.identity.policy.Rule)4 QueryResults (com.sun.identity.console.base.model.QueryResults)1 SimpleTimeCondition (com.sun.identity.policy.plugins.SimpleTimeCondition)1