Package org.apache.catalina.realm

Examples of org.apache.catalina.realm.GenericPrincipal


                fireSessionEvent(Session.SESSION_DESTROYED_EVENT, null);
            }

            // Call the logout method
            if (principal instanceof GenericPrincipal) {
                GenericPrincipal gp = (GenericPrincipal) principal;
                try {
                    gp.logout();
                } catch (Exception e) {
                    manager.getContainer().getLogger().error(
                            sm.getString("standardSession.logoutfail"),
                            e);
                }
View Full Code Here


                                         principal.getRoles()!=null?Arrays.asList(principal.getRoles()):null);
    }

    public GenericPrincipal getPrincipal( Realm realm )
    {
        return new GenericPrincipal(realm,name,password,getRoles()!=null?Arrays.asList(getRoles()):null);
    }
View Full Code Here

        String pwd = null;
        if ( hasPwd ) pwd = in.readUTF();
        int size = in.readInt();
        String[] roles = new String[size];
        for ( int i=0; i<size; i++ ) roles[i] = in.readUTF();
        return new GenericPrincipal(realm,name,pwd,Arrays.asList(roles));
    }
View Full Code Here

   * @param credentials
   *            Password or other credentials to use in authenticating this
   *            username
   */
  public Principal authenticate(String username, String credentials) {
    GenericPrincipal principal = (GenericPrincipal) getPrincipal(username);
    boolean validated = false;
    if (principal != null) {
      if (hasMessageDigest()) {
        // Hex hashes should be compared case-insensitive
        validated = (digest(credentials).equalsIgnoreCase(principal
            .getPassword()));
      } else {
        validated = (digest(credentials)
            .equals(principal.getPassword()));
      }
    }
    if (validated) {
      if (debug >= 2)
        log(sm.getString("userDatabaseRealm.authenticateSuccess", username));
View Full Code Here

  }
  /**
   * Return the password associated with the given principal's user name.
   */
  protected String getPassword(String username) {
    GenericPrincipal principal = (GenericPrincipal) getPrincipal(username);
    if (principal != null) {
      return (principal.getPassword());
    } else {
      return (null);
    }
  }
View Full Code Here

                fireSessionEvent(Session.SESSION_DESTROYED_EVENT, null);
            }

            // Call the logout method
            if (principal instanceof GenericPrincipal) {
                GenericPrincipal gp = (GenericPrincipal) principal;
                try {
                    gp.logout();
                } catch (Exception e) {
                    manager.getContainer().getLogger().error(
                            sm.getString("standardSession.logoutfail"),
                            e);
                }
View Full Code Here

  }

  public List<String> getUserRoles() {

    if (request.getUserPrincipal() instanceof GenericPrincipal) {
      final GenericPrincipal wp = (GenericPrincipal) request
          .getUserPrincipal();

      if (wp.getRoles() != null) {
        final List<String> roles = Arrays.asList(wp.getRoles());
        log.debug("GenericPrincipal roles: " + roles);
        return roles;
      }
    }


    if (request.getUserPrincipal() instanceof WindowsPrincipal) {
      final WindowsPrincipal wp = (WindowsPrincipal) request
          .getUserPrincipal();

      log.debug("WindowsPrincipal roles: " + wp.getRolesString());
      log.debug("WindowsPrincipal groups: " + wp.getGroups());

      if (wp.getRolesString() != null) {
        return Arrays.asList(wp.getRolesString().split(","));
      }
    }

    /*if (this.request.getUserPrincipal() instanceof ActiveDirectoryPrincipal) {
      final ActiveDirectoryPrincipal ap = (ActiveDirectoryPrincipal) this.request
View Full Code Here

    return null;
  }

  @Override
  protected Principal getPrincipal(String username) {
    return new GenericPrincipal(username, null, Arrays.asList( "*".split("")));
  }
 
View Full Code Here

      return "foo".equals(username) ? "bar" : "" + Math.random();
   }

   @Override
   protected Principal getPrincipal(String username) {
      return new GenericPrincipal(username, username, Arrays.asList("myrole"));
   }
View Full Code Here

                fireSessionEvent(Session.SESSION_DESTROYED_EVENT, null);
            }

            // Call the logout method
            if (principal instanceof GenericPrincipal) {
                GenericPrincipal gp = (GenericPrincipal) principal;
                try {
                    gp.logout();
                } catch (Exception e) {
                    manager.getContainer().getLogger().error(
                            sm.getString("standardSession.logoutfail"),
                            e);
                }
View Full Code Here

TOP

Related Classes of org.apache.catalina.realm.GenericPrincipal

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.