Search in sources :

Example 11 with InvalidNameException

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

the class DSAMERole method setValues.

/**
     * Sets the names for the instance of the <code>Subject</code>
     * object. The names are obtained from the policy object,
     * usually configured when a policy is created.
     *
     * @param names names selected for the instance of
     * the user collection object.
     *
     * @exception InvalidNameException if the given names are not valid
     */
public void setValues(Set names) throws InvalidNameException {
    if (names == null) {
        throw (new InvalidNameException(ResBundleUtils.rbName, "role_subject_invalid_role_names", null, null, PolicyException.USER_COLLECTION));
    }
    if (names.isEmpty()) {
        subjectRoles = names;
    } else {
        subjectRoles = new HashSet();
        Iterator iter = names.iterator();
        while (iter.hasNext()) {
            String role = (String) iter.next();
            if (role != null) {
                subjectRoles.add(DN.valueOf(role).toString().toLowerCase());
            }
        }
    }
    if (debug.messageEnabled()) {
        debug.message("Set subjectRoles to: " + subjectRoles);
    }
}
Also used : InvalidNameException(com.sun.identity.policy.InvalidNameException) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 12 with InvalidNameException

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

the class PolicyModelImpl method cachePolicy.

/**
     * Caches a policy. Returns the cache ID of the policy object.
     *
     * @param policyName Name of policy.
     * @param description Description of policy.
     * @param isReferral <code>true</code> if policy is referral typed.
     * @param isActive <code>true</code> if policy is active.
     * @return cache ID of the policy object.
     * @throws AMConsoleException if policy cannot be cached.
     */
public String cachePolicy(String policyName, String description, boolean isReferral, boolean isActive) throws AMConsoleException {
    try {
        Policy policy = new Policy(policyName, description, isReferral, isActive);
        PolicyCache cache = PolicyCache.getInstance();
        return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
    } catch (InvalidNameException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Policy(com.sun.identity.policy.Policy) InvalidNameException(com.sun.identity.policy.InvalidNameException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 13 with InvalidNameException

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

the class PolicyModelImpl method cachePolicy.

/**
     * Caches an existing policy. Returns the cache ID of the policy object.
     *
     * @param realmName Name of realm.
     * @param policyName Name of policy.
     * @return cache ID of the policy object.
     * @throws AMConsoleException if policy cannot be cached.
     */
public String cachePolicy(String realmName, String policyName) throws AMConsoleException {
    try {
        PolicyManager policyManager = getPolicyManager(realmName);
        Policy policy = policyManager.getPolicy(policyName);
        PolicyCache cache = PolicyCache.getInstance();
        return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
    } catch (InvalidFormatException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (InvalidNameException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (NoPermissionException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) NoPermissionException(com.sun.identity.policy.NoPermissionException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) InvalidFormatException(com.sun.identity.policy.InvalidFormatException)

Example 14 with InvalidNameException

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

the class SubjectAddViewBean method handleButton2Request.

/**
     * Handles create policy's subject request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    boolean forwarded = false;
    submitCycle = true;
    bFilter = true;
    try {
        Subject subject = createSubject();
        if (subject != null) {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
            policy.addSubject(name, subject, isExclusive());
            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) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 15 with InvalidNameException

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

the class PrivilegeUtils method pravToPav.

static Map pravToPav(Map<String, Boolean> actionValues, String serviceName) throws PolicyException, SSOException {
    if (actionValues == null) {
        return null;
    }
    ServiceType serviceType = null;
    try {
        serviceType = svcTypeManager.getServiceType(serviceName);
    } catch (NameNotFoundException e) {
    //ignore
    }
    Map av = new HashMap();
    Set<String> keySet = actionValues.keySet();
    for (String action : keySet) {
        try {
            Set values = new HashSet();
            Boolean value = actionValues.get(action);
            if (serviceType != null) {
                ActionSchema as = serviceType.getActionSchema(action);
                String trueValue = as.getTrueValue();
                String falseValue = as.getFalseValue();
                if (value.equals(Boolean.TRUE)) {
                    values.add(trueValue);
                } else {
                    values.add(falseValue);
                }
            } else {
                values.add(value.toString());
            }
            av.put(action, values);
        } catch (InvalidNameException e) {
            Boolean value = actionValues.get(action);
            Set values = new HashSet();
            values.add(value.toString());
            av.put(action, values);
        }
    }
    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) HashSet(java.util.HashSet)

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