Package javax.security.jacc

Examples of javax.security.jacc.WebRoleRefPermission


            * must be the value of the role-name (that is the  reference), appearing in the security-role-ref.
            * The deployment tools must  call the addToRole method on the PolicyConfiguration object to add the
            * WebRoleRefPermission object resulting from the translation to the role
            * identified in the role-link appearing in the security-role-ref.
            */
            policyConfiguration.addToRole(roleLink, new WebRoleRefPermission(servletName, roleName));
            unmappedRoles.remove(roleName);
        }
        for (String roleName : unmappedRoles) {
            policyConfiguration.addToRole(roleName, new WebRoleRefPermission(servletName, roleName));
        }
    }
View Full Code Here


        }
    }

    protected void addUnmappedJSPPermissions() throws PolicyContextException {
        for (String roleName : securityRoles) {
            policyConfiguration.addToRole(roleName, new WebRoleRefPermission("", roleName));
        }
    }
View Full Code Here

         */
        if (name == null || name.equals("jsp")) {
            name = "";
        }
        try {
            acc.checkPermission(new WebRoleRefPermission(name, role));
            return true;
        } catch (AccessControlException e) {
            return false;
        }
    }
View Full Code Here

            servletName = "";
        }
        try {
            //correct run-as identity available from context manager.
            AccessControlContext acc = ContextManager.getCurrentContext();
            acc.checkPermission(new WebRoleRefPermission(servletName, role));
            return true;
        } catch (AccessControlException e) {
            return false;
        }
    }
View Full Code Here

            // JACC v1.0 secion B.19
            String servletName = InternalJettyServletHolder.getCurrentServletName();
            if (servletName == null || servletName.equals("jsp")) {
                servletName = "";
            }
            acc.checkPermission(new WebRoleRefPermission(servletName, role));
        } catch (AccessControlException e) {
            return false;
        }
        return true;
    }
View Full Code Here

            String[] roleRefs = servlet.findSecurityReferences();
            // Perform the unreferenced roles processing for every servlet name
            for (int j = 0; j < roleRefs.length; j++) {
                String roleRef = roleRefs[j];
                String roleName = servlet.findSecurityReference(roleRef);
                WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef);
                pc.addToRole(roleName, wrrp);
                /*
                 * A bit of a hack due to how tomcat calls out to its Realm.hasRole() with a role name that has been mapped to
                 * the role-link value. We may need to handle this with a custom request wrapper.
                 */
                wrrp = new WebRoleRefPermission(servletName, roleName);
                pc.addToRole(roleRef, wrrp);
                // Remove the role from the unreferencedRoles
                unRefRoles.remove(roleName);
            }

            // Spec 3.1.3.2: For each servlet element in the deployment descriptor
            // a WebRoleRefPermission must be added to each security-role of the
            // application whose name does not appear as the rolename
            // in a security-role-ref within the servlet element.
            for (String unrefRole : unRefRoles) {
                WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName, unrefRole);
                pc.addToRole(unrefRole, unrefP);
            }
        }

        // JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an
        // additional WebRoleRefPermission must be added to the corresponding role by
        // calling the addToRole method on the PolicyConfiguration object. The
        // name of all such permissions must be the empty string, and the actions of each
        // such permission must be the role-name of the corresponding role.
        for (int i = 0; i < unreferencedRoles.length; i++) {
            String unreferencedRole = unreferencedRoles[i];
            WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole);
            pc.addToRole(unreferencedRole, wrrep);
        }

        // Now build the cross product of the unreferencedRoles and servlets
        for (int i = 0; i < servlets.length; i++) {
            Wrapper servlet = (Wrapper) servlets[i];
            String servletName = servlet.getName();
            for (int j = 0; j < unreferencedRoles.length; j++) {
                String role = unreferencedRoles[j];
                WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role);
                pc.addToRole(role, wrrp);
            }
        }
    }
View Full Code Here

/* 266 */       Set unreferencedRoles = metaData.getSecurityRoleNames();
/* 267 */       if (roleRefs != null) {
/* 268 */         for (SecurityRoleRefMetaData roleRef : roleRefs)
/*     */         {
/* 270 */           String roleName = roleRef.getRoleLink();
/* 271 */           WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName());
/* 272 */           pc.addToRole(roleName, wrrp);
/*     */
/* 277 */           wrrp = new WebRoleRefPermission(servletName, roleName);
/* 278 */           pc.addToRole(roleRef.getName(), wrrp);
/*     */
/* 280 */           unreferencedRoles.remove(roleName);
/*     */         }
/*     */
/*     */       }
/*     */
/* 287 */       if (unreferencedRoles != null)
/* 288 */         for (String unrefRole : unreferencedRoles)
/*     */         {
/* 290 */           WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName, unrefRole);
/* 291 */           pc.addToRole(unrefRole, unrefP);
/*     */         }
/*     */     }
/*     */     String servletName;
/* 295 */     Set unreferencedRoles = metaData.getSecurityRoleNames();
/*     */
/* 301 */     if (unreferencedRoles != null) {
/* 302 */       for (String unreferencedRole : unreferencedRoles)
/*     */       {
/* 304 */         WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole);
/* 305 */         pc.addToRole(unreferencedRole, wrrep);
/*     */       }
/*     */     }
/*     */
/* 309 */     Set servletNames = servlets.keySet();
/*     */     Iterator i$;
/* 310 */     if (servletNames != null)
/* 311 */       for (i$ = servletNames.iterator(); i$.hasNext(); ) { servletName = (String)i$.next();
/*     */
/* 313 */         if (unreferencedRoles != null)
/* 314 */           for (String role : unreferencedRoles)
/*     */           {
/* 316 */             WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role);
/* 317 */             pc.addToRole(role, wrrp);
/*     */           }
/*     */       }
/*     */     String servletName;
/* 324 */     if (unreferencedRoles != null)
/* 325 */       for (String role : unreferencedRoles)
/*     */       {
/* 327 */         WebRoleRefPermission wrrp = new WebRoleRefPermission("", role);
/* 328 */         pc.addToRole(role, wrrp);
/*     */       }
/*     */   }
View Full Code Here

/* 229 */     return allowed;
/*     */   }
/*     */
/*     */   private boolean hasRole(Principal principal, String roleName, Set<Principal> roles, String servletName)
/*     */   {
/* 242 */     WebRoleRefPermission perm = new WebRoleRefPermission(servletName, roleName);
/* 243 */     Principal[] principals = { principal };
/* 244 */     if (roles != null)
/*     */     {
/* 246 */       principals = new Principal[roles.size()];
/* 247 */       roles.toArray(principals);
View Full Code Here

    }

    public boolean isUserInRole(Principal user, String role) {
        AccessControlContext acc = ContextManager.getCurrentContext();
        try {
            acc.checkPermission(new WebRoleRefPermission(JettyServletHolder.getJettyServletHolder().getName(), role));
        } catch (AccessControlException e) {
            return false;
        }
        return true;
    }
View Full Code Here

                Set refs = (Set) roleRefs.get(roleLink);
                if (refs == null) {
                    refs = new HashSet();
                    roleRefs.put(roleLink, refs);
                }
                refs.add(new WebRoleRefPermission(name, roleName));
            } else {
                log.warn("Ignored invalid security-role-ref element: " + "servlet-name=" + name + ", " + securityRef);
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.security.jacc.WebRoleRefPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.