Package javax.security.auth.login

Examples of javax.security.auth.login.LoginContext.login()


    {
        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)
        {
View Full Code Here


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

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

    static void logoutContext(LoginContext context) {
        try {
View Full Code Here

    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

      // 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);
View Full Code Here

                            throw new UnsupportedCallbackException(callback);
                        }
                    }
                }
            });
            loginContext.login();
            if (role != null && role.length() > 0) {
                String clazz = "org.apache.karaf.jaas.modules.RolePrincipal";
                String name = role;
                int idx = role.indexOf(':');
                if (idx > 0) {
View Full Code Here

    }

    public static LoginContext login(String realm, CallbackHandler callbackHandler) throws LoginException {
        Subject subject = new Subject();
        LoginContext loginContext = new LoginContext(realm, subject, callbackHandler);
        loginContext.login();
        SubjectId id = ContextManager.registerSubject(subject);
        IdentificationPrincipal principal = new IdentificationPrincipal(id);
        subject.getPrincipals().add(principal);
        return loginContext;
    }
View Full Code Here

           
           
            CallbackHandler handler = getCallbackHandler(name, password)
            LoginContext ctx = new LoginContext(getContextName(), null, handler, loginConfig)
           
            ctx.login();
           
            Subject subject = ctx.getSubject();
           
            message.put(SecurityContext.class, createSecurityContext(subject));
        } catch (LoginException ex) {
View Full Code Here

        try
        {
            System.setProperty( "javax.security.auth.useSubjectCredsOnly", "true" );
            LoginContext loginContext = new LoginContext( request.getLoginContextName(),
                new SaslCallbackHandler( request ) );
            loginContext.login();

            final GssApiRequest requetFinal = request;
            return ( BindFuture ) Subject.doAs( loginContext.getSubject(), new PrivilegedExceptionAction<Object>()
            {
                public Object run() throws Exception
View Full Code Here

                  log.debug("Login context created " + principalName);

              // Negotiate a login via this LoginContext
              Subject subject;
              try {
                  loginContext.login();
                  Subject tempSubject = loginContext.getSubject();
                  if (tempSubject == null) {
                      if (log.isDebugEnabled())
                          log.debug(sm.getString("jaasRealm.failedLogin", principalName));
                      return (null);
View Full Code Here

            if (contextAndServiceNameCallback.getServiceName() == null) {
                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "kerberosCallbackServiceNameNotSupplied");
            }

            LoginContext loginContext = new LoginContext(contextAndServiceNameCallback.getContextName(), callbackHandler);
            loginContext.login();

            Subject clientSubject = loginContext.getSubject();
            Set<Principal> clientPrincipals = clientSubject.getPrincipals();
            if (clientPrincipals.isEmpty()) {
                throw new WSSecurityException(
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.