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

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


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


    return lastLoginError;
  }

  @Override
  public Roles getRoles() {
    return new Roles(authenticated ? Roles.ADMIN : "NO_AUTH");
  }
View Full Code Here

   
    return authResult;
  }

  public Roles getRoles() {
    Roles resultRoles = new Roles();
   
    if(isSignedIn())
      resultRoles.add("SIGNED_IN");
   
    if(username!= null && username.equals("superuser"))
      resultRoles.add(Roles.ADMIN);
   
    return resultRoles;
  }
View Full Code Here

  /**
   * @see IRoleCheckingStrategy#hasAnyRole(Roles)
   */
  public final boolean hasAnyRole(final Roles roles)
  {
    final Roles sessionRoles = AbstractAuthenticatedWebSession.get().getRoles();
    return (sessionRoles != null) && sessionRoles.hasAnyRole(roles);
  }
View Full Code Here

    if (roles == null)
    {
      throw new IllegalArgumentException("roles must be not null");
    }
    this.uid = uid;
    this.roles = new Roles(roles);
  }
View Full Code Here

  public Roles getRoles()
  {
    if (isSignedIn())
    {
      // If the user is signed in, they have these roles
      return new Roles(Roles.ADMIN);
    }
    return null;
  }
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

    // 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()))
      {
        if (hasAny(new Roles(authorizeActionAnnotation.deny())))
        {
          return false;
        }

        Roles roles = new Roles(authorizeActionAnnotation.roles());
        if (!(isEmpty(roles) || hasAny(roles)))
        {
          return false;
        }
      }
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.