@Override public String toString() { List<Permission> ps = new ArrayList<Permission>(); for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) { ps.add(e.nextElement()); } return "AdjustablePolicy with permissions " + ps; } }
public String toString() { List<Permission> ps = new ArrayList<>(); for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) ps.add(e.nextElement()); return "AdjustablePolicy with permissions " + ps; } }
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification attachment = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); if (attachment == null) { return; } final List<PermissionFactory> permissions = attachment.getPermissionFactories(); final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements(); while (e.hasMoreElements()) { permissions.add(new ImmediatePermissionFactory(e.nextElement())); } //make sure they can read the contents of the deployment ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); try { File file = root.getRoot().getPhysicalFile(); if(file != null && file.isDirectory()) { FilePermission permission = new FilePermission(file.getAbsolutePath() + File.separatorChar + "-", "read"); permissions.add(new ImmediatePermissionFactory(permission)); } } catch (IOException ex) { throw new DeploymentUnitProcessingException(ex); } }
public Enumeration<Permission> elements() { return perms.elements(); }
/** * @param permissions * @return */ public static int getPermissionsSize(final Permissions permissions) { int size = 0; final Enumeration<Permission> p = permissions.elements(); while (p.hasMoreElements()) { size++; } return size; }
/** * @param permissions * @return */ public static int getPermissionsSize(final Permissions permissions) { int size = 0; final Enumeration<Permission> p = permissions.elements(); while (p.hasMoreElements()) { size++; } return size; }
/** * @param permissions * @return the permissions size */ public static int getPermissionsSize(final Permissions permissions) { int size = 0; final Enumeration<Permission> p = permissions.elements(); while (p.hasMoreElements()) { size++; } return size; }
/** * @param permissions * @return the permissions size */ public static int getPermissionsSize(final Permissions permissions) { int size = 0; final Enumeration<Permission> p = permissions.elements(); while (p.hasMoreElements()) { size++; } return size; }
/** * @param permissions * @return */ public static int getPermissionsSize(final Permissions permissions) { int size = 0; final Enumeration<Permission> p = permissions.elements(); while (p.hasMoreElements()) { size++; } return size; }
private void checkRequiredPermissions(){ SecurityManager sm = System.getSecurityManager(); if (sm != null) { final Enumeration<Permission> permissionElements = permissions.elements(); while(permissionElements.hasMoreElements()) sm.checkPermission(permissionElements.nextElement()); } }
/** * Check that the current access control context has all of the given permissions. */ private static void checkPermissions(Permissions perms) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { // should never be null? Enumeration en = perms.elements(); while (en.hasMoreElements()) { sm.checkPermission((Permission) en.nextElement()); } } }
/** * */ @Override public Enumeration<Permission> elements() { if (unresolved != 0) { resolve(); } return pc.elements(); }
public Enumeration<Permission> elements() { return getAssembled().elements(); }
public Enumeration<Permission> elements() { return getAssembled().elements(); }
Permissions getPermissions() { Permissions perms = new Permissions(); Enumeration<Permission> eter = uncheckedPermissions.elements(); while( eter.hasMoreElements() ) { Permission p = (Permission) eter.nextElement(); perms.add(p); } Iterator<Permissions> iter = rolePermissions.values().iterator(); while( iter.hasNext() ) { Permissions rp = iter.next(); eter = rp.elements(); while( eter.hasMoreElements() ) { Permission p = eter.nextElement(); perms.add(p); } } return perms; }
Permissions getPermissions() { Permissions perms = new Permissions(); Enumeration<Permission> eter = uncheckedPermissions.elements(); while( eter.hasMoreElements() ) { Permission p = (Permission) eter.nextElement(); perms.add(p); } Iterator<Permissions> iter = rolePermissions.values().iterator(); while( iter.hasNext() ) { Permissions rp = (Permissions) iter.next(); eter = rp.elements(); while( eter.hasMoreElements() ) { Permission p = (Permission) eter.nextElement(); perms.add(p); } } return perms; }
public void commit() throws PolicyContextException { if (state != OPEN) throw new UnsupportedOperationException("Not in an open state"); for (Iterator principalEntries = principalRoleMapping.entrySet().iterator(); principalEntries.hasNext(); ) { Map.Entry principalEntry = (Map.Entry) principalEntries.next(); Principal principal = (Principal) principalEntry.getKey(); Permissions principalPermissions = (Permissions) principalPermissionsMap.get(principal); if (principalPermissions == null) { principalPermissions = new Permissions(); principalPermissionsMap.put(principal, principalPermissions); } HashSet roleSet = (HashSet) principalEntry.getValue(); for (Iterator roles = roleSet.iterator(); roles.hasNext(); ) { Permissions permissions = (Permissions) rolePermissionsMap.get(roles.next()); if (permissions == null) continue; for (Enumeration rolePermissions = permissions.elements(); rolePermissions.hasMoreElements(); ) { principalPermissions.add((Permission) rolePermissions.nextElement()); } } } state = IN_SERVICE; }
private static Permissions createPermissions(List<Permission> permissionsList, List<InjectedValue<Permissions>> permissionSetInjectors) throws StartException { Permissions allPermissions = createPermissions(permissionsList); for (InjectedValue<Permissions> permissionSetInjector : permissionSetInjectors) { Permissions permissionSet = permissionSetInjector.getValue(); Enumeration<java.security.Permission> permissions = permissionSet.elements(); while (permissions.hasMoreElements()) { allPermissions.add(permissions.nextElement()); } } return allPermissions; }
/** * Removes permissions from <code>toBeChecked</code> that are implied by * <code>permission</code>. * * @param toBeChecked the permissions that are to be checked and possibly culled * @param permission the permission that is to be used for culling * @return the culled set of permissions that are not implied by <code>permission</code> */ private Permissions cullPermissions(Permissions toBeChecked, Permission permission) { Permissions result = new Permissions(); for (Enumeration e = toBeChecked.elements(); e.hasMoreElements();) { Permission test = (Permission) e.nextElement(); if (!permission.implies(test)) { result.add(test); } } return result; } }
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification attachment = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); if (attachment == null) { return; } final List<PermissionFactory> permissions = attachment.getPermissionFactories(); final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements(); while (e.hasMoreElements()) { permissions.add(new ImmediatePermissionFactory(e.nextElement())); } //make sure they can read the contents of the deployment ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); try { File file = root.getRoot().getPhysicalFile(); if(file != null && file.isDirectory()) { FilePermission permission = new FilePermission(file.getAbsolutePath() + File.separatorChar + "-", "read"); permissions.add(new ImmediatePermissionFactory(permission)); } } catch (IOException ex) { throw new DeploymentUnitProcessingException(ex); } }