Skip to content

Commit

Permalink
Fix formatting after Maven build.
Browse files Browse the repository at this point in the history
  • Loading branch information
malaporte committed May 20, 2019
1 parent a29929f commit 2f65df3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/com/coveo/saml/SamlClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public static SamlClient fromMetadata(
* SAML response.
* @param metadata the XML metadata obtained from the identity provider.
* @param samlBinding the HTTP method to use for binding to the IdP.
* @param certificates list of certificates.
* @return The created {@link SamlClient}.
* @throws SamlException thrown if any error occur while loading the metadata information.
*/
Expand All @@ -394,12 +395,13 @@ public static SamlClient fromMetadata(
DOMMetadataResolver metadataResolver = createMetadataResolver(metadata);
EntityDescriptor entityDescriptor = getEntityDescriptor(metadataResolver);

IDPSSODescriptor idpSsoDescriptor = getIDPSSODescriptor(entityDescriptor);
IDPSSODescriptor idpSsoDescriptor = getIDPSSODescriptor(entityDescriptor);
SingleSignOnService idpBinding = null;
if(idpSsoDescriptor.getSingleSignOnServices()!=null && !idpSsoDescriptor.getSingleSignOnServices().isEmpty()) {
idpBinding = getIdpBinding(idpSsoDescriptor, samlBinding);
if (idpSsoDescriptor.getSingleSignOnServices() != null
&& !idpSsoDescriptor.getSingleSignOnServices().isEmpty()) {
idpBinding = getIdpBinding(idpSsoDescriptor, samlBinding);
}

List<X509Certificate> x509Certificates = getCertificates(idpSsoDescriptor);
boolean isOkta = entityDescriptor.getEntityID().contains(".okta.com");

Expand All @@ -413,7 +415,7 @@ public static SamlClient fromMetadata(
}
}

if (idpBinding!=null && assertionConsumerServiceUrl == null && isOkta) {
if (idpBinding != null && assertionConsumerServiceUrl == null && isOkta) {
// Again, Okta's own toolkit uses this value for the assertion consumer url, which
// kinda makes no sense since this is supposed to be a url pointing to a server
// outside Okta, but it probably just straight ignores this and use the one from
Expand All @@ -428,10 +430,10 @@ public static SamlClient fromMetadata(
}

String identityProviderUrl;
if(idpBinding!=null) {
identityProviderUrl = idpBinding.getLocation();
}else {
identityProviderUrl = assertionConsumerServiceUrl;
if (idpBinding != null) {
identityProviderUrl = idpBinding.getLocation();
} else {
identityProviderUrl = assertionConsumerServiceUrl;
}
String responseIssuer = entityDescriptor.getEntityID();

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/coveo/saml/SamlClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ public void metadataXMLFromHubCanBeLoaded() throws Throwable {
SamlClient.SamlIdpBinding.POST,
certificates);
}

@Test
public void metadataXMLFromPingFederateCanBeLoaded() throws Throwable {
SamlClient.fromMetadata(
"myidentifier", "http://some/url", getXml("ping.xml"), SamlClient.SamlIdpBinding.POST);
}

@Test
public void relyingPartyIdentifierAndAssertionConsumerServiceUrlCanBeOmittedForOkta()
throws Throwable {
Expand Down

0 comments on commit 2f65df3

Please sign in to comment.