Package org.jboss.security.auth.callback

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler


     lc.logout();
  }
  public void testSimple() throws Exception
  {
     log.info("testSimple");
     UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke", "jduke".toCharArray());
     LoginContext lc = new LoginContext("testSimple", handler);
     lc.login();
     Subject subject = lc.getSubject();
     Set groups = subject.getPrincipals(Group.class);
     assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("jduke")));
View Full Code Here


 

  public void testSharedMap() throws Exception
  {
     log.info("testSharedMap");
     UsernamePasswordHandler handler = new UsernamePasswordHandler("anil", "superman".toCharArray());
     LoginContext lc = new LoginContext("testSharedMap", handler);
     lc.login();
     Subject subject = lc.getSubject();
     Set groups = subject.getPrincipals(Group.class);
     assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("anil")));
View Full Code Here

   * @throws Exception if an error occurs while running the test.
   */
  public void testValidateError() throws Exception
  {
     // test the configuration that doesn't set the throwValidateError flag.
     LoginContext context = new LoginContext("testValidateError", new UsernamePasswordHandler(null, null));
     try
     {
        context.login();
        fail("Login should have failed as the validation of the test module was unsuccessful");
     }
     catch(LoginException le)
     {
        assertNull("Unexpected root throwable found", le.getCause());
     }
    
     // test the configuration that sets the throwValidateError flag.
     context = new LoginContext("testValidateErrorWithFlag", new UsernamePasswordHandler(null, null));
     try
     {
        context.login();
        fail("Login should have failed as the validation of the test module was unsuccessful");
     }
View Full Code Here

   * @throws Exception if an error occurs while running the test.
   */
  public void testInputValidator() throws Exception
  {
     // let's start with a valid username/password pair.
     LoginContext context = new LoginContext("testInputValidator", new UsernamePasswordHandler("user", "secret"));
     context.login();
     assertNotNull(context.getSubject());
     context.logout();
    
     // now let's try a username that doesn't conform to the [A-Za-z0-9]* pattern.
     context = new LoginContext("testInputValidator", new UsernamePasswordHandler("$user$", "secret"));
     try
     {
        context.login();
        fail("Login should have failed as the supplied username does not adhere to the expected pattern");
     }
     catch(LoginException le)
     {
        assertEquals("Username or password does not adhere to the acceptable pattern", le.getMessage());
     }
    
     // now let's try a password that doesn't conform to the pattern by including a space in the middle of the password).
     context = new LoginContext("testInputValidator", new UsernamePasswordHandler("user", "sec ret"));
     try
     {
        context.login();
        fail("Login should have failed as the supplied username does not adhere to the expected pattern");
     }
     catch(LoginException le)
     {
        assertEquals("Username or password does not adhere to the acceptable pattern", le.getMessage());
     }
    
     // finally, let's try a username that has one of the blacklisted tokens.
     context = new LoginContext("testInputValidator", new UsernamePasswordHandler("javaINSERTduke", "secret"));
     try
     {
        context.login();
        fail("Login should have failed as the supplied username does not adhere to the expected pattern");
     }
View Full Code Here

         else
         {
            username = principal.toString();
         }
   
         UsernamePasswordHandler handler = new UsernamePasswordHandler(username,
            credentials);
         Configuration conf = getConfiguration();
         // Do the JAAS login
         LoginContext lc = new LoginContext(protocol, null, handler, conf);
         lc.login();
View Full Code Here

/*     */       }
/*     */       else
/*     */       {
/* 105 */         username = principal.toString();
/*     */       }
/* 107 */       UsernamePasswordHandler handler = new UsernamePasswordHandler(username, credentials);
/*     */
/* 110 */       LoginContext lc = new LoginContext(protocol, handler);
/* 111 */       lc.login();
/*     */     }
/*     */     catch (LoginException e)
View Full Code Here

/*    */       }
/*    */       else
/*    */       {
/* 79 */         username = principal.toString();
/*    */       }
/* 81 */       UsernamePasswordHandler handler = new UsernamePasswordHandler(username, credentials);
/*    */
/* 84 */       LoginContext lc = new LoginContext(protocol, handler);
/* 85 */       lc.login();
/*    */     }
/*    */     catch (LoginException e)
View Full Code Here

         }
         else
         {
            username = principal.toString();
         }
         UsernamePasswordHandler handler = new UsernamePasswordHandler(username,
            credentials);
         // Do the JAAS login
         LoginContext lc = new LoginContext(protocol, handler);
         lc.login();
      }
View Full Code Here

TOP

Related Classes of org.jboss.security.auth.callback.UsernamePasswordHandler

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.