private void handleMethodPermissions(final EJBComponentDescription componentDescription, final MethodPermissionsMetaData methodPermissions) { for (final MethodPermissionMetaData methodPermissionMetaData : methodPermissions) { final MethodsMetaData methods = methodPermissionMetaData.getMethods(); for (final MethodMetaData method : methods) { EJBMethodSecurityAttribute ejbMethodSecurityMetaData; if (methodPermissionMetaData.isNotChecked()) { ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.permitAll(); } else { ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.rolesAllowed(methodPermissionMetaData.getRoles());
/** * Whether this is not checked * * @param methodName the method name * @param params the parameters * @param interfaceType the interface type * @return true when it is not checked and it matches matches */ public boolean isNotChecked(String methodName, Class[] params, MethodInterfaceType interfaceType) { if (isNotChecked() == false) return false; return matches(methodName, params, interfaceType); }
public void process(MethodPermissionsMetaData metaData, T type) { PermitAll permit = finder.getAnnotation(type, PermitAll.class); if(permit == null) return; Method method = null; if(type instanceof Method) method = (Method) type; String ejbName = EjbNameThreadLocal.ejbName.get(); MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method); MethodPermissionMetaData perm = new MethodPermissionMetaData(); MethodsMetaData methods = perm.getMethods(); if(methods == null) { methods = new MethodsMetaData(); perm.setMethods(methods); } perm.setUnchecked(new EmptyMetaData()); Descriptions descriptions = ProcessorUtils.getDescription("@PermitAll for: "+type); mmd.setDescriptions(descriptions); methods.add(mmd); metaData.add(perm); }
public void process(MethodPermissionsMetaData metaData, T type) { RolesAllowed allowed = finder.getAnnotation(type, RolesAllowed.class); if(allowed == null) return; Method method = null; if(type instanceof Method) method = (Method) type; String ejbName = EjbNameThreadLocal.ejbName.get(); MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method); MethodPermissionMetaData perm = new MethodPermissionMetaData(); MethodsMetaData methods = perm.getMethods(); if(methods == null) { methods = new MethodsMetaData(); perm.setMethods(methods); } HashSet<String> roles = new HashSet<String>(); for(String role : allowed.value()) roles.add(role); perm.setRoles(roles); Descriptions descriptions = ProcessorUtils.getDescription("@RolesAllowed for: "+type); mmd.setDescriptions(descriptions); methods.add(mmd); metaData.add(perm); }
if (permission.isNotChecked(methodName, params, interfaceType)) break; else if (permission.matches(methodName, params, interfaceType)) Set<String> roles = permission.getRoles(); if (roles != null)
for (MethodPermissionMetaData perm : perms) MethodsMetaData methods = perm.getMethods(); if (methods != null) for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods) String iface = miType != null ? miType.name() : null; EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params); if (perm.getUnchecked() != null) Set<String> roles = perm.getRoles(); Iterator riter = roles.iterator(); while (riter.hasNext())
@Override public String toString() { StringBuilder tmp = new StringBuilder("MethodPermissionMetaData(id="); tmp.append(getId()); if (isNotChecked()) { tmp.append(",unchecked=true"); } else { tmp.append(",roles="); tmp.append(this.roles); } tmp.append(",methods="); tmp.append(this.methods); tmp.append(')'); return tmp.toString(); } }
public Set<String> getRoles() { Set<String> result = getDelegate().getRoles(); if (result == null) result = Collections.emptySet(); return result; }
/** * Bump the iterators onto the next element */ private void bump() { while (delegate.hasNext()) { permission = delegate.next(); MethodsMetaData theMethods = permission.getMethods(); if (theMethods != null && theMethods.isEmpty() == false) { methods = theMethods.iterator(); break; } } } }
public boolean isUnchecked() { return getDelegate().isNotChecked(); } }
/** * Get the method permissions for an ejb * * @param ejbName the ejb name * @return the method permission or null for no result * @throws IllegalArgumentException for a null ejb name */ public MethodPermissionMetaData getMethodPermissionByEjbName(String ejbName) { if (ejbName == null) throw new IllegalArgumentException("Null ejbName"); if (methods == null) return null; MethodsMetaData ejbMethods = methods.getMethodsByEjbName(ejbName); if (ejbMethods == null) return null; MethodPermissionMetaData result = clone(); result.setMethods(ejbMethods); return result; }
/** * Get the methods permissions for an ejb * * @param ejbName the ejb name * @return the method permissions or null for no result * @throws IllegalArgumentException for a null ejb name */ public MethodPermissionsMetaData getMethodPermissionsByEjbName(String ejbName) { if (ejbName == null) throw new IllegalArgumentException("Null ejbName"); if (isEmpty()) return null; MethodPermissionsMetaData result = null; for (MethodPermissionMetaData permission : this) { MethodPermissionMetaData ejbPermission = permission.getMethodPermissionByEjbName(ejbName); if (ejbPermission != null) { if (result == null) result = new MethodPermissionsMetaData(); result.add(ejbPermission); } } return result; }
/** * Check to see if there was a method-permission or exclude-list statement * for the given method. * * @param methodName - the method name * @param params - the method parameter signature * @param interfaceType - the method interface type * @return true if a matching method permission exists, false if no match */ public boolean hasMethodPermissions(String methodName, Class<?>[] params, MethodInterfaceType interfaceType) { // First check the excluded method list as this takes priority over // all other assignments ExcludeListMetaData excluded = getExcludeList(); if (excluded != null && excluded.matches(methodName, params, interfaceType)) return true; // Check the permissioned methods list MethodPermissionsMetaData permissions = getMethodPermissions(); if (permissions != null) { for (MethodPermissionMetaData permission : permissions) { if (permission.matches(methodName, params, interfaceType)) return true; } } // No match return false; }
public void process(MethodPermissionsMetaData metaData, T type) { PermitAll permit = finder.getAnnotation(type, PermitAll.class); if(permit == null) return; Method method = null; if(type instanceof Method) method = (Method) type; String ejbName = EjbNameThreadLocal.ejbName.get(); MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method); MethodPermissionMetaData perm = new MethodPermissionMetaData(); MethodsMetaData methods = perm.getMethods(); if(methods == null) { methods = new MethodsMetaData(); perm.setMethods(methods); } perm.setUnchecked(new EmptyMetaData()); Descriptions descriptions = ProcessorUtils.getDescription("@PermitAll for: "+type); mmd.setDescriptions(descriptions); methods.add(mmd); metaData.add(perm); }
public void process(MethodPermissionsMetaData metaData, T type) { RolesAllowed allowed = finder.getAnnotation(type, RolesAllowed.class); if(allowed == null) return; Method method = null; if(type instanceof Method) method = (Method) type; String ejbName = EjbNameThreadLocal.ejbName.get(); MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method); MethodPermissionMetaData perm = new MethodPermissionMetaData(); MethodsMetaData methods = perm.getMethods(); if(methods == null) { methods = new MethodsMetaData(); perm.setMethods(methods); } HashSet<String> roles = new HashSet<String>(); for(String role : allowed.value()) roles.add(role); perm.setRoles(roles); Descriptions descriptions = ProcessorUtils.getDescription("@RolesAllowed for: "+type); mmd.setDescriptions(descriptions); methods.add(mmd); metaData.add(perm); }
if (permission.isNotChecked(methodName, params, interfaceType)) break; else if (permission.matches(methodName, params, interfaceType)) Set<String> roles = permission.getRoles(); if (roles != null)
@Override public String toString() { StringBuilder tmp = new StringBuilder("MethodPermissionMetaData(id="); tmp.append(getId()); if (isNotChecked()) { tmp.append(",unchecked=true"); } else { tmp.append(",roles="); tmp.append(this.roles); } tmp.append(",methods="); tmp.append(this.methods); tmp.append(')'); return tmp.toString(); } }
public Set<String> getRoles() { Set<String> result = getDelegate().getRoles(); if (result == null) result = Collections.emptySet(); return result; }
/** * Bump the iterators onto the next element */ private void bump() { while (delegate.hasNext()) { permission = delegate.next(); MethodsMetaData theMethods = permission.getMethods(); if (theMethods != null && theMethods.isEmpty() == false) { methods = theMethods.iterator(); break; } } } }
public boolean isUnchecked() { return getDelegate().isNotChecked(); } }