Search in sources :

Example 1 with InvalidNameException

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

the class ReferralAddViewBean method handleButton2Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    boolean forwarded = false;
    submitCycle = true;
    try {
        Referral referral = createReferral();
        if (referral != null) {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String name = (String) propertySheetModel.getValue(REFERRAL_NAME);
            policy.addReferral(name, referral);
            backTrail();
            forwardToPolicyViewBean();
            forwarded = 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) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        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) Referral(com.sun.identity.policy.interfaces.Referral) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 2 with InvalidNameException

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

the class SubjectEditViewBean method handleButton1Request.

private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
    submitCycle = true;
    Subject deleted = null;
    String origName = (String) getPageSessionAttribute(EDIT_SUBJECT_NAME);
    Policy policy = cachedPolicy.getPolicy();
    try {
        Subject subject = createSubject();
        if (subject != null) {
            String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
            if (origName.equals(name)) {
                policy.replaceSubject(name, subject, isExclusive());
            } else {
                deleted = policy.removeSubject(origName);
                policy.addSubject(name, subject, isExclusive());
            }
            deleted = null;
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.subject.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 (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        if (deleted != null) {
            try {
                policy.addSubject(origName, deleted);
            } catch (NameAlreadyExistsException e) {
                debug.warning("SubjectEditViewBean.handleButton1Request", e);
            } catch (InvalidNameException e) {
                debug.warning("SubjectEditViewBean.handleButton1Request", e);
            }
        }
    }
    forwardTo();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 3 with InvalidNameException

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

the class PolicyOpViewBeanBase method reconstructPolicyGeneral.

private boolean reconstructPolicyGeneral(PolicyModel model) throws AMConsoleException {
    boolean bError = false;
    String policyName = (String) propertySheetModel.getValue(PolicyModel.TF_NAME);
    policyName = policyName.trim();
    String description = (String) propertySheetModel.getValue(ATTR_DESCRIPTION);
    description = description.trim();
    String isActive = (String) propertySheetModel.getValue(ATTR_ISACTIVE);
    boolean active = (isActive != null) && isActive.equals("true");
    if (policyName.length() == 0) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "policy.missing.policyName");
        bError = true;
        return bError;
    }
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    try {
        policy.setDescription(description);
        policy.setActive(active);
        policy.setName(policyName);
    } catch (InvalidNameException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        bError = true;
    }
    return bError;
}
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)

Example 4 with InvalidNameException

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

the class ConditionEditViewBean method handleButton1Request.

private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
    submitCycle = true;
    boolean forwarded = false;
    Condition deleted = null;
    String origName = (String) getPageSessionAttribute(EDIT_CONDITION_NAME);
    Policy policy = cachedPolicy.getPolicy();
    try {
        Condition condition = createCondition();
        if (condition != null) {
            String name = (String) propertySheetModel.getValue(CONDITION_NAME);
            if (origName.equals(name)) {
                policy.replaceCondition(name, condition);
            } else {
                deleted = policy.removeCondition(origName);
                policy.addCondition(name, condition);
            }
            deleted = null;
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.condition.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 (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        if (deleted != null) {
            try {
                policy.addCondition(origName, deleted);
            } catch (NameAlreadyExistsException e) {
                debug.warning("ConditionEditViewBean.handleButton1Request", e);
            } catch (InvalidNameException e) {
                debug.warning("ConditionEditViewBean.handleButton1Request", e);
            }
        }
    }
    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) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 5 with InvalidNameException

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

the class PrivilegeUtils method pavToPrav.

static Map<String, Boolean> pavToPrav(Map actionValues, String serviceName) throws PolicyException, SSOException {
    if (actionValues == null) {
        return null;
    }
    ServiceType serviceType = null;
    if (serviceName != null) {
        try {
            serviceType = svcTypeManager.getServiceType(serviceName);
        } catch (NameNotFoundException e) {
        //ignore
        }
    }
    Map av = new HashMap();
    Set keySet = (Set) actionValues.keySet();
    for (Object actionObj : keySet) {
        String action = (String) actionObj;
        Set values = (Set) actionValues.get(action);
        if ((values == null) || values.isEmpty()) {
            av.put(action, Boolean.FALSE);
        } else {
            if (serviceType != null) {
                try {
                    ActionSchema as = serviceType.getActionSchema(action);
                    if (as.getSyntax().equals(AttributeSchema.Syntax.BOOLEAN)) {
                        String trueValue = as.getTrueValue();
                        if (values.contains(trueValue)) {
                            av.put(action, Boolean.TRUE);
                        } else {
                            av.put(action, Boolean.FALSE);
                        }
                    } else {
                        // Append action value to action name
                        String value = values.iterator().next().toString();
                        av.put(action + "_" + value, Boolean.TRUE);
                    }
                } catch (InvalidNameException e) {
                    av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
                }
            } else {
                av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
            }
        }
    }
    return av;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) HashMap(java.util.HashMap) ServiceType(com.sun.identity.policy.ServiceType) HashMap(java.util.HashMap) Map(java.util.Map) ActionSchema(com.sun.identity.policy.ActionSchema)

Aggregations

InvalidNameException (com.sun.identity.policy.InvalidNameException)19 Policy (com.sun.identity.policy.Policy)11 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)9 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)8 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)6 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)3 ByteString (org.forgerock.opendj.ldap.ByteString)3 ActionSchema (com.sun.identity.policy.ActionSchema)2 Rule (com.sun.identity.policy.Rule)2 ServiceType (com.sun.identity.policy.ServiceType)2 Condition (com.sun.identity.policy.interfaces.Condition)2 Referral (com.sun.identity.policy.interfaces.Referral)2 Subject (com.sun.identity.policy.interfaces.Subject)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 SSOException (com.iplanet.sso.SSOException)1 InvalidFormatException (com.sun.identity.policy.InvalidFormatException)1