Examples of LoginContext


Examples of javax.security.auth.login.LoginContext

    }
    return null;
  }

  protected LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
      return new LoginContext(domain, handler);
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

  protected LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
      return new LoginContext(domain, handler);
    }
 
  protected LoginContext createLoginContext(String domain, Subject subject) throws LoginException {
      return new LoginContext(domain, subject);
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

            }
    }

        // try to log out of the context.
        try {
          LoginContext context = info.getLoginContext();
          if (context != null) {
            context.logout();
          }
    } catch (LoginException e) {
       LogManager.logWarning(LogConstants.CTX_SECURITY,e,"Exception terminitating session"); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

  public SessionMetadata createSession(String userName, Credentials credentials, String applicationName, Properties properties, boolean adminConnection, boolean authenticate)
    throws LoginException, SessionServiceException {
    ArgCheck.isNotNull(applicationName);
        ArgCheck.isNotNull(properties);
       
        LoginContext loginContext = null;
        String securityDomain = "none"; //$NON-NLS-1$
        Object securityContext = null;
        List<String> domains = this.securityDomains;
        if (adminConnection) {
          domains = this.adminSecurityDomains;
View Full Code Here

Examples of javax.security.auth.login.LoginContext

 
  public void testLoginAndPermission() {
    initControl();
   
    LoginContext loginContext;
    try {
      loginContext = new LoginContext("gvs", new CallbackHandler() {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
              ((NameCallback) callback).setName(username);
            } else if (callback instanceof PasswordCallback) {
              ((PasswordCallback) callback).setPassword(password
                  .toCharArray());
            } else {
              throw new UnsupportedCallbackException(callback,
                  "Callback class not supported");
            }
          }
        }
       
      });
      loginContext.login();
    } catch (LoginException e) {
      throw new RuntimeException(e);
    }
    assertTrue(true); //made it till here
    Subject subject = loginContext.getSubject();
    Subject.doAsPrivileged(subject, new PrivilegedAction<Object>() {

      public Object run() {
        AccessController.checkPermission(new GVSImpersonatePermission(new SourceImpl(userSourceURL)));
        return null;
View Full Code Here

Examples of javax.security.auth.login.LoginContext

  }
 
  public void testWrongLogin() {
    initControl();
    final boolean[] exceptionCatched = new boolean[1];
    LoginContext loginContext;
    try {
      loginContext = new LoginContext("gvs", new CallbackHandler() {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
              ((NameCallback) callback).setName(username);
            } else if (callback instanceof PasswordCallback) {
              ((PasswordCallback) callback).setPassword((password+"wrong")
                  .toCharArray());
            } else {
              throw new UnsupportedCallbackException(callback,
                  "Callback class not supported");
            }
          }
        }
       
      });
      loginContext.login();
    } catch (LoginException e) {
      exceptionCatched[0] = true;
    }
    assertTrue(exceptionCatched[0]);
   
View Full Code Here

Examples of javax.security.auth.login.LoginContext

      public JaasSecurityHandler(Object target, final String username, final String password) {
          this.target = target;               
          Configuration jaasConfig = new JBossConfiguration();
          try {
              this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, null, new CallbackHandler() {
         
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                for (Callback callback : callbacks) {
                    if (callback instanceof NameCallback) {
View Full Code Here

Examples of javax.security.auth.login.LoginContext

      } else {
        jaasEntryName = JAAS_ENTRY_NAME; //default
      }
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "setIdentity: jaasEntryName = "  + jaasEntryName);
      loginContext = new LoginContext(jaasEntryName, new NoInputCallbackHandler(user, passwd));
    } catch (LoginException e) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "EXCEPTION setIdentity::",e);
      throw new Exception(e.getMessage());
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

      SecurityHelper sh = Mockito.mock(SecurityHelper.class);
      Mockito.stub(sh.getSubjectInContext("passthrough")).toReturn(subject); //$NON-NLS-1$
     
        TeiidLoginContext membershipService = new TeiidLoginContext(sh) {
      public LoginContext createLoginContext(String domain, CallbackHandler handler) throws LoginException {
            LoginContext context =  Mockito.mock(LoginContext.class);
            return context;
          }
      protected LoginContext createLoginContext(String domain, Subject subject) throws LoginException {
            LoginContext context =  Mockito.mock(LoginContext.class);
            return context;
        }     
        };
        return membershipService;
    }
View Full Code Here

Examples of javax.security.auth.login.LoginContext

        }, null);
      } catch (PrivilegedActionException e) {
        throw new RuntimeException(e);
      }
    } else {
      LoginContext loginContext;
      try {
        loginContext = new LoginContext("GVS-Auth", new CookieCallbackHandler(request));
        loginContext.login();
      } catch (LoginException e) {
        /*response.setResponseStatus(ResponseStatus.FORBIDDEN);
        log.info(e);
        response.setBody(new MessageBody2Read() {
 
          public ReadableByteChannel read() throws IOException {
            return Channels.newChannel(new ByteArrayInputStream("Login Failed".getBytes()));
          }
         
        });
        return;*/
        try {
          Cookie loginCookie = new Cookie("login", "-");
          loginCookie.setMaxAge(-1);
          response.setHeader(HeaderName.SET_COOKIE, loginCookie.toString());

          loginContext = new LoginContext("GVS-Auth", new CallbackHandler() {

            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
              for (int i = 0; i < callbacks.length; i++) {
                if (callbacks[i] instanceof NameCallback) {
                  ((NameCallback) callbacks[i]).setName("");
                } else if (callbacks[i] instanceof PasswordCallback) {
                  ((PasswordCallback) callbacks[i]).setPassword(""
                      .toCharArray());
                } else {
                  throw new UnsupportedCallbackException(callbacks[i],
                      "Callback class not supported");
                }

              }
             
            }
         
          });
          loginContext.login();
        } catch (LoginException e1) {
          // TODO Auto-generated catch block
          throw new RuntimeException(e1);
        }
       
      }
      try {
        Subject subject = loginContext.getSubject();
        Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
          public Object run() throws Exception {
            wrapped.handle(request, response);
            return null;
          }
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.