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;
}
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();
}
}
}
}
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;
}
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;
}
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;
}
Aggregations