Search in sources :

Example 26 with Rule

use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.

the class RuleEditViewBean method handleButton1Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    boolean forwarded = false;
    Rule rule = createRule();
    if (rule != null) {
        try {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String origRuleName = (String) getPageSessionAttribute(EDIT_RULE_NAME);
            policy.removeRule(origRuleName);
            policy.addRule(rule);
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.rule.updated");
            cachedPolicy.setPolicyModified(true);
        } catch (NameAlreadyExistsException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        } catch (InvalidNameException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        } catch (AMConsoleException e) {
            debug.warning("RuleEditViewBean.handleButton1Request", e);
            redirectToStartURL();
            forwarded = true;
        }
    }
    if (!forwarded) {
        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)

Example 27 with Rule

use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.

the class RuleEditViewBean method isActionSelected.

public boolean isActionSelected(ActionSchema as) {
    boolean selected = false;
    if (actionValues != null) {
        Set values = (Set) actionValues.get(as.getName());
        selected = (values != null) && !values.isEmpty();
    } else {
        try {
            Rule rule = getRule();
            Set actionNames = rule.getActionNames();
            selected = (actionNames != null) && actionNames.contains(as.getName());
        } catch (NameNotFoundException e) {
            selected = false;
        } catch (AMConsoleException e) {
            debug.warning("RuleEditViewBean.isActionSelected", e);
            selected = false;
        }
    }
    return selected;
}
Also used : Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 28 with Rule

use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.

the class RuleEditViewBean method getDefaultActionValues.

public Set getDefaultActionValues(ActionSchema as) {
    Set values = null;
    try {
        Rule rule = getRule();
        values = rule.getActionValues(as.getName());
        if (values == null) {
            values = as.getDefaultValues();
        }
    } catch (NameNotFoundException e) {
        values = as.getDefaultValues();
    } catch (AMConsoleException e) {
        debug.warning("RuleEditViewBean.getDefaultActionValues", e);
        values = as.getDefaultValues();
    }
    return values;
}
Also used : Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

Rule (com.sun.identity.policy.Rule)28 Policy (com.sun.identity.policy.Policy)15 HashSet (java.util.HashSet)12 Set (java.util.Set)12 PolicyException (com.sun.identity.policy.PolicyException)9 SSOException (com.iplanet.sso.SSOException)8 Subject (com.sun.identity.policy.interfaces.Subject)8 AMException (com.iplanet.am.sdk.AMException)6 InvalidAuthContextException (com.sun.identity.authentication.internal.InvalidAuthContextException)6 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)6 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)6 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)6 SMSException (com.sun.identity.sm.SMSException)6 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 LoginException (javax.security.auth.login.LoginException)6 ByteString (org.forgerock.opendj.ldap.ByteString)6