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);
}
}
}
}
}
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());
}
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());
}
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);
}
}
}
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);
}
}
}
Aggregations