Search in sources :

Example 1 with ActionSchema

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

the class PolicyModelImpl method getActionSchemas.

/**
     * Returns action schemas of service type.
     * name.
     *
     * @param policy Policy object.
     * @param realmName Realm Name.
     * @param name Name of Service Type.
     * @param withResourceName <code>true</code> for action names for resource
     *        name.
     * @return action schemas of service type.
     */
public Set getActionSchemas(Policy policy, String realmName, String name, boolean withResourceName) {
    Set actions = null;
    Map map = getSvcTypeNameToActionsMap(policy, realmName);
    Set actionSchemas = (Set) map.get(name);
    if ((actionSchemas != null) && !actionSchemas.isEmpty()) {
        actions = new HashSet(actionSchemas.size() * 2);
        for (Iterator iter = actionSchemas.iterator(); iter.hasNext(); ) {
            ActionSchema as = (ActionSchema) iter.next();
            if (withResourceName) {
                if (as.requiresResourceName()) {
                    actions.add(as);
                }
            } else if (!as.requiresResourceName()) {
                actions.add(as);
            }
        }
    }
    return (actions != null) ? actions : Collections.EMPTY_SET;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) ActionSchema(com.sun.identity.policy.ActionSchema) HashSet(java.util.HashSet)

Example 2 with ActionSchema

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

the class PolicyModelImpl method filterActionSchemaWithI18nKey.

private void filterActionSchemaWithI18nKey(Set actionSchemas) {
    if ((actionSchemas != null) && !actionSchemas.isEmpty()) {
        for (Iterator iter = actionSchemas.iterator(); iter.hasNext(); ) {
            ActionSchema as = (ActionSchema) iter.next();
            String i18nKey = as.getI18NKey();
            if ((i18nKey == null) || (i18nKey.trim().length() == 0)) {
                iter.remove();
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) ActionSchema(com.sun.identity.policy.ActionSchema)

Example 3 with ActionSchema

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

the class PolicyModelImpl method requiresResourceName.

private boolean requiresResourceName(Policy policy, String realmName, String serviceTypeName, Set actionSchemas, boolean required) {
    if ((realmName == null) || (realmName.trim().length() == 0)) {
        realmName = getStartDN();
    }
    boolean yes = false;
    for (Iterator iter = actionSchemas.iterator(); iter.hasNext() && !yes; ) {
        ActionSchema as = (ActionSchema) iter.next();
        yes = (as.requiresResourceName() == required);
    }
    if (required) {
        if (yes) {
            yes = canCreateNewResource(realmName, serviceTypeName) || !getManagedResources(realmName, serviceTypeName).isEmpty();
        }
    } else {
        if (yes) {
            Set ruleWithoutRes = getRuleNamesWithoutRes(policy, serviceTypeName);
            /* cannot have more than one rule for service without resource
                   name */
            if (ruleWithoutRes.isEmpty()) {
                yes = realmName.equals("/") || !getManagedResources(realmName, serviceTypeName).isEmpty();
            } else {
                yes = false;
            }
        }
    }
    return yes;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) ActionSchema(com.sun.identity.policy.ActionSchema)

Example 4 with ActionSchema

use of com.sun.identity.policy.ActionSchema 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)

Example 5 with ActionSchema

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

the class RuleOpViewBeanBase method mapActionSchemaNameToActionSchema.

private Map mapActionSchemaNameToActionSchema(Set actionSchemas) {
    Map map = new HashMap(actionSchemas.size() * 2);
    for (Iterator iter = actionSchemas.iterator(); iter.hasNext(); ) {
        ActionSchema as = (ActionSchema) iter.next();
        map.put(as.getName(), as);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) ActionSchema(com.sun.identity.policy.ActionSchema)

Aggregations

ActionSchema (com.sun.identity.policy.ActionSchema)10 Set (java.util.Set)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)5 Map (java.util.Map)5 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 InvalidNameException (com.sun.identity.policy.InvalidNameException)2 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)2 ServiceType (com.sun.identity.policy.ServiceType)2 CCActionTable (com.sun.web.ui.view.table.CCActionTable)2 ArrayList (java.util.ArrayList)2 OptionList (com.iplanet.jato.view.html.OptionList)1 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 CCSelectableList (com.sun.web.ui.view.html.CCSelectableList)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1