/** * Whether this roles object containes the provided role. * * @param role * the role to check * @return true if it contains the role, false otherwise */ public boolean hasRole(final String role) { if (role != null) { return contains(role); } return false; }
/** * Gets whether any of the given roles applies to the authorizer. * * @param roles * the roles * @return whether any of the given roles applies to the authorizer */ protected final boolean hasAny(Roles roles) { if (roles.isEmpty()) { return true; } else { return roleCheckingStrategy.hasAnyRole(roles); } }
/** * Conducts a check to see if the roles object is empty. Since the roles object does not contain * any null values and will always hold an empty string, an extra test is required beyond * roles.isEmpty(). * * @param roles * the Roles object to test * @return true if the object holds no real roles */ protected final boolean isEmpty(Roles roles) { if (roles.isEmpty()) { return true; } return false; } }
private boolean isResourceAnnotationSatisfied(AuthorizeResource annotation) { if (annotation != null) { // we have an annotation => we must check for the required roles return hasAny(new Roles(annotation.value())); } else { // no annotation => no required roles => this resource can be accessed return true; } } }
List<Roles> userRoleList = new ArrayList<Roles>(); Users currentUser = new Users(); currentUser.setUserId(userId); currentUser.setUsername(email); currentUser.setPassword(password); Roles userRole = new Roles(); userRole.setRoleId("2"); userRoleList.add(userRole); currentUser.setRolesCollection(userRoleList); getUsersFacade().create(currentUser);
/** * Construct. * * @param roles * Roles */ public Roles(final String[] roles) { Args.notNull(roles, "roles"); for (final String role : roles) { add(role); } }
/** * Construct. * * @param roleCheckingStrategy * the role checking strategy */ public RoleAuthorizationStrategy(final IRoleCheckingStrategy roleCheckingStrategy) { add(new AnnotationsRoleAuthorizationStrategy(roleCheckingStrategy)); add(new MetaDataRoleAuthorizationStrategy(roleCheckingStrategy)); } }
/** * Whether this roles object contains any of the provided roles. * * @param roles * the roles to check * @return true if it contains any of the roles, false otherwise */ public boolean hasAnyRole(Roles roles) { if (roles != null) { for (String role : roles) { if (hasRole(role)) { return true; } } } return false; }
/** * @see IRoleCheckingStrategy#hasAnyRole(Roles) */ @Override public final boolean hasAnyRole(final Roles roles) { final Roles sessionRoles = AbstractAuthenticatedWebSession.get().getRoles(); return (sessionRoles != null) && sessionRoles.hasAnyRole(roles); }
public Roles(final Collection<String> roles) { Args.notNull(roles, "roles"); addAll(roles); }
/** * Construct. * * @param roles * Roles */ public Roles(final String[] roles) { Args.notNull(roles, "roles"); for (final String role : roles) { add(role); } }
/** * Construct. * * @param roleCheckingStrategy * the role checking strategy */ public RoleAuthorizationStrategy(final IRoleCheckingStrategy roleCheckingStrategy) { add(new AnnotationsRoleAuthorizationStrategy(roleCheckingStrategy)); add(new MetaDataRoleAuthorizationStrategy(roleCheckingStrategy)); } }
/** * Whether this roles object contains any of the provided roles. * * @param roles * the roles to check * @return true if it contains any of the roles, false otherwise */ public boolean hasAnyRole(Roles roles) { if (roles != null) { for (String role : roles) { if (hasRole(role)) { return true; } } } return false; }
/** * Whether this roles object containes the provided role. * * @param role * the role to check * @return true if it contains the role, false otherwise */ public boolean hasRole(final String role) { if (role != null) { return contains(role); } return false; }
/** * Gets whether any of the given roles applies to the authorizer. * * @param roles * the roles * @return whether any of the given roles applies to the authorizer */ protected final boolean hasAny(Roles roles) { if (roles.isEmpty()) { return true; } else { return roleCheckingStrategy.hasAnyRole(roles); } }
/** * @see IRoleCheckingStrategy#hasAnyRole(Roles) */ @Override public final boolean hasAnyRole(final Roles roles) { final Roles sessionRoles = AbstractAuthenticatedWebSession.get().getRoles(); return (sessionRoles != null) && sessionRoles.hasAnyRole(roles); }
/** * Conducts a check to see if the roles object is empty. Since the roles object does not contain * any null values and will always hold an empty string, an extra test is required beyond * roles.isEmpty(). * * @param roles * the Roles object to test * @return true if the object holds no real roles */ protected final boolean isEmpty(Roles roles) { if (roles.isEmpty()) { return true; } return false; } }
public Roles(final Collection<String> roles) { Args.notNull(roles, "roles"); addAll(roles); }
/** * Whether this roles object contains all the provided roles. * * @param roles * the roles to check * @return true if it contains all the roles or the provided roles object is null, false * otherwise */ public boolean hasAllRoles(Roles roles) { if (roles != null) { for (String role : roles) { if (!hasRole(role)) { return false; } } } return true; }
/** * Whether this roles object contains all the provided roles. * * @param roles * the roles to check * @return true if it contains all the roles or the provided roles object is null, false * otherwise */ public boolean hasAllRoles(Roles roles) { if (roles != null) { for (String role : roles) { if (!hasRole(role)) { return false; } } } return true; }