use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PrivilegeUtils method resourceAttributesToResponseProviders.
private static Map<String, ResponseProvider> resourceAttributesToResponseProviders(Set<ResourceAttribute> resourceAttributes) throws PolicyException, EntitlementException {
Map<String, ResponseProvider> results = new HashMap<String, ResponseProvider>();
if (resourceAttributes != null) {
Map<String, Map<String, Set<String>>> map = new HashMap<String, Map<String, Set<String>>>();
for (ResourceAttribute ra : resourceAttributes) {
if (ra instanceof StaticAttributes) {
resourceAttributesToResponseProviders((StaticAttributes) ra, map);
} else if (ra instanceof UserAttributes) {
resourceAttributesToResponseProviders((UserAttributes) ra, map);
}
}
for (String n : map.keySet()) {
ResponseProvider rp = new IDRepoResponseProvider();
Map<String, Set<String>> values = map.get(n);
Set<String> dynValues = values.get(IDRepoResponseProvider.DYNAMIC_ATTRIBUTE);
if ((dynValues != null) && !dynValues.isEmpty()) {
Map<String, Set<String>> configParams = new HashMap<String, Set<String>>();
configParams.put(PolicyConfig.SELECTED_DYNAMIC_ATTRIBUTES, dynValues);
rp.initialize(configParams);
}
rp.setProperties(values);
results.put(n, rp);
}
// Copy any legacy response providers over directly
for (ResourceAttribute ra : resourceAttributes) {
if (ra instanceof PolicyResponseProvider) {
PolicyResponseProvider prp = (PolicyResponseProvider) ra;
results.put(prp.getPResponseProviderName(), prp.getResponseProvider());
}
}
}
return results;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PolicyResponseProvider method getResponseProvider.
/**
* Constructs a legacy response provider based on the information in this adapter.
*
* @return the legacy response provider
* @throws EntitlementException if an error occurs constructing the response provider.
*/
@JsonIgnore
public ResponseProvider getResponseProvider() throws EntitlementException {
try {
ResponseProvider rp = Class.forName(className).asSubclass(ResponseProvider.class).newInstance();
Map<String, Set<String>> properties = new HashMap<String, Set<String>>();
properties.put(propertyName, propertyValues);
rp.setProperties(properties);
return rp;
} catch (Exception ex) {
throw new EntitlementException(510, ex);
}
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PolicyResponseProvider method evaluate.
/**
* Called by the entitlements framework to fetch its resource attributes;
* cascades the call through to the configured response provider implementation
*
* @param adminSubject The admin user executing the policy eval
* @param realm The realm of the policy eval
* @param subject The user who is subject to the policy eval
* @param resourceName The resource name of the policy eval
* @param environment environment map from the policy eval client
* @return The attributes (only one since resource attributes are singled)
* @throws EntitlementException
*/
public Map<String, Set<String>> evaluate(Subject adminSubject, String realm, Subject subject, String resourceName, Map<String, Set<String>> environment) throws EntitlementException {
try {
ResponseProvider rp = getResponseProvider();
SSOToken token = (subject != null) ? getSSOToken(subject) : null;
Map<String, Set<String>> result = rp.getResponseDecision(token, environment);
return result;
} catch (SSOException ex) {
throw new EntitlementException(510, ex);
} catch (PolicyException ex) {
throw new EntitlementException(510, ex);
}
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PolicyModelImpl method getResponseProviderViewBeanURL.
/**
* Returns properties view bean URL of a response provider.
*
* @param realmName Name of realm.
* @param typeName Name of response provider Type.
* @return properties view bean URL of a response provider.
*/
public String getResponseProviderViewBeanURL(String realmName, String typeName) {
String url = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
ResponseProvider provider = mgr.getResponseProvider(typeName);
url = mgr.getViewBeanURL(provider);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getResponseProviderViewBeanURL", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getResponseProviderViewBeanURL", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getResponseProviderViewBeanURL", e);
}
return url;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PolicyModelImpl method createResponseProvider.
/**
* Returns a response provider object.
*
* @param realmName Name of Realm.
* @param providerType Name of response provider type.
* @param values Values of the response provider.
* @return response provider object.
* @throws AMConsoleException if response provider cannot be created.
*/
public ResponseProvider createResponseProvider(String realmName, String providerType, Map values) throws AMConsoleException {
ResponseProvider provider = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
provider = mgr.getResponseProvider(providerType);
provider.setProperties(values);
}
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
}
return provider;
}
Aggregations