Search in sources :

Example 11 with Condition

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

the class ConditionTypeManager method getCondition.

/**
     * Returns an instance of the <code>Condition</code>
     * given the condition type name.
     *
     * @param conditionType condition type name.
     * @return an instance of the <code>Condition</code>
     *            given the condition type name.
     * @throws NameNotFoundException if the <code>Condition</code> for the
     *            <code>conditionType</code> name is not found
     * @throws PolicyException for any other abnormal condition
     */
public Condition getCondition(String conditionType) throws NameNotFoundException, PolicyException {
    PluginSchema ps = PolicyManager.getPluginSchema(CONDITION, conditionType);
    if (ps == null) {
        throw (new NameNotFoundException(ResBundleUtils.rbName, "invalid_condition", null, conditionType, PolicyException.USER_COLLECTION));
    }
    // Construct the object
    Condition condition = null;
    try {
        String className = ps.getClassName();
        condition = (Condition) Class.forName(className).newInstance();
    } catch (Exception e) {
        throw (new PolicyException(e));
    }
    return (condition);
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) SSOException(com.iplanet.sso.SSOException)

Example 12 with Condition

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

the class ConditionOpViewBeanBase method createCondition.

protected Condition createCondition() throws ModelControlException, AMConsoleException {
    Condition condition = null;
    String conditionType = (String) getPageSessionAttribute(PG_SESSION_CONDITION_TYPE);
    String conditionName = getConditionName();
    Map values = getValues(conditionType);
    if (conditionName != null) {
        if (values != null) {
            condition = createCondition(conditionType, values);
        }
    }
    return condition;
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with Condition

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

the class ConditionAddViewBean method handleButton2Request.

/**
     * Handles create policy's condition request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    try {
        Condition condition = createCondition();
        if (condition != null) {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String name = (String) propertySheetModel.getValue(CONDITION_NAME);
            policy.addCondition(name, condition);
            backTrail();
            forwardToPolicyViewBean();
        } else {
            forwardTo();
        }
    } 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) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        forwardTo();
    }
}
Also used : Condition(com.sun.identity.policy.interfaces.Condition) 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) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 14 with Condition

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

the class ConditionEditViewBean method getDefaultValues.

protected Map getDefaultValues() {
    Map values = null;
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String conditionName = (String) getPageSessionAttribute(ConditionOpViewBeanBase.PG_SESSION_CONDITION_NAME);
        Condition condition = policy.getCondition(conditionName);
        values = condition.getProperties();
    } catch (NameNotFoundException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    }
    return values;
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Condition(com.sun.identity.policy.interfaces.Condition) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 15 with Condition

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

the class PolicyOpViewBeanBase method handleTblConditionsEditLinkRequest.

public void handleTblConditionsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_CONDITIONS_ACTION_HREF));
    setPageSessionAttribute(ConditionEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ConditionEditViewBean.EDIT_CONDITION_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Condition condition = policy.getCondition(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String conditionType = model.getConditionTypeName(realmName, condition);
        String viewBeanURL = model.getConditionViewBeanURL(realmName, conditionType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToConditionURL(viewBeanURL, name, conditionType, realmName, "edit");
        } else {
            forwardToConditionEditViewBean(model, realmName, name, conditionType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        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) Condition(com.sun.identity.policy.interfaces.Condition) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

Condition (com.sun.identity.policy.interfaces.Condition)27 Policy (com.sun.identity.policy.Policy)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)8 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)8 PolicyException (com.sun.identity.policy.PolicyException)8 HashMap (java.util.HashMap)8 Set (java.util.Set)8 HashSet (java.util.HashSet)7 Map (java.util.Map)7 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)6 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)6 OrCondition (com.sun.identity.entitlement.OrCondition)6 PrivilegeCondition (com.sun.identity.policy.plugins.PrivilegeCondition)6 ConditionTypeManager (com.sun.identity.policy.ConditionTypeManager)5 PolicyManager (com.sun.identity.policy.PolicyManager)5 SSOException (com.iplanet.sso.SSOException)4 Iterator (java.util.Iterator)4 AndCondition (com.sun.identity.entitlement.AndCondition)3 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 EntitlementException (com.sun.identity.entitlement.EntitlementException)2