Package javax.security.auth.login

Examples of javax.security.auth.login.LoginException


          this.securitydomain = domain;    
          this.loginContext = createLoginContext(domain, existing);
          return;
            }
            }
            throw new LoginException(RuntimePlugin.Util.getString("no_passthrough_identity_found")); //$NON-NLS-1$
      }

       
        // If username specifies a domain (user@domain) only that domain is authenticated against.
        // If username specifies no domain, then all domains are tried in order.
        for (String domain:getDomainsForUser(domains, username)) {
                   
            try {
            CallbackHandler handler = new CallbackHandler() {
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
              if (callbacks[i] instanceof NameCallback) {
                NameCallback nc = (NameCallback)callbacks[i];
                nc.setName(baseUsername);
              } else if (callbacks[i] instanceof PasswordCallback) {
                PasswordCallback pc = (PasswordCallback)callbacks[i];
                    char[] password = null;
                    if (credential != null) {
                      password = credential.getCredentialsAsCharArray();
                    }
                pc.setPassword(password);
                credentials = password;
              } else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); //$NON-NLS-1$
              }
            }
          }
            };       
             
            // this is the configured login for teiid
            this.loginContext = createLoginContext(domain,handler);
        this.loginContext.login();
        this.userName = baseUsername+AT+domain;
        this.securitydomain = domain;
        LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", username, "\""}); //$NON-NLS-1$ //$NON-NLS-2$
        return;
      } catch (LoginException e) {
        LogManager.logDetail(LogConstants.CTX_SECURITY,e, e.getMessage());
      }
        }
        throw new LoginException(RuntimePlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect", username )); //$NON-NLS-1$      
    }
View Full Code Here


  }

  public boolean login() throws LoginException {

    if (credentialMap == null) {
      throw new LoginException"Credential Map properties file failed to load"); //$NON-NLS-1$
    }
       
    return super.login();
  }
View Full Code Here

        cred.setManagedConnectionFactory(getMcf());
        SecurityActions.addCredentials(this.subject, cred);   
      }
      return super.commit();
    } catch (Exception e) {
      throw new LoginException("Failed to decode password: "+e.getMessage()); //$NON-NLS-1$
    }
  } 
View Full Code Here

         }
         return true;
      }
      catch (Exception e)
      {
         LoginException le = new LoginException();
         le.initCause(e);
         throw le;
      }
   }
View Full Code Here

   * @see javax.security.auth.spi.LoginModule#login()
   */
  public boolean login() throws LoginException {
    logger.debug("logging in");
    if (callbackHandler == null)
      throw new LoginException(
        "Error: no CallbackHandler available "
          + "to garner authentication information from the user");
    // Setup default callback handlers.
    Callback[] callbacks =
      new Callback[] {
        new NameCallback("Username: "),
        new PasswordCallback("Password: ", false)};

    try {
      callbackHandler.handle(callbacks);
    } catch (IOException e) {
      throw new LoginException("exception calling back: " + e.toString());
    } catch (UnsupportedCallbackException e) {
      throw new LoginException("exception calling back: " + e.toString());
    }

    String username = ((NameCallback) callbacks[0]).getName();
    String password =
      new String(((PasswordCallback) callbacks[1]).getPassword());
    if (username.equals("")) {
      //succesfull login of anoynmous user
      success = true;
      tempPrincipals.add(anonymousUserPrincipal);
      return true;
    }
    //get userInfo and check pwd
    try {
      Resource userResource = getUserResource(username);
      if (userResource == null) {
        if (logger.isInfoEnabled()) {
          logger.info("No user-resource with shortname "+username+" found");
        }
        throw new LoginException("Authentication failed: Password does not match");
      }
      success =
        userResource
          .getProperty(ACCOUNTMANAGER.passwordSha1)
          .getLiteral()
          .getString()
          .equals(
          Util.sha1(password));

      if (!success)
        throw new LoginException("Authentication failed: Password does not match");
      GVSPrincipal newPrincipal = new GVSPrincipal(username, userResource);
      tempPrincipals.add(newPrincipal);
    } catch (RuntimeException ex) {
      logger.error("error handling user info", ex);
      throw ex;
View Full Code Here

   */
  public boolean commit() throws LoginException {
    logger.debug("committing");
    if (success) {
      if (subject.isReadOnly()) {
        throw new LoginException("Subject is Readonly");
      }
      subject.getPrincipals().addAll(tempPrincipals);
      subject.getPublicCredentials().addAll(tempCredentials);
      tempPrincipals.clear();
      tempCredentials.clear();
View Full Code Here

  public boolean login() throws LoginException {
    this.client = new JRestClient();
    // 提示输入用户名和密码;
    if (callbackHandler == null) {
      throw new LoginException("没有指明 CallBackHandler!");
    }
    Callback[] callbacks = new Callback[2];
    callbacks[0] = new NameCallback("用户名");
    callbacks[1] = new PasswordCallback("密码", false);
    try {
View Full Code Here

     *      <code>LoginModule</code> should be ignored.
     */
    public boolean login() throws LoginException {
        /*  Authenticate user   */
        if (callbackHandler == null) {
            throw new LoginException("No callback handler is available");
        }
        NameCallback nameCallback = new NameCallback("username");
        PasswordCallback pwdCallback = new PasswordCallback("password", false);
        Callback[] callbacks = new Callback[] {nameCallback, pwdCallback};

        String username = null;
        char[] password = null;
        try {
            callbackHandler.handle(callbacks);
            username = nameCallback.getName();
            password = pwdCallback.getPassword();
        } catch (java.io.IOException ioe) {
            throw new LoginException(ioe.toString());
        } catch (UnsupportedCallbackException ce) {
            throw new LoginException("Error: " + ce.getCallback().toString());
        }
        /* check username and password */
        UserManager userManager = UserManager.getInstance();
        loggedInUser = userManager.verifyUsernamePassword(username, password);
        loginStatus = loggedInUser != null;
View Full Code Here

         this.systemSubject = lc.getSubject();
      }
      catch(Throwable t)
      {
         log.fatal("SystemAuthenticator failed, server will shutdown NOW!", t);
         LoginException le = new LoginException("SystemAuthenticator failed, msg="+t.getMessage());
         Thread shutdownThread = new Thread("SystemAuthenticatorExitThread")
         {
            public void run()
            {
               System.exit(1);
View Full Code Here

      String username = userPrincipal.getName();
      // First try to locate an SRPServerInterface using JNDI
      try
      {
         if( cacheJndiName == null )
            throw new LoginException("Required cacheJndiName option not set");
         InitialContext iniCtx = new InitialContext();
         CachePolicy cache = (CachePolicy) iniCtx.lookup(cacheJndiName);
         SRPSessionKey key;
         if( userPrincipal instanceof SRPPrincipal )
         {
            SRPPrincipal srpPrincpal = (SRPPrincipal) userPrincipal;
            key = new SRPSessionKey(username, srpPrincpal.getSessionID());
         }
         else
         {
            key = new SRPSessionKey(username);
         }
         Object cacheCredential = cache.get(key);
         if( cacheCredential == null )
         {
            throw new LoginException("No SRP session found for: "+key);
         }
         log.trace("Found SRP cache credential: "+cacheCredential);
         /** The cache object should be the SRPServerSession object used in the
          authentication of the client.
          */
         if( cacheCredential instanceof SRPServerSession )
         {
            session = (SRPServerSession) cacheCredential;
            if( validateCache(session) == false )
               throw new LoginException("Failed to validate SRP session key for: "+key);
         }
         else
         {
            throw new LoginException("Unknown type of cache credential: "+cacheCredential.getClass());
         }
      }
      catch(NamingException e)
      {
         log.error("Failed to load SRP auth cache", e);
         throw new LoginException("Failed to load SRP auth cache: "+e.toString(true));
      }
     
      log.trace("Login succeeded");
      // Put the username and the client challenge into the sharedState map
      sharedState.put("javax.security.auth.login.name", username);
View Full Code Here

TOP

Related Classes of javax.security.auth.login.LoginException

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.