use of java.security.PermissionCollection in project scout.rt by eclipse.
the class SharedAccessControlServiceTest method testClearCache.
/**
* Test method for
* {@link org.eclipse.scout.rt.shared.services.common.security.AbstractAccessControlService#clearCache()}.
*/
@Test
public void testClearCache() throws ProcessingException {
PermissionCollection p1 = m_accessControlService.getPermissions();
PermissionCollection p2 = m_accessControlService.getPermissions();
assertSame(p1, p2);
m_accessControlService.clearCache();
PermissionCollection p3 = m_accessControlService.getPermissions();
assertNotSame(p1, p3);
}
use of java.security.PermissionCollection in project scout.rt by eclipse.
the class SharedAccessControlServiceTest method testGetPermissions.
/**
* Test method for
* {@link org.eclipse.scout.rt.shared.services.common.security.AbstractAccessControlService#getPermissions()}.
*/
@Test
public void testGetPermissions() {
PermissionCollection permissions = m_accessControlService.getPermissions();
assertNotNull(permissions);
}
use of java.security.PermissionCollection in project scout.rt by eclipse.
the class SharedAccessControlServiceTest method testClearCacheOfUserIds.
/**
* Test method for
* {@link org.eclipse.scout.rt.shared.services.common.security.AbstractAccessControlService#clearCacheOfUserIds(java.util.Collection)}
* .
*/
@Test
public void testClearCacheOfUserIds() throws ProcessingException {
PermissionCollection p1 = m_accessControlService.getPermissions();
PermissionCollection p2 = m_accessControlService.getPermissions();
assertSame(p1, p2);
m_accessControlService.clearCache(Collections.<String>emptyList());
PermissionCollection p3 = m_accessControlService.getPermissions();
assertSame(p1, p3);
m_accessControlService.clearCache(Collections.<String>singletonList(null));
PermissionCollection p4 = m_accessControlService.getPermissions();
assertSame(p1, p4);
m_accessControlService.clearCache(Collections.singletonList(TEST_USER));
PermissionCollection p5 = m_accessControlService.getPermissions();
PermissionCollection p6 = m_accessControlService.getPermissions();
assertNotSame(p1, p5);
assertNotSame(p1, p6);
assertSame(p5, p6);
}
use of java.security.PermissionCollection in project tomcat by apache.
the class WebappClassLoaderBase method getPermissions.
/**
* Get the Permissions for a CodeSource. If this instance
* of WebappClassLoaderBase is for a web application context,
* add read FilePermission for the appropriate resources.
*
* @param codeSource where the code was loaded from
* @return PermissionCollection for CodeSource
*/
@Override
protected PermissionCollection getPermissions(CodeSource codeSource) {
String codeUrl = codeSource.getLocation().toString();
PermissionCollection pc;
if ((pc = loaderPC.get(codeUrl)) == null) {
pc = super.getPermissions(codeSource);
if (pc != null) {
for (Permission p : permissionList) {
pc.add(p);
}
loaderPC.put(codeUrl, pc);
}
}
return pc;
}
use of java.security.PermissionCollection in project tomcat by apache.
the class WebappClassLoaderBase method check.
@Override
public boolean check(Permission permission) {
if (!Globals.IS_SECURITY_ENABLED) {
return true;
}
Policy currentPolicy = Policy.getPolicy();
if (currentPolicy != null) {
URL contextRootUrl = resources.getResource("/").getCodeBase();
CodeSource cs = new CodeSource(contextRootUrl, (Certificate[]) null);
PermissionCollection pc = currentPolicy.getPermissions(cs);
if (pc.implies(permission)) {
return true;
}
}
return false;
}
Aggregations