Search in sources :

Example 6 with ResponseProvider

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;
}
Also used : ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider)

Example 7 with ResponseProvider

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());
}
Also used : ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider)

Example 8 with ResponseProvider

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;
}
Also used : Policy(com.sun.identity.policy.Policy) EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) OrCondition(com.sun.identity.entitlement.OrCondition) AndCondition(com.sun.identity.entitlement.AndCondition) PrivilegeCondition(com.sun.identity.policy.plugins.PrivilegeCondition) Condition(com.sun.identity.policy.interfaces.Condition) EntitlementCondition(com.sun.identity.entitlement.EntitlementCondition) EntitlementCondition(com.sun.identity.entitlement.EntitlementCondition) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) Rule(com.sun.identity.policy.Rule) Entitlement(com.sun.identity.entitlement.Entitlement) EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) PrivilegeSubject(com.sun.identity.policy.plugins.PrivilegeSubject) Subject(com.sun.identity.policy.interfaces.Subject) OrSubject(com.sun.identity.entitlement.OrSubject)

Example 9 with ResponseProvider

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;
}
Also used : IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) ResourceAttribute(com.sun.identity.entitlement.ResourceAttribute) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) HashSet(java.util.HashSet)

Example 10 with ResponseProvider

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;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ResponseProviderTypeManager(com.sun.identity.policy.ResponseProviderTypeManager)

Aggregations

ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)19 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)7 Policy (com.sun.identity.policy.Policy)6 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)5 PolicyException (com.sun.identity.policy.PolicyException)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 IDRepoResponseProvider (com.sun.identity.policy.plugins.IDRepoResponseProvider)4 Map (java.util.Map)4 SSOException (com.iplanet.sso.SSOException)3 PolicyManager (com.sun.identity.policy.PolicyManager)3 ResponseProviderTypeManager (com.sun.identity.policy.ResponseProviderTypeManager)3 HashMap (java.util.HashMap)3 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 EntitlementException (com.sun.identity.entitlement.EntitlementException)2 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)2 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 SSOToken (com.iplanet.sso.SSOToken)1