Search in sources :

Example 11 with ResourceName

use of com.sun.identity.entitlement.interfaces.ResourceName in project OpenAM by OpenRock.

the class OpenSSOApplicationPrivilegeManager method isDelegatableResource.

private boolean isDelegatableResource(Application appl, String res) {
    Set<String> resources = getDelegatableResourceNames(appl.getName());
    if ((resources != null) && !resources.isEmpty()) {
        ResourceName resComp = appl.getResourceComparator();
        boolean isRegEx = (resComp instanceof RegExResourceName);
        for (String r : resources) {
            if (!r.endsWith("*")) {
                if (!r.endsWith("/")) {
                    r += "/";
                }
                r += "*";
            }
            if (isRegEx) {
                ResourceMatch result = resComp.compare(res, r, true);
                if (result.equals(ResourceMatch.EXACT_MATCH) || result.equals(ResourceMatch.SUB_RESOURCE_MATCH) || result.equals(ResourceMatch.WILDCARD_MATCH)) {
                    return true;
                }
            } else {
                ResourceMatch result = resComp.compare(r, res, false);
                if (result.equals(ResourceMatch.EXACT_MATCH) || result.equals(ResourceMatch.SUB_RESOURCE_MATCH)) {
                    return true;
                }
                result = resComp.compare(res, r, true);
                if (result.equals(ResourceMatch.EXACT_MATCH) || result.equals(ResourceMatch.SUB_RESOURCE_MATCH) || result.equals(ResourceMatch.WILDCARD_MATCH)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ResourceName(com.sun.identity.entitlement.interfaces.ResourceName) RegExResourceName(com.sun.identity.entitlement.RegExResourceName) ResourceMatch(com.sun.identity.entitlement.ResourceMatch) RegExResourceName(com.sun.identity.entitlement.RegExResourceName)

Aggregations

ResourceName (com.sun.identity.entitlement.interfaces.ResourceName)11 HashSet (java.util.HashSet)7 Set (java.util.Set)3 ISaveIndex (com.sun.identity.entitlement.interfaces.ISaveIndex)2 ISearchIndex (com.sun.identity.entitlement.interfaces.ISearchIndex)2 HashMap (java.util.HashMap)2 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 CLIException (com.sun.identity.cli.CLIException)1 RegExResourceName (com.sun.identity.entitlement.RegExResourceName)1 ResourceMatch (com.sun.identity.entitlement.ResourceMatch)1 Subject (javax.security.auth.Subject)1