use of org.pac4j.core.context.WebContext 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>"));
}
use of org.pac4j.core.context.WebContext in project pac4j by pac4j.
the class RedirectSAML2ClientTests method testSetComparisonTypeWithRedirectBinding.
@Test
public void testSetComparisonTypeWithRedirectBinding() {
final SAML2Client client = getClient();
client.getConfiguration().setComparisonType(AuthnContextComparisonTypeEnumeration.EXACT.toString());
final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
final RedirectAction action = client.getRedirectAction(context);
assertTrue(getInflatedAuthnRequest(action.getLocation()).contains("Comparison=\"exact\""));
}
use of org.pac4j.core.context.WebContext in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testNoClientOnRequestBadDefaultClient.
@Test
public void testNoClientOnRequestBadDefaultClient() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
final WebContext context = MockWebContext.create();
TestsHelper.expectException(() -> finder.find(clients, context, FAKE_VALUE), TechnicalException.class, "No client found for name: " + FAKE_VALUE);
}
use of org.pac4j.core.context.WebContext in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testNoClientOnRequest.
@Test
public void testNoClientOnRequest() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
final WebContext context = MockWebContext.create();
final List<Client> currentClients = finder.find(clients, context, CLIENT_NAME);
assertEquals(1, currentClients.size());
assertEquals(client2, currentClients.get(0));
}
use of org.pac4j.core.context.WebContext in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testClientOnRequestNotAllowedList.
@Test
public void testClientOnRequestNotAllowedList() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
final WebContext context = MockWebContext.create().addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, NAME);
TestsHelper.expectException(() -> finder.find(clients, context, CLIENT_NAME + "," + FAKE_VALUE), TechnicalException.class, "Client not allowed: " + NAME);
}
Aggregations