Package org.apache.wicket.authroles.authorization.strategies.role

Examples of org.apache.wicket.authroles.authorization.strategies.role.Roles


        this.version = version;
    }

    public void setEntitlements(final String[] entitlements) {
        String[] defensiveCopy = entitlements.clone();
        roles = new Roles(defensiveCopy);
    }
View Full Code Here


    }

    @Override
    public Roles getRoles() {
        if (isSignedIn()) {
            return new Roles("ROLE_USER");
        } else {
            return new Roles();
        }
    }
View Full Code Here

    }

    //FIXME: MZA: Modification of returning object - it would be better if roles were returned
    @Override
    public Roles getRoles() {
        Roles roles = new Roles();
        getRolesIfSignedIn(roles);
        return roles;
    }
View Full Code Here

    if (rolesToAdd == null)
    {
      throw new IllegalArgumentException("Argument rolesToAdd cannot be null");
    }

    Roles roles = rolesForAction.get(action);
    if (roles == null)
    {
      roles = new Roles();
      rolesForAction.put(action, roles);
    }
    roles.addAll(rolesToAdd);
  }
View Full Code Here

    if (rolesToRemove == null)
    {
      throw new IllegalArgumentException("Argument rolesToRemove cannot be null");
    }

    Roles roles = rolesForAction.get(action);
    if (roles != null)
    {
      roles.removeAll(rolesToRemove);
    }
    else
    {
      roles = new Roles();
      rolesForAction.put(action, roles);
    }

    // If we removed the last authorized role, we authorize the empty role
    // so that removing authorization can't suddenly open something up to
    // everyone.
    if (roles.size() == 0)
    {
      roles.add(MetaDataRoleAuthorizationStrategy.NO_ROLE);
    }
  }
View Full Code Here

    // Check class annotation first because it is more specific than package annotation
    final AuthorizeInstantiation classAnnotation = componentClass.getAnnotation(AuthorizeInstantiation.class);
    if (classAnnotation != null)
    {
      authorized = hasAny(new Roles(classAnnotation.value()));
    }
    else
    {
      // Check package annotation if there is no one on the the class
      final Package componentPackage = componentClass.getPackage();
      if (componentPackage != null)
      {
        final AuthorizeInstantiation packageAnnotation = componentPackage.getAnnotation(AuthorizeInstantiation.class);
        if (packageAnnotation != null)
        {
          authorized = hasAny(new Roles(packageAnnotation.value()));
        }
      }
    }

    return authorized;
View Full Code Here

  {
    if (authorizeActionAnnotation != null)
    {
      if (action.getName().equals(authorizeActionAnnotation.action()))
      {
        Roles deniedRoles = new Roles(authorizeActionAnnotation.deny());
        if (isEmpty(deniedRoles) == false && hasAny(deniedRoles))
        {
          return false;
        }

        Roles acceptedRoles = new Roles(authorizeActionAnnotation.roles());
        if (!(isEmpty(acceptedRoles) || hasAny(acceptedRoles)))
        {
          return false;
        }
      }
View Full Code Here

     *
     * @param roles
     */
    public UserRolesAuthorizer(String roles)
    {
      this.roles = new Roles(roles);
    }
View Full Code Here

   */
  public void testAdd1() throws Exception
  {
    ActionPermissions permissions = new ActionPermissions();
    Action mambo = new Action("mambo");
    permissions.authorize(mambo, new Roles("jonathan"));
    permissions.authorize(mambo, new Roles("johan"));
    permissions.authorize(mambo, new Roles("maurice"));
    permissions.authorize(mambo, new Roles("eelco"));
    assertEquals(4, permissions.rolesFor(mambo).size());
    permissions.unauthorize(mambo, new Roles("maurice"));
    assertEquals(3, permissions.rolesFor(mambo).size());
    permissions.authorizeAll(mambo);
    assertEquals(null, permissions.rolesFor(mambo));
  }
View Full Code Here

  public void testRemove1() throws Exception
  {
    ActionPermissions permissions = new ActionPermissions();
    Action mambo = new Action("mambo");
    assertEquals(null, permissions.rolesFor(mambo));
    permissions.unauthorize(mambo, new Roles("maurice"));
    assertEquals(new Roles(MetaDataRoleAuthorizationStrategy.NO_ROLE),
      permissions.rolesFor(mambo));
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.authroles.authorization.strategies.role.Roles

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.