Examples of LoginContext


Examples of javax.security.auth.login.LoginContext

    
     lc = null;
     String confName = System.getProperty("conf.name", "other");
     AppCallbackHandler handler = new AppCallbackHandler(username, password);
     log.debug("Creating LoginContext("+confName+")");
     lc = new LoginContext(confName, handler);
     lc.login();
     log.debug("Created LoginContext, subject="+lc.getSubject());
     loggedIn = true;
  }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

      lc = null;
      String username = "jduke";
      char[] password = "theduke".toCharArray();
      AppCallbackHandler handler = new AppCallbackHandler(username, password);
      log.debug("Creating LoginContext(ejb-timers)");
      lc = new LoginContext("ejb-timers", handler);
      lc.login();
      log.debug("Created LoginContext, subject="+lc.getSubject());
   }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

    public void testLogin()
    {
        CallbackHandler handler = new UsernamePasswordHandler("scott", "stark".toCharArray());
        try
        {
            LoginContext lc = new LoginContext("srp-login", handler);
            lc.login();
            Subject subject = lc.getSubject();
            System.out.println("Subject="+subject);
        }
        catch(LoginException e)
        {
            e.printStackTrace();
View Full Code Here

Examples of javax.security.auth.login.LoginContext

    
     lc = null;
     String confName = System.getProperty("conf.name", "jaas-test");
     AppCallbackHandler handler = new AppCallbackHandler(username, password);
     log.debug("Creating LoginContext("+confName+")");
     lc = new LoginContext(confName, handler);
     lc.login();
     log.debug("Created LoginContext, subject="+lc.getSubject());
     loggedIn = true;
  }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

    }
   
    protected void assertCredentials(ActiveDirectoryUser user, String password) throws Throwable {
        if (configuration.isUserAuthenticationGssApi()) {
            ActiveDirectoryUser activeDirectoryUser = (ActiveDirectoryUser) user;
            LoginContext context = configuration.createLoginContext(activeDirectoryUser.getUserPrincipalName(), password);
            ActiveDirectoryUserDatabaseConfiguration.logoutContext(context);
        } else {
            assertSimpleCredentialsValid(user.getPrincipalName(), password);
        }
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

   
    public Object doAs(PrivilegedAction<?> action) throws UserDatabaseException {
        Object result = null;
        if (isServiceAuthenticationGssApi()) {
            try {
                LoginContext context = getServiceAccountLoginContext();
                result = Subject.doAs(context.getSubject(), action);
                logoutContext(context);
            } catch (Exception e) {
                logger.error("Failure to create Login Context", e);
                throw new UserDatabaseException("", e);
            }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

        UserPasswordCallbackHandler callbackHandler = new UserPasswordCallbackHandler();
        callbackHandler.setUserId(username);
        callbackHandler.setPassword(password);

        LoginContext context = new LoginContext(ActiveDirectoryUserDatabase.class.getName(), callbackHandler);
        context.login();
        return context;
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

    PAMCallbackHandler callback = new PAMCallbackHandler();
    callback.setUserId(username);
    callback.setPassword(password);

    try {
      LoginContext context = new LoginContext(PAMUserDatabase.class.getName(), callback);
      context.login();
    }
    catch (LoginException e) {
      throw new InvalidLoginCredentialsException(e.getMessage());
    }
    return users.get(username);
View Full Code Here

Examples of javax.security.auth.login.LoginContext

   public class MockIdentity extends Identity
   {
      @Override
      protected LoginContext getLoginContext() throws LoginException
      {
         return new LoginContext("default", getSubject(), getCredentials().createCallbackHandler(),
               createMockJAASConfiguration());
      }           
View Full Code Here

Examples of javax.security.auth.login.LoginContext

      // perform the JAAS login; it will callback on the callbackHandler to
      // obtain
      // username and password
      try {
        LoginContext loginContext = new LoginContext(jaasApplicationName,
            callbackHandler);
        loginContext.login();

        request.getSession().setAttribute("SUBJECT", loginContext.getSubject());

        // redirect to the main menu page
        response.sendRedirect(request.getContextPath() + successRedirectUrl);
      } catch (LoginException le) {
        // redirect to the error page
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.