use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviders method getResponseProviderDecision.
/**
* Returns response decision evalutating this object
* The effective result is union of all attributes defined in all
* <code>ResponseProvider</code> objects contained in this object
*
* @param token single sign on token of the user
* @param env a map of key/value pairs containing any information
* that could be used by each contraint to evaluate
* the allow/deny result
* @return <code>Map</code> of attribute value pairs.
*
* @throws PolicyException if an error occured
* @throws SSOException if the token is invalid
*/
Map getResponseProviderDecision(SSOToken token, Map env) throws PolicyException, SSOException {
HashMap attrsMap = new HashMap();
Iterator items = providers.entrySet().iterator();
while (items.hasNext()) {
ResponseProvider responseProvider = (ResponseProvider) ((Map.Entry) items.next()).getValue();
Map respProviderMap = responseProvider.getResponseDecision(token, env);
PolicyUtils.appendMapToMap(respProviderMap, attrsMap);
}
return attrsMap;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviders method toXML.
protected String toXML() {
StringBuilder sb = new StringBuilder(100);
sb.append("\n").append(RESPONSE_PROVIDERS_ELEMENT_BEGIN).append(XMLUtils.escapeSpecialCharacters(name)).append(RESPONSE_PROVIDERS_DESCRIPTION).append(XMLUtils.escapeSpecialCharacters(description)).append("\">");
Iterator items = providers.keySet().iterator();
while (items.hasNext()) {
String responseProviderName = (String) items.next();
ResponseProvider responseProvider = (ResponseProvider) providers.get(responseProviderName);
sb.append("\n").append(RESPONSE_PROVIDER_ELEMENT).append(XMLUtils.escapeSpecialCharacters(responseProviderName)).append(RESPONSE_PROVIDER_TYPE).append(XMLUtils.escapeSpecialCharacters(ResponseProviderTypeManager.responseProviderTypeName(responseProvider))).append("\">\n");
// Add attribute values pairs
Map properties = responseProvider.getProperties();
if (properties != null) {
sb.append(PolicyUtils.mapToXMLString(properties));
}
sb.append(RESPONSE_PROVIDER_ELEMENT_END);
}
sb.append("\n").append(RESPONSE_PROVIDERS_ELEMENT_END);
return (sb.toString());
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PrivilegeUtils method privilegeToPolicy.
public static Policy privilegeToPolicy(String realm, Privilege privilege) throws PolicyException, SSOException, EntitlementException {
Policy policy = new Policy(privilege.getName());
policy.setDescription(privilege.getDescription());
if (privilege.getEntitlement() != null) {
Entitlement entitlement = privilege.getEntitlement();
Set<Rule> rules = entitlementToRule(realm, entitlement);
for (Rule rule : rules) {
policy.addRule(rule);
}
}
EntitlementSubject es = privilege.getSubject();
if ((es != null) && (es != Privilege.NOT_SUBJECT)) {
Subject sbj = eSubjectToEPSubject(es);
policy.addSubject(getSubjectName(es), sbj, false);
}
EntitlementCondition ec = privilege.getCondition();
if (ec != null) {
Condition cond = eConditionToEPCondition(ec);
policy.addCondition(getConditionName(ec), cond);
}
if (privilege.getResourceAttributes() != null) {
Map<String, ResponseProvider> nrps = resourceAttributesToResponseProviders(privilege.getResourceAttributes());
for (String rpName : nrps.keySet()) {
ResponseProvider responseProvider = nrps.get(rpName);
policy.addResponseProvider(rpName, responseProvider);
}
}
policy.setCreatedBy(privilege.getCreatedBy());
policy.setCreationDate(privilege.getCreationDate());
policy.setLastModifiedBy(privilege.getLastModifiedBy());
policy.setLastModifiedDate(privilege.getLastModifiedDate());
return policy;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PrivilegeUtils method nrpsToResourceAttributes.
private static Set<ResourceAttribute> nrpsToResourceAttributes(Set nrps) throws EntitlementException {
Set<ResourceAttribute> resourceAttributesSet = new HashSet<ResourceAttribute>();
if (nrps != null && !nrps.isEmpty()) {
for (Object nrpObj : nrps) {
Object[] nrpa = (Object[]) nrpObj;
String nrpName = (String) nrpa[0];
ResponseProvider rp = (ResponseProvider) nrpa[1];
if (rp instanceof IDRepoResponseProvider) {
resourceAttributesSet.addAll(nrpsToResourceAttributes((IDRepoResponseProvider) rp, nrpName));
} else if (rp instanceof ResponseProvider) {
resourceAttributesSet.addAll(mapGenericResponseProvider(nrpName, rp));
}
}
}
return resourceAttributesSet;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class PolicyModelImpl method getResponseProviderInstance.
private ResponseProvider getResponseProviderInstance(String realmName, String typeName) {
ResponseProvider provider = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
provider = mgr.getResponseProvider(typeName);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
}
return provider;
}
Aggregations