Search in sources :

Example 6 with ResourceSaveIndexes

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

the class OpenSSOIndexStore method delete.

/**
     * Deletes a privilege from data store.
     *
     * @param privileges Privileges to be deleted.
     * @throws EntitlementException if deletion
     * failed.
     */
public void delete(Set<IPrivilege> privileges) throws EntitlementException {
    Subject adminSubject = getAdminSubject();
    String realm = getRealm();
    for (IPrivilege p : privileges) {
        String dn = null;
        if (p instanceof Privilege) {
            dn = delete(p.getName(), true);
        } else {
            dn = deleteReferral(p.getName(), true);
        }
        if (indexCacheSize > 0) {
            ResourceSaveIndexes sIndex = p.getResourceSaveIndexes(adminSubject, DNMapper.orgNameToRealmName(realm));
            if (sIndex != null) {
                if (p instanceof Privilege) {
                    indexCache.clear(sIndex, dn);
                } else {
                    referralIndexCache.clear(sIndex, dn);
                }
            }
        }
    }
}
Also used : ResourceSaveIndexes(com.sun.identity.entitlement.ResourceSaveIndexes) IPrivilege(com.sun.identity.entitlement.IPrivilege) IPrivilege(com.sun.identity.entitlement.IPrivilege) Privilege(com.sun.identity.entitlement.Privilege) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) Subject(javax.security.auth.Subject)

Example 7 with ResourceSaveIndexes

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

the class TreeSaveIndexTest method simpleScenario.

@Test
public void simpleScenario() {
    ResourceSaveIndexes result = saveIndex.getIndexes("http://www.test.com/*");
    Set<String> expectedResults = new HashSet<String>();
    expectedResults.add("http://www.test.com/*");
    assertEquals(Arrays.asList("://www.test.com"), result.getHostIndexes());
    assertEquals(expectedResults, result.getPathIndexes());
    assertEquals(Arrays.asList("/"), result.getParentPathIndexes());
}
Also used : ResourceSaveIndexes(com.sun.identity.entitlement.ResourceSaveIndexes) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 8 with ResourceSaveIndexes

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

the class TreeSaveIndexTest method enforceLowerCase.

@Test
public void enforceLowerCase() {
    ResourceSaveIndexes result = saveIndex.getIndexes("HtTp://wWw.tESt.CoM/*");
    Set<String> expectedResults = new HashSet<String>();
    expectedResults.add("http://www.test.com/*");
    assertEquals(Arrays.asList("://www.test.com"), result.getHostIndexes());
    assertEquals(expectedResults, result.getPathIndexes());
    assertEquals(Arrays.asList("/"), result.getParentPathIndexes());
}
Also used : ResourceSaveIndexes(com.sun.identity.entitlement.ResourceSaveIndexes) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 9 with ResourceSaveIndexes

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

the class ResourceNameIndexTest method testPath.

@Test
public void testPath() throws Exception {
    ResourceNameIndexGenerator gen = new ResourceNameIndexGenerator();
    Map<String, String> map = parseResource("resourceNameIndexURI");
    for (String k : map.keySet()) {
        String expectedResult = map.get(k);
        ResourceSaveIndexes indexes = gen.getIndexes(k);
        String path = indexes.getPathIndexes().iterator().next();
        if (!path.equals(expectedResult)) {
            String msg = "ResourceNameIndexTest.testPath: " + k + " failed.";
            UnittestLog.logError(msg);
            throw new Exception(msg);
        }
    }
}
Also used : ResourceSaveIndexes(com.sun.identity.entitlement.ResourceSaveIndexes) Test(org.testng.annotations.Test)

Example 10 with ResourceSaveIndexes

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

the class ResourceNameIndexTest method testHost.

@Test
public void testHost() throws Exception {
    ResourceNameIndexGenerator gen = new ResourceNameIndexGenerator();
    Map<String, String> map = parseResource("resourceNameIndexHost");
    for (String k : map.keySet()) {
        String expectedResult = map.get(k);
        ResourceSaveIndexes indexes = gen.getIndexes(k);
        String host = indexes.getHostIndexes().iterator().next();
        if (!host.equals(expectedResult)) {
            String msg = "ResourceNameIndexTest.testHost: " + k + " failed.";
            UnittestLog.logError(msg);
            throw new Exception(msg);
        }
    }
}
Also used : ResourceSaveIndexes(com.sun.identity.entitlement.ResourceSaveIndexes) Test(org.testng.annotations.Test)

Aggregations

ResourceSaveIndexes (com.sun.identity.entitlement.ResourceSaveIndexes)11 HashSet (java.util.HashSet)8 Test (org.testng.annotations.Test)6 Set (java.util.Set)4 SSOException (com.iplanet.sso.SSOException)2 EntitlementException (com.sun.identity.entitlement.EntitlementException)2 SMSEntry (com.sun.identity.sm.SMSEntry)2 SMSException (com.sun.identity.sm.SMSException)2 Collections.emptySet (java.util.Collections.emptySet)2 HashMap (java.util.HashMap)2 SSOToken (com.iplanet.sso.SSOToken)1 Entitlement (com.sun.identity.entitlement.Entitlement)1 IPrivilege (com.sun.identity.entitlement.IPrivilege)1 Privilege (com.sun.identity.entitlement.Privilege)1 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)1 MalformedURLException (java.net.MalformedURLException)1 Subject (javax.security.auth.Subject)1 JSONException (org.json.JSONException)1