Package javax.security.sasl

Examples of javax.security.sasl.AuthenticationException


    @Override
    public void Authenticate(String user, String password) throws AuthenticationException {

      if(!userMap.containsKey(user)){
        throw new AuthenticationException("Invalid user : "+user);
      }
      if(!userMap.get(user).equals(password)){
        throw new AuthenticationException("Invalid passwd : "+password);
      }
    }
View Full Code Here


    } else if (authMethod == AuthMethods.CUSTOM) {
      return new CustomAuthenticationProviderImpl();
    } else if (authMethod == AuthMethods.NONE) {
      return new AnonymousAuthenticationProviderImpl();
    } else {
      throw new AuthenticationException("Unsupported authentication method");
    }
  }
View Full Code Here

    try {
      // Create initial context
      Context ctx = new InitialDirContext(env);
      ctx.close();
    } catch (NamingException e) {
      throw new AuthenticationException("Error validating LDAP user", e);
    }
  }
View Full Code Here

  @Override
  public void Authenticate(String user, String password) throws AuthenticationException {

    if (pamServiceNames == null || pamServiceNames.trim().isEmpty()) {
      throw new AuthenticationException("No PAM services are set.");
    }

    String[] pamServices = pamServiceNames.split(",");
    for (String pamService : pamServices) {
      Pam pam = new Pam(pamService);
      boolean isAuthenticated = pam.authenticateSuccessful(user, password);
      if (!isAuthenticated) {
        throw new AuthenticationException(
          "Error authenticating with the PAM service: " + pamService);
      }
    }
  }
View Full Code Here

    public static String getDirectiveValue(HashMap<String, String> directivesMap, String directive, boolean mandatory)
            throws AuthenticationException {
        String value = directivesMap.get(directive);
        if (value == null) {
            if (mandatory) {
                throw new AuthenticationException("\"" + directive + "\" mandatory directive is missing");
            }

            return "";
        }
View Full Code Here

        } catch (UnsupportedCallbackException e) {
            throw new SaslException(msg, e);
        }
  authnCb.clearPassword();
  if (!authnCb.isAuthenticated()) {
            throw new AuthenticationException(msg);
  }
    }
View Full Code Here

                           entry = realmMap.get(userName);
                        }
                     }
                  }
                  if (entry == null) {
                     throw new AuthenticationException("No matching user found");
                  }
                  for (String group : entry.getGroups()) {
                     subject.getPrincipals().add(new SimpleGroupPrincipal(group));
                  }
                  passwordCallback.setPassword(entry.getPassword());
View Full Code Here

        if(null==in)
        {
            int responseCode = httpclient.getResponseCode();
            if(401== responseCode || 403==responseCode)
                throw new AuthenticationException(responseCode, httpclient.getHeader("WWW-Authenticate"));
            else
                throw new IOException("Failed to open input stream, status: "+responseCode);
        }

        // read the encoding from the incoming document and default to UTF-8
View Full Code Here

    }
    else if (authMethod.equals(AuthMethods.NONE)) {
      return new AnonymousAuthenticationProviderImpl();
    }
    else {
      throw new AuthenticationException("Unsupported authentication method");
    }
  }
View Full Code Here

    try {
      // Create initial context
      DirContext ctx = new InitialDirContext(env);
      ctx.close();
    } catch (NamingException e) {
      throw new AuthenticationException("Error validating LDAP user", e);
    }
  return;
  }
View Full Code Here

TOP

Related Classes of javax.security.sasl.AuthenticationException

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.