use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.
the class KerberosClientTests method testMissingKerberosHeader.
@Test
public void testMissingKerberosHeader() {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
final DirectKerberosClient client = new DirectKerberosClient(new KerberosAuthenticator(krbValidator));
KerberosCredentials credentials = client.getCredentials(new J2EContext(request, response));
assertNull(credentials);
}
use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.
the class PostSAML2ClientTests method testRelayState.
@Test
public void testRelayState() {
final SAML2Client client = getClient();
final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
context.getSessionStore().set(context, SAML2Client.SAML_RELAY_STATE_ATTRIBUTE, "relayState");
final RedirectAction action = client.getRedirectAction(context);
assertTrue(action.getContent().contains("<input type=\"hidden\" name=\"RelayState\" value=\"relayState\"/>"));
}
use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.
the class PostSAML2ClientTests method testForceAuthIsSetForPostBinding.
@Test
public void testForceAuthIsSetForPostBinding() {
final SAML2Client client = getClient();
client.getConfiguration().setForceAuth(true);
final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
final RedirectAction action = client.getRedirectAction(context);
assertTrue(getDecodedAuthnRequest(action.getContent()).contains("ForceAuthn=\"true\""));
}
use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.
the class PostSAML2ClientTests method testCustomSpEntityIdForPostBinding.
@Test
public void testCustomSpEntityIdForPostBinding() {
final SAML2Client client = getClient();
client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/cb");
final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
final RedirectAction action = client.getRedirectAction(context);
assertTrue(getDecodedAuthnRequest(action.getContent()).contains("<saml2:Issuer " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\" " + "NameQualifier=\"http://localhost:8080/cb\" " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\">http://localhost:8080/cb</saml2:Issuer>"));
}
use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.
the class RedirectSAML2ClientTests method testCustomSpEntityIdForRedirectBinding.
@Test
public void testCustomSpEntityIdForRedirectBinding() {
final SAML2Client client = getClient();
client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/callback");
final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
final RedirectAction action = client.getRedirectAction(context);
final String inflated = getInflatedAuthnRequest(action.getLocation());
assertTrue(inflated.contains("<saml2:Issuer " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\" " + "NameQualifier=\"http://localhost:8080/callback\" " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\">http://localhost:8080/callback</saml2:Issuer>"));
}
Aggregations