use of com.sun.identity.policy.ServiceType 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.ServiceType in project OpenAM by OpenRock.
the class PolicyModelImpl method getSvcTypeNameToActionsMap.
private Map getSvcTypeNameToActionsMap(Policy policy, String realmName) {
if (mapSvcTypeNameToActions == null) {
try {
Set serviceTypeNames = getServiceTypeNames().keySet();
int sz = serviceTypeNames.size();
mapSvcTypeNameToActions = new HashMap(sz * 2);
mapSvcTypeNameToResBundle = new HashMap(sz * 2);
ServiceTypeManager mgr = getServiceTypeManager();
for (Iterator i = serviceTypeNames.iterator(); i.hasNext(); ) {
String serviceTypeName = (String) i.next();
ServiceType serviceType = mgr.getServiceType(serviceTypeName);
if (serviceType != null) {
ResourceBundle rb = getResourceBundle(serviceType, getUserLocale());
if (rb != null) {
mapSvcTypeNameToResBundle.put(serviceTypeName, rb);
Set as = getActionSchemas(serviceType);
filterActionSchemaWithI18nKey(as);
if ((as != null) && !as.isEmpty()) {
mapSvcTypeNameToActions.put(serviceTypeName, as);
if (requiresResourceName(policy, realmName, serviceTypeName, as, true)) {
requiredResourceNameService.add(serviceTypeName);
}
if (requiresResourceName(policy, realmName, serviceTypeName, as, false)) {
notRequiredResourceNameService.add(serviceTypeName);
}
}
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (SSOException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
}
}
return mapSvcTypeNameToActions;
}
use of com.sun.identity.policy.ServiceType 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;
}
Aggregations