use of org.keycloak.adapters.saml.config.KeycloakSamlAdapter in project keycloak by keycloak.
the class KeycloakSamlAdapterXMLParserTest method testXmlParserBaseFile.
@Test
public void testXmlParserBaseFile() throws Exception {
KeycloakSamlAdapter config = parseKeycloakSamlAdapterConfig("keycloak-saml.xml", KeycloakSamlAdapter.class);
assertThat(config, notNullValue());
assertThat(config.getSps(), hasSize(1));
SP sp = config.getSps().get(0);
assertThat(sp.getEntityID(), is("sp"));
assertThat(sp.getSslPolicy(), is("EXTERNAL"));
assertThat(sp.getNameIDPolicyFormat(), is("format"));
assertThat(sp.isForceAuthentication(), is(true));
assertThat(sp.isIsPassive(), is(true));
assertThat(sp.isAutodetectBearerOnly(), is(false));
assertThat(sp.isKeepDOMAssertion(), is(false));
assertThat(sp.getKeys(), hasSize(2));
Key signing = sp.getKeys().get(0);
assertThat(signing.isSigning(), is(true));
Key.KeyStoreConfig keystore = signing.getKeystore();
assertThat(keystore, notNullValue());
assertThat(keystore.getFile(), is("file"));
assertThat(keystore.getResource(), is("cp"));
assertThat(keystore.getPassword(), is("pw"));
assertThat(keystore.getPrivateKeyAlias(), is("private alias"));
assertThat(keystore.getPrivateKeyPassword(), is("private pw"));
assertThat(keystore.getCertificateAlias(), is("cert alias"));
Key encryption = sp.getKeys().get(1);
assertThat(encryption.isEncryption(), is(true));
assertThat(encryption.getPrivateKeyPem(), is("private pem"));
assertThat(encryption.getPublicKeyPem(), is("public pem"));
assertThat(sp.getPrincipalNameMapping().getPolicy(), is("FROM_ATTRIBUTE"));
assertThat(sp.getPrincipalNameMapping().getAttributeName(), is("attribute"));
assertThat(sp.getRoleAttributes(), hasSize(1));
assertThat(sp.getRoleAttributes(), Matchers.contains("member"));
IDP idp = sp.getIdp();
assertThat(idp.getEntityID(), is("idp"));
assertThat(idp.getSignatureAlgorithm(), is("RSA_SHA256"));
assertThat(idp.getSignatureCanonicalizationMethod(), is("canon"));
assertThat(idp.getSingleSignOnService().isSignRequest(), is(true));
assertThat(idp.getSingleSignOnService().isValidateResponseSignature(), is(true));
assertThat(idp.getSingleSignOnService().getRequestBinding(), is("POST"));
assertThat(idp.getSingleSignOnService().getBindingUrl(), is("url"));
assertThat(idp.getSingleLogoutService().isSignRequest(), is(false));
assertThat(idp.getSingleLogoutService().isSignResponse(), is(true));
assertThat(idp.getSingleLogoutService().isValidateRequestSignature(), is(true));
assertThat(idp.getSingleLogoutService().isValidateResponseSignature(), is(true));
assertThat(idp.getSingleLogoutService().getRequestBinding(), is("REDIRECT"));
assertThat(idp.getSingleLogoutService().getResponseBinding(), is("POST"));
assertThat(idp.getSingleLogoutService().getPostBindingUrl(), is("posturl"));
assertThat(idp.getSingleLogoutService().getRedirectBindingUrl(), is("redirecturl"));
assertThat(idp.getKeys(), hasSize(1));
assertThat(idp.getKeys().get(0).isSigning(), is(true));
assertThat(idp.getKeys().get(0).getCertificatePem(), is("cert pem"));
}
use of org.keycloak.adapters.saml.config.KeycloakSamlAdapter in project keycloak by keycloak.
the class KeycloakSamlAdapterXMLParserTest method testXmlParserSystemPropertiesWithPropertiesSet.
@Test
public void testXmlParserSystemPropertiesWithPropertiesSet() throws Exception {
try {
System.setProperty("keycloak-saml-properties.entityID", "meid");
System.setProperty("keycloak-saml-properties.sslPolicy", "INTERNAL");
System.setProperty("keycloak-saml-properties.signaturesRequired", "true");
KeycloakSamlAdapter config = parseKeycloakSamlAdapterConfig("keycloak-saml-properties.xml", KeycloakSamlAdapter.class);
assertThat(config, notNullValue());
assertThat(config.getSps(), Matchers.contains(instanceOf(SP.class)));
SP sp = config.getSps().get(0);
IDP idp = sp.getIdp();
assertThat(sp.getEntityID(), is("meid"));
assertThat(sp.getSslPolicy(), is("INTERNAL"));
assertThat(idp.isSignaturesRequired(), is(true));
assertThat(idp.getSingleLogoutService().isSignRequest(), is(true));
assertThat(idp.getSingleLogoutService().isSignResponse(), is(false));
assertThat(idp.getSingleSignOnService().isSignRequest(), is(true));
assertThat(idp.getSingleSignOnService().isValidateResponseSignature(), is(true));
// These should take default from IDP.signaturesRequired
assertThat(idp.getSingleLogoutService().isValidateRequestSignature(), is(true));
assertThat(idp.getSingleLogoutService().isValidateResponseSignature(), is(true));
// This is false by default
assertThat(idp.getSingleSignOnService().isValidateAssertionSignature(), is(false));
} finally {
System.clearProperty("keycloak-saml-properties.entityID");
System.clearProperty("keycloak-saml-properties.sslPolicy");
System.clearProperty("keycloak-saml-properties.signaturesRequired");
}
}
use of org.keycloak.adapters.saml.config.KeycloakSamlAdapter in project keycloak by keycloak.
the class KeycloakSamlAdapterXMLParserTest method testMetadataUrl.
@Test
public void testMetadataUrl() throws Exception {
KeycloakSamlAdapter config = parseKeycloakSamlAdapterConfig("keycloak-saml-with-metadata-url.xml", KeycloakSamlAdapter.class);
assertThat(config, notNullValue());
assertThat(config.getSps(), Matchers.contains(instanceOf(SP.class)));
SP sp = config.getSps().get(0);
IDP idp = sp.getIdp();
assertThat(idp.getMetadataUrl(), is("https:///example.com/metadata.xml"));
}
use of org.keycloak.adapters.saml.config.KeycloakSamlAdapter in project keycloak by keycloak.
the class KeycloakSamlAdapterXMLParserTest method testXmlParserSystemPropertiesNoPropertiesSet.
@Test
public void testXmlParserSystemPropertiesNoPropertiesSet() throws Exception {
KeycloakSamlAdapter config = parseKeycloakSamlAdapterConfig("keycloak-saml-properties.xml", KeycloakSamlAdapter.class);
assertThat(config, notNullValue());
assertThat(config.getSps(), Matchers.contains(instanceOf(SP.class)));
SP sp = config.getSps().get(0);
IDP idp = sp.getIdp();
assertThat(sp.getEntityID(), is("sp"));
assertThat(sp.getSslPolicy(), is("${keycloak-saml-properties.sslPolicy}"));
assertThat(idp.isSignaturesRequired(), is(false));
assertThat(idp.getSingleLogoutService().isSignRequest(), is(true));
assertThat(idp.getSingleLogoutService().isSignResponse(), is(false));
assertThat(idp.getSingleSignOnService().isSignRequest(), is(true));
assertThat(idp.getSingleSignOnService().isValidateResponseSignature(), is(true));
// These should take default from IDP.signaturesRequired
assertThat(idp.getSingleLogoutService().isValidateRequestSignature(), is(false));
assertThat(idp.getSingleLogoutService().isValidateResponseSignature(), is(false));
assertThat(idp.getSingleSignOnService().isValidateAssertionSignature(), is(false));
}
use of org.keycloak.adapters.saml.config.KeycloakSamlAdapter in project keycloak by keycloak.
the class KeycloakSamlAdapterXMLParserTest method testValidationWithKeepDOMAssertion.
@Test
public void testValidationWithKeepDOMAssertion() throws Exception {
testValidationValid("keycloak-saml-keepdomassertion.xml");
// check keep dom assertion is TRUE
KeycloakSamlAdapter config = parseKeycloakSamlAdapterConfig("keycloak-saml-keepdomassertion.xml", KeycloakSamlAdapter.class);
assertThat(config, Matchers.notNullValue());
assertThat(config.getSps(), hasSize(1));
SP sp = config.getSps().get(0);
assertThat(sp.isKeepDOMAssertion(), is(true));
}
Aggregations