1 22 package org.jboss.test.security.identity.sso; 23 24 import org.jboss.security.identity.sso.AuthResponse; 25 import org.jboss.security.identity.sso.JBossSingleSignOnProcessor; 26 import org.jboss.security.identity.sso.SSOUser; 27 import org.jboss.security.identity.sso.SingleSignOnProcessor; 28 import org.jboss.test.JBossTestCase; 29 30 32 40 public class SAMLGenerationTestCase extends JBossTestCase 41 { 42 45 private SingleSignOnProcessor processor = null; 46 47 private static final String USERNAME = "saml_user"; 48 private static final String PASSWORD = "saml_pwd"; 49 private static final String ASSERTING_PARTY = "jboss"; 50 51 public SAMLGenerationTestCase(String name) 52 { 53 super(name); 54 } 55 56 protected void setUp() 57 { 58 processor = new JBossSingleSignOnProcessor(); 59 } 60 61 protected void tearDown() 62 { 63 processor = null; 64 } 65 66 public void testRequestGeneration() throws Exception 67 { 68 assertNotNull("processor != null"); 69 String request = processor.generateAuthRequest(USERNAME, PASSWORD); 70 assertNotNull("request != null", request); 71 SSOUser user = processor.parseAuthRequest(request); 72 assertNotNull("user != null", user); 73 assertTrue("user ==" + USERNAME, user.getUserName().equals(USERNAME)); 74 assertTrue("pwd ==" + PASSWORD, user.getPassword().equals(PASSWORD)); 75 } 76 77 public void testResponseGeneration() throws Exception 78 { 79 assertNotNull("processor != null"); 80 String response = processor.generateAuthResponse(ASSERTING_PARTY,USERNAME, true); 81 assertNotNull("response != null", response); 82 AuthResponse authResponse = processor.parseAuthResponse(response); 83 assertNotNull("authResponse != null", authResponse); 84 assertTrue("AP ==" + ASSERTING_PARTY, 85 authResponse.getAssertingParty().equals(ASSERTING_PARTY)); 86 assertTrue(" USERNAME==" + USERNAME, 87 authResponse.getUser().getUserName().equals(USERNAME)); 88 assertNotNull("Asserting token != null", authResponse.getAssertToken()); 89 assertTrue("authenticated?", authResponse.isAuthenticated()); 90 } 91 } 92 | Popular Tags |