Skip to content

Commit fa1df60

Browse files
authored
Merge pull request #101 from inflexiontecnologia/master
Be able to handle multiple signing certs provided by AzureAD IdP
2 parents 6c320d0 + 0f53b87 commit fa1df60

File tree

11 files changed

+546
-78
lines changed

11 files changed

+546
-78
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,14 @@ You should be able to workaround this by configuring your server so that it is a
548548
For Apache Tomcat this is done by setting the proxyName, proxyPort, scheme and secure attributes for the Connector. See [here](http://serverfault.com/questions/774300/ssl-offloading-from-apache-to-tomcat-get-overwritten-somewhere) for an example.
549549

550550

551+
### IdP with multiple certificates
552+
553+
In some scenarios the IdP uses different certificates for
554+
signing/encryption, or is under key rollover phase and more than one certificate is published on IdP metadata.
555+
556+
In order to handle that the toolkit offers the `onelogin.saml2.idp.x509certMulti` parameters where you can set additional certificates that will be used to validate IdP signature. However just the certificate setted in `onelogin.saml2.idp.x509cert` parameter will be used for encrypting.
557+
558+
551559
### Replay attacks
552560

553561
In order to avoid replay attacks, you can store the ID of the SAML messages already processed, to avoid processing them twice. Since the Messages expires and will be invalidated due that fact, you don't need to store those IDs longer than the time frame that you currently accepting.

core/src/main/java/com/onelogin/saml2/authn/SamlResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,16 @@ public boolean isValid(String requestId) {
293293
if (signedElements.isEmpty() || (!hasSignedAssertion && !hasSignedResponse)) {
294294
throw new ValidationError("No Signature found. SAML Response rejected", ValidationError.NO_SIGNATURE_FOUND);
295295
} else {
296-
X509Certificate cert = settings.getIdpx509cert();
296+
List<X509Certificate> certList = settings.getIdpx509certMulti();
297297
String fingerprint = settings.getIdpCertFingerprint();
298298
String alg = settings.getIdpCertFingerprintAlgorithm();
299299

300-
if (hasSignedResponse && !Util.validateSign(samlResponseDocument, cert, fingerprint, alg, Util.RESPONSE_SIGNATURE_XPATH)) {
300+
if (hasSignedResponse && !Util.validateSign(samlResponseDocument, certList, fingerprint, alg, Util.RESPONSE_SIGNATURE_XPATH)) {
301301
throw new ValidationError("Signature validation failed. SAML Response rejected", ValidationError.INVALID_SIGNATURE);
302302
}
303303

304304
final Document documentToCheckAssertion = encrypted ? decryptedDocument : samlResponseDocument;
305-
if (hasSignedAssertion && !Util.validateSign(documentToCheckAssertion, cert, fingerprint, alg, Util.ASSERTION_SIGNATURE_XPATH)) {
305+
if (hasSignedAssertion && !Util.validateSign(documentToCheckAssertion, certList, fingerprint, alg, Util.ASSERTION_SIGNATURE_XPATH)) {
306306
throw new ValidationError("Signature validation failed. SAML Response rejected", ValidationError.INVALID_SIGNATURE);
307307
}
308308
}

core/src/main/java/com/onelogin/saml2/settings/Saml2Settings.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class Saml2Settings {
5252
private URL idpSingleLogoutServiceResponseUrl = null;
5353
private String idpSingleLogoutServiceBinding = Constants.BINDING_HTTP_REDIRECT;
5454
private X509Certificate idpx509cert = null;
55+
private List<X509Certificate> idpx509certMulti = null;
5556
private String idpCertFingerprint = null;
5657
private String idpCertFingerprintAlgorithm = "sha1";
5758

@@ -212,6 +213,13 @@ public final String getIdpCertFingerprintAlgorithm() {
212213
return idpCertFingerprintAlgorithm;
213214
}
214215

216+
/**
217+
* @return the idpx509certMulti setting value
218+
*/
219+
public List<X509Certificate> getIdpx509certMulti() {
220+
return idpx509certMulti;
221+
}
222+
215223
/**
216224
* @return the nameIdEncrypted setting value
217225
*/
@@ -522,6 +530,15 @@ protected final void setIdpCertFingerprintAlgorithm(String idpCertFingerprintAlg
522530
this.idpCertFingerprintAlgorithm = idpCertFingerprintAlgorithm;
523531
}
524532

533+
/**
534+
* Set the idpx509certMulti setting value
535+
*
536+
* @param idpx509certMulti the idpx509certMulti to set
537+
*/
538+
public void setIdpx509certMulti(List<X509Certificate> idpx509certMulti) {
539+
this.idpx509certMulti= idpx509certMulti;
540+
}
541+
525542
/**
526543
* Set the nameIdEncrypted setting value
527544
*

core/src/main/java/com/onelogin/saml2/settings/SettingsBuilder.java

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.security.PrivateKey;
88
import java.security.cert.CertificateException;
99
import java.security.cert.X509Certificate;
10+
import java.util.ArrayList;
1011
import java.util.Arrays;
1112
import java.util.LinkedHashMap;
1213
import java.util.LinkedList;
@@ -67,6 +68,7 @@ public class SettingsBuilder {
6768
public final static String IDP_SINGLE_LOGOUT_SERVICE_BINDING_PROPERTY_KEY = "onelogin.saml2.idp.single_logout_service.binding";
6869

6970
public final static String IDP_X509CERT_PROPERTY_KEY = "onelogin.saml2.idp.x509cert";
71+
public final static String IDP_X509CERTMULTI_PROPERTY_KEY = "onelogin.saml2.idp.x509certMulti";
7072
public final static String CERTFINGERPRINT_PROPERTY_KEY = "onelogin.saml2.idp.certfingerprint";
7173
public final static String CERTFINGERPRINT_ALGORITHM_PROPERTY_KEY = "onelogin.saml2.idp.certfingerprint_algorithm";
7274

@@ -222,9 +224,15 @@ private void loadIdpSetting() {
222224
if (idpSingleLogoutServiceBinding != null)
223225
saml2Setting.setIdpSingleLogoutServiceBinding(idpSingleLogoutServiceBinding);
224226

227+
List<X509Certificate> idpX509certMulti = loadCertificateListFromProp(IDP_X509CERTMULTI_PROPERTY_KEY);
228+
if (idpX509certMulti != null)
229+
saml2Setting.setIdpx509certMulti(idpX509certMulti);
230+
225231
X509Certificate idpX509cert = loadCertificateFromProp(IDP_X509CERT_PROPERTY_KEY);
226-
if (idpX509cert != null)
232+
if (idpX509cert != null) {
227233
saml2Setting.setIdpx509cert(idpX509cert);
234+
idpX509certMulti.add(0, idpX509cert);
235+
}
228236

229237
String idpCertFingerprint = loadStringProperty(CERTFINGERPRINT_PROPERTY_KEY);
230238
if (idpCertFingerprint != null)
@@ -485,15 +493,14 @@ private URL loadURLProperty(String propertyKey) {
485493
}
486494

487495
/**
488-
* Loads a property of the type X509Certificate from the Properties object
496+
* Loads a property of the type X509Certificate from the property value
489497
*
490-
* @param propertyKey
491-
* the property name
498+
* @param propValue
499+
* the property value
492500
*
493501
* @return the X509Certificate object
494502
*/
495-
protected X509Certificate loadCertificateFromProp(String propertyKey) {
496-
Object propValue = samlData.get(propertyKey);
503+
protected X509Certificate loadCertificateFromProp(Object propValue) {
497504

498505
if (isString(propValue)) {
499506
try {
@@ -511,6 +518,42 @@ protected X509Certificate loadCertificateFromProp(String propertyKey) {
511518
return null;
512519
}
513520

521+
/**
522+
* Loads a property of the type X509Certificate from the Properties object
523+
*
524+
* @param propertyKey
525+
* the property name
526+
*
527+
* @return the X509Certificate object
528+
*/
529+
protected X509Certificate loadCertificateFromProp(String propertyKey) {
530+
return loadCertificateFromProp(samlData.get(propertyKey));
531+
}
532+
533+
/**
534+
* Loads a property of the type List of X509Certificate from the Properties object
535+
*
536+
* @param propertyKey
537+
* the property name
538+
*
539+
* @return the X509Certificate object list
540+
*/
541+
private List<X509Certificate> loadCertificateListFromProp(String propertyKey) {
542+
List<X509Certificate> list = new ArrayList<X509Certificate>();
543+
544+
int i = 0;
545+
while (true) {
546+
Object propValue = samlData.get(propertyKey + "." + i++);
547+
548+
if (propValue == null)
549+
break;
550+
551+
list.add(loadCertificateFromProp(propValue));
552+
}
553+
554+
return list;
555+
}
556+
514557
/**
515558
* Loads a property of the type X509Certificate from file
516559
*

core/src/main/java/com/onelogin/saml2/util/Util.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.security.spec.PKCS8EncodedKeySpec;
3030
import java.util.Calendar;
3131
import java.util.Iterator;
32+
import java.util.List;
3233
import java.util.Locale;
3334
import java.util.TimeZone;
3435
import java.util.UUID;
@@ -852,6 +853,39 @@ public static boolean validateSign(final Document doc, final X509Certificate cer
852853
}
853854
return false;
854855
}
856+
857+
/**
858+
* Validate the signature pointed to by the xpath
859+
*
860+
* @param doc The document we should validate
861+
* @param certs The public certificates
862+
* @param fingerprint The fingerprint of the public certificate
863+
* @param alg The signature algorithm method
864+
* @param xpath the xpath of the ds:Signture node to validate
865+
*
866+
* @return True if the signature exists and is valid, false otherwise.
867+
*/
868+
public static boolean validateSign(final Document doc, final List<X509Certificate> certList, final String fingerprint,
869+
final String alg, final String xpath) {
870+
try {
871+
final NodeList signatures = query(doc, xpath);
872+
873+
if (signatures.getLength() == 1) {
874+
final Node signNode = signatures.item(0);
875+
if (certList == null || certList.isEmpty()) {
876+
return validateSignNode(signNode, null, fingerprint, alg);
877+
} else {
878+
for (X509Certificate cert : certList) {
879+
if (validateSignNode(signNode, cert, fingerprint, alg))
880+
return true;
881+
}
882+
}
883+
}
884+
} catch (XPathExpressionException e) {
885+
LOGGER.warn("Failed to find signature nodes", e);
886+
}
887+
return false;
888+
}
855889

856890
/**
857891
* Validate signature (Metadata).
@@ -921,10 +955,13 @@ public static Boolean validateSignNode(Node signNode, X509Certificate cert, Stri
921955
res = signature.checkSignatureValue(cert);
922956
} else {
923957
KeyInfo keyInfo = signature.getKeyInfo();
924-
if (keyInfo != null && keyInfo.containsX509Data()) {
958+
if (fingerprint != null && keyInfo != null && keyInfo.containsX509Data()) {
925959
X509Certificate providedCert = keyInfo.getX509Certificate();
926-
if (fingerprint.equals(calculateX509Fingerprint(providedCert, alg))) {
927-
res = signature.checkSignatureValue(providedCert);
960+
String calculatedFingerprint = calculateX509Fingerprint(providedCert, alg);
961+
for (String fingerprintStr : fingerprint.split(",")) {
962+
if (calculatedFingerprint.equals(fingerprintStr.trim())) {
963+
res = signature.checkSignatureValue(providedCert);
964+
}
928965
}
929966
}
930967
}

core/src/test/java/com/onelogin/saml2/test/authn/AuthnResponseTest.java

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,6 +2299,57 @@ public void testIsValidSign() throws IOException, Error, XPathExpressionExceptio
22992299
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
23002300
assertTrue(samlResponse.isValid());
23012301
}
2302+
2303+
/**
2304+
* Tests the isValid method of SamlResponse with idpx509certMulti
2305+
* Case: valid sign response / sign assertion / both signed
2306+
*
2307+
* @throws ValidationError
2308+
* @throws SettingsException
2309+
* @throws IOException
2310+
* @throws SAXException
2311+
* @throws ParserConfigurationException
2312+
* @throws XPathExpressionException
2313+
* @throws Error
2314+
*
2315+
* @see com.onelogin.saml2.authn.SamlResponse#isValid
2316+
*/
2317+
@Test
2318+
public void testIsValidSignWithCertMulti() throws IOException, Error, XPathExpressionException, ParserConfigurationException, SAXException, SettingsException, ValidationError {
2319+
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.mywithmulticert.properties").build();
2320+
settings.setWantAssertionsSigned(false);
2321+
settings.setWantMessagesSigned(false);
2322+
String samlResponseEncoded = Util.getFileAsString("data/responses/signed_message_response.xml.base64");
2323+
2324+
settings.setStrict(false);
2325+
SamlResponse samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2326+
assertTrue(samlResponse.isValid());
2327+
2328+
settings.setStrict(true);
2329+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2330+
assertTrue(samlResponse.isValid());
2331+
2332+
samlResponseEncoded = Util.getFileAsString("data/responses/signed_assertion_response.xml.base64");
2333+
2334+
settings.setStrict(false);
2335+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2336+
assertTrue(samlResponse.isValid());
2337+
2338+
settings.setStrict(true);
2339+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2340+
assertTrue(samlResponse.isValid());
2341+
2342+
samlResponseEncoded = Util.getFileAsString("data/responses/double_signed_response.xml.base64");
2343+
2344+
settings.setStrict(false);
2345+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2346+
assertTrue(samlResponse.isValid());
2347+
2348+
settings.setStrict(true);
2349+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2350+
assertTrue(samlResponse.isValid());
2351+
}
2352+
23022353

23032354
/**
23042355
* Tests the processSignedElements method of SamlResponse
@@ -2505,6 +2556,75 @@ public void testIsInValidSign() throws IOException, Error, XPathExpressionExcept
25052556
assertFalse(samlResponse.isValid());
25062557
assertEquals("Found an invalid Signed Element. SAML Response rejected", samlResponse.getError());
25072558
}
2559+
2560+
2561+
2562+
/**
2563+
* Tests the isValid method of SamlResponse with Idpx509certMulti
2564+
* Case: invalid signs
2565+
*
2566+
* @throws ValidationError
2567+
* @throws SettingsException
2568+
* @throws IOException
2569+
* @throws SAXException
2570+
* @throws ParserConfigurationException
2571+
* @throws XPathExpressionException
2572+
* @throws Error
2573+
*
2574+
* @see com.onelogin.saml2.authn.SamlResponse#isValid
2575+
*/
2576+
@Test
2577+
public void testIsInValidSignWithCertMulti() throws IOException, Error, XPathExpressionException, ParserConfigurationException, SAXException, SettingsException, ValidationError {
2578+
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.min.properties").build();
2579+
settings.setStrict(true);
2580+
String samlResponseEncoded = Util.getFileAsString("data/responses/unsigned_response.xml.base64");
2581+
2582+
SamlResponse samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2583+
assertFalse(samlResponse.isValid());
2584+
assertEquals("No Signature found. SAML Response rejected", samlResponse.getError());
2585+
2586+
settings = new SettingsBuilder().fromFile("config/config.mywithmulticert.properties").build();
2587+
2588+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/triple_signed_response.xml.base64");
2589+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2590+
assertFalse(samlResponse.isValid());
2591+
assertEquals("Duplicated ID. SAML Response rejected", samlResponse.getError());
2592+
2593+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/signed_assertion_response_with_2signatures.xml.base64");
2594+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2595+
assertFalse(samlResponse.isValid());
2596+
assertEquals("Duplicated ID. SAML Response rejected", samlResponse.getError());
2597+
2598+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/signed_message_response_with_2signatures.xml.base64");
2599+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2600+
assertFalse(samlResponse.isValid());
2601+
assertEquals("Duplicated ID. SAML Response rejected", samlResponse.getError());
2602+
2603+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/wrong_signed_element.xml.base64");
2604+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2605+
assertFalse(samlResponse.isValid());
2606+
assertEquals("Invalid Signature Element {urn:oasis:names:tc:SAML:2.0:assertion}Subject SAML Response rejected", samlResponse.getError());
2607+
2608+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/wrong_signed_element2.xml.base64");
2609+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2610+
assertFalse(samlResponse.isValid());
2611+
assertEquals("Invalid Signature Element {urn:oasis:names:tc:SAML:2.0:assertion}Subject SAML Response rejected", samlResponse.getError());
2612+
2613+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/duplicate_reference_uri.xml.base64");
2614+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2615+
assertFalse(samlResponse.isValid());
2616+
assertEquals("Found an invalid Signed Element. SAML Response rejected", samlResponse.getError());
2617+
2618+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/no_assertion_id.xml.base64");
2619+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2620+
assertFalse(samlResponse.isValid());
2621+
assertEquals("Signed Element must contain an ID. SAML Response rejected", samlResponse.getError());
2622+
2623+
samlResponseEncoded = Util.getFileAsString("data/responses/invalids/bad_reference.xml.base64");
2624+
samlResponse = new SamlResponse(settings, newHttpRequest(samlResponseEncoded));
2625+
assertFalse(samlResponse.isValid());
2626+
assertEquals("Found an invalid Signed Element. SAML Response rejected", samlResponse.getError());
2627+
}
25082628

25092629
/**
25102630
* Tests the validateSignedElements method of SamlResponse

core/src/test/java/com/onelogin/saml2/test/settings/SettingBuilderTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ public void testLoadFromValues() throws Exception {
618618
samlData.put(IDP_SINGLE_LOGOUT_SERVICE_BINDING_PROPERTY_KEY, "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect");
619619
samlData.put(IDP_SINGLE_LOGOUT_SERVICE_RESPONSE_URL_PROPERTY_KEY, "http://idp.example.com/simplesaml/saml2/idp/SingleLogoutServiceResponse.php");
620620
samlData.put(IDP_X509CERT_PROPERTY_KEY, "-----BEGIN CERTIFICATE-----\nMIIBrTCCAaGgAwIBAgIBATADBgEAMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRUwEwYDVQQHDAxTYW50YSBNb25pY2ExETAPBgNVBAoMCE9uZUxvZ2luMRkwFwYDVQQDDBBhcHAub25lbG9naW4uY29tMB4XDTEwMTAxMTIxMTUxMloXDTE1MTAxMTIxMTUxMlowZzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFTATBgNVBAcMDFNhbnRhIE1vbmljYTERMA8GA1UECgwIT25lTG9naW4xGTAXBgNVBAMMEGFwcC5vbmVsb2dpbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMPmjfjy7L35oDpeBXBoRVCgktPkLno9DOEWB7MgYMMVKs2B6ymWQLEWrDugMK1hkzWFhIb5fqWLGbWy0J0veGR9/gHOQG+rD/I36xAXnkdiXXhzoiAG/zQxM0edMOUf40n314FC8moErcUg6QabttzesO59HFz6shPuxcWaVAgxAgMBAAEwAwYBAAMBAA==\n-----END CERTIFICATE-----");
621+
samlData.put(IDP_X509CERTMULTI_PROPERTY_KEY + ".0", "-----BEGIN CERTIFICATE-----\nMIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYDVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4MTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xiZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2ZlaWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5vMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LONoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHISKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8BUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2QarQ4/67OZfHd7R+POBXhophSMv1ZOo\n-----END CERTIFICATE-----");
622+
samlData.put(IDP_X509CERTMULTI_PROPERTY_KEY + ".1", "-----BEGIN CERTIFICATE-----\nMIICbDCCAdWgAwIBAgIBADANBgkqhkiG9w0BAQ0FADBTMQswCQYDVQQGEwJ1czETMBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMT25lbG9naW4gSW5jMRgwFgYDVQQDDA9pZHAuZXhhbXBsZS5jb20wHhcNMTQwOTIzMTIyNDA4WhcNNDIwMjA4MTIyNDA4WjBTMQswCQYDVQQGEwJ1czETMBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMT25lbG9naW4gSW5jMRgwFgYDVQQDDA9pZHAuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOWA+YHU7cvPOrBOfxCscsYTJB+kH3MaA9BFrSHFS+KcR6cw7oPSktIJxUgvDpQbtfNcOkE/tuOPBDoech7AXfvH6d7Bw7xtW8PPJ2mB5Hn/HGW2roYhxmfh3tR5SdwN6i4ERVF8eLkvwCHsNQyK2Ref0DAJvpBNZMHCpS24916/AgMBAAGjUDBOMB0GA1UdDgQWBBQ77/qVeiigfhYDITplCNtJKZTM8DAfBgNVHSMEGDAWgBQ77/qVeiigfhYDITplCNtJKZTM8DAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4GBAJO2j/1uO80E5C2PM6Fk9mzerrbkxl7AZ/mvlbOn+sNZE+VZ1AntYuG8ekbJpJtG1YfRfc7EA9mEtqvv4dhv7zBy4nK49OR+KpIBjItWB5kYvrqMLKBa32sMbgqqUqeF1ENXKjpvLSuPdfGJZA3dNa/+Dyb8GGqWe707zLyc5F8m\n-----END CERTIFICATE-----");
621623
samlData.put(CERTFINGERPRINT_PROPERTY_KEY, "4b6f70bb2cab82c86a8270f71a880b62e25bc2b3");
622624
samlData.put(CERTFINGERPRINT_ALGORITHM_PROPERTY_KEY, "sha1");
623625

@@ -672,6 +674,14 @@ public void testLoadFromValues() throws Exception {
672674
assertEquals(setting.getIdpSingleLogoutServiceBinding(), "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect");
673675
assertNotNull(setting.getIdpx509cert());
674676
assertEquals(Util.loadCert(Util.getFileAsString("certs/certificate1")), setting.getIdpx509cert());
677+
assertNotNull(setting.getIdpx509certMulti());
678+
assertEquals(setting.getIdpx509certMulti().size(), 3);
679+
assertNotNull(setting.getIdpx509certMulti().get(0));
680+
assertEquals(Util.loadCert(Util.getFileAsString("certs/certificate1")), setting.getIdpx509certMulti().get(0));
681+
assertNotNull(setting.getIdpx509certMulti().get(1));
682+
assertEquals(Util.loadCert(Util.getFileAsString("certs/certificate2")), setting.getIdpx509certMulti().get(1));
683+
assertNotNull(setting.getIdpx509certMulti().get(2));
684+
assertEquals(Util.loadCert(Util.getFileAsString("certs/certificate3")), setting.getIdpx509certMulti().get(2));
675685
assertEquals("4b6f70bb2cab82c86a8270f71a880b62e25bc2b3", setting.getIdpCertFingerprint());
676686
assertEquals("sha1", setting.getIdpCertFingerprintAlgorithm());
677687

0 commit comments

Comments
 (0)