Search in sources :

Example 1 with SAML2MetadataUIInfo

use of org.pac4j.saml.metadata.SAML2MetadataUIInfo in project pac4j by pac4j.

the class PostSAML2ClientTests method testCustomSpEntityIdForPostBinding.

@Test
public void testCustomSpEntityIdForPostBinding() {
    final var client = getClient();
    client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/cb");
    client.getConfiguration().setUseNameQualifier(true);
    final var person = new SAML2MetadataContactPerson();
    person.setCompanyName("Pac4j");
    person.setGivenName("Bob");
    person.setSurname("Smith");
    person.setType("technical");
    person.setEmailAddresses(Collections.singletonList("test@example.org"));
    person.setTelephoneNumbers(Collections.singletonList("+13476547689"));
    client.getConfiguration().getContactPersons().add(person);
    final var uiInfo = new SAML2MetadataUIInfo();
    uiInfo.setDescriptions(Collections.singletonList("description1"));
    uiInfo.setDisplayNames(Collections.singletonList("displayName"));
    uiInfo.setPrivacyUrls(Collections.singletonList("https://pac4j.org"));
    uiInfo.setInformationUrls(Collections.singletonList("https://pac4j.org"));
    uiInfo.setKeywords(Collections.singletonList("keyword1,keyword2,keyword3"));
    uiInfo.setLogos(Collections.singletonList(new SAML2MetadataUIInfo.SAML2MetadataUILogo("https://pac4j.org/logo.png", 16, 16)));
    client.getConfiguration().getMetadataUIInfos().add(uiInfo);
    final var action = (OkAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
    final var issuerJdk11 = "<saml2:Issuer " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\" " + "NameQualifier=\"http://localhost:8080/cb\">http://localhost:8080/cb</saml2:Issuer>";
    final var decodedAuthnRequest = getDecodedAuthnRequest(action.getContent());
    assertTrue(decodedAuthnRequest.contains(issuerJdk11));
}
Also used : SAML2MetadataContactPerson(org.pac4j.saml.metadata.SAML2MetadataContactPerson) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) SAML2MetadataUIInfo(org.pac4j.saml.metadata.SAML2MetadataUIInfo) OkAction(org.pac4j.core.exception.http.OkAction) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MockSessionStore (org.pac4j.core.context.session.MockSessionStore)1 OkAction (org.pac4j.core.exception.http.OkAction)1 SAML2MetadataContactPerson (org.pac4j.saml.metadata.SAML2MetadataContactPerson)1 SAML2MetadataUIInfo (org.pac4j.saml.metadata.SAML2MetadataUIInfo)1