Package java.security

Examples of java.security.Principal


     
      if (password != null) {
        String signed = password;
       
        if (algorithm != null && ! "".equals(uid)) {
          Principal user = new BasicPrincipal(uid);
       
          char []digest = DigestBuilder.getDigest(user,
                                                  algorithm,
                                                  password.toCharArray(),
                                                  algorithm.toCharArray());
View Full Code Here


                                           credentials));
    }
    else if (credentials instanceof DigestCredentials) {
      DigestCredentials digestCred = (DigestCredentials) credentials;

      Principal user = new BasicPrincipal(digestCred.getUserName());
     
      user = auth.authenticate(user, digestCred, null);

      if (user == null) {
        throw new NotAuthorizedException(L.l("'{0}' has invalid digest credentials",
                                             digestCred.getUserName()));
      }
    }
    else if (credentials instanceof String) {
      String password = (String) credentials;
   
      Principal user = new BasicPrincipal(to);
      PasswordCredentials pwdCred = new PasswordCredentials(password);
   
      if (auth.authenticate(user, pwdCred, null) == null) {
        throw new NotAuthorizedException(L.l("'{0}' has invalid password credentials",
                                             to));
View Full Code Here

    if (clientDigest == null || username == null
        || uri == null || nonce == null)
      return null;

    Authenticator auth = getAuthenticator();
    Principal principal = new BasicPrincipal(username);

    HttpDigestCredentials cred = new HttpDigestCredentials();

    cred.setCnonce(cnonce);
    cred.setMethod(request.getMethod());
    cred.setNc(nc);
    cred.setNonce(nonce);
    cred.setQop(qop);
    cred.setRealm(realm);
    cred.setResponse(clientDigest);
    cred.setUri(uri);

    Principal user;

    user = auth.authenticate(principal, cred, request);

    if (log.isLoggable(Level.FINE))
      log.fine("digest: " + username + " -> " + user);
View Full Code Here

   */
  protected PasswordUser createUser(String name, String value)
  {
    String []values = value.trim().split("[,]");

    Principal principal = new BasicPrincipal(name);

    if (values.length < 1) {
      return new PasswordUser(principal, new char[0],
                              true, false,
                              new String[0]);
View Full Code Here

    Authenticator auth = getAuthenticator();
    BasicPrincipal user = new BasicPrincipal(userName);

    Credentials credentials = new PasswordCredentials(password);
    Principal principal = auth.authenticate(user, credentials, request);

    if (log.isLoggable(Level.FINE))
      log.fine("basic: " + user + " -> " + principal + " (" + auth + ")");

    return principal;
View Full Code Here

   * @return the logged in principal on success, null on failure.
   */
  public Principal getUserPrincipal(HttpServletRequest request)
  {
    for (int i = 0; i < _loginList.size(); i++) {
      Principal user = _loginList.get(i).getUserPrincipal(request);

      if (user != null)
        return user;
    }

View Full Code Here

  {
    for (int i = 0; i < _loginList.size(); i++) {
      Login login = _loginList.get(i);

      if (login.isLoginUsedForRequest(request)) {
        Principal user = login.login(request, response, isFail);

        if (user != null)
          return user;
      }
    }

    // if none match, use first

    if (_loginList.size() > 0) {
      Login login = _loginList.get(0);

      Principal user = login.login(request, response, isFail);

      return user;
    }

    return null;
View Full Code Here

      }

      if (roles == null)
        roles = new String[] { "user" };
     
      Principal principal = new BasicPrincipal(userName);

      boolean isDisabled = false;
      boolean isAnonymous = false;
     
      return new PasswordUser(principal, ldapPassword.toCharArray(),
View Full Code Here

      Set<Principal> principals = getPrincipals(userName, password);

      if (principals == null || principals.size() == 0)
        return null;
     
      Principal userPrincipal = null;
      Group roles = null;

      for (Principal loginPrincipal : principals) {
        if ("roles".equals(loginPrincipal.getName())
            && loginPrincipal instanceof Group) {
View Full Code Here

      if (_roles == null)
        return "user".equals(role);
     
      Enumeration<? extends Principal> e = _roles.members();
      while (e.hasMoreElements()) {
        Principal principal = e.nextElement();
       
        if (role.equals(principal.getName()))
          return true;
      }
     
      return false;
    }
View Full Code Here

TOP

Related Classes of java.security.Principal

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.