From 8acb3cbb24845360d8b2106bbe4cc573b454860d Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Wed, 24 Jun 2020 15:56:17 -0400 Subject: [PATCH] GUACAMOLE-103: Change IdP metadata file to a URI. --- .../auth/saml/conf/ConfigurationService.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/extensions/guacamole-auth-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java b/extensions/guacamole-auth-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java index f55d7b8ce..ca830cfd1 100644 --- a/extensions/guacamole-auth-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java +++ b/extensions/guacamole-auth-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java @@ -24,7 +24,6 @@ import com.onelogin.saml2.settings.IdPMetadataParser; import com.onelogin.saml2.settings.Saml2Settings; import com.onelogin.saml2.settings.SettingsBuilder; import com.onelogin.saml2.util.Constants; -import java.io.File; import java.net.URI; import java.util.HashMap; import java.util.Map; @@ -32,7 +31,6 @@ import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.environment.Environment; import org.apache.guacamole.properties.BooleanGuacamoleProperty; -import org.apache.guacamole.properties.FileGuacamoleProperty; import org.apache.guacamole.properties.StringGuacamoleProperty; import org.apache.guacamole.properties.URIGuacamoleProperty; @@ -43,13 +41,14 @@ import org.apache.guacamole.properties.URIGuacamoleProperty; public class ConfigurationService { /** - * The file containing the XML Metadata associated with the SAML IdP. + * The URI of the file containing the XML Metadata associated with the + * SAML IdP. */ - private static final FileGuacamoleProperty SAML_IDP_METADATA = - new FileGuacamoleProperty() { + private static final URIGuacamoleProperty SAML_IDP_METADATA = + new URIGuacamoleProperty() { @Override - public String getName() { return "saml-idp-metadata"; } + public String getName() { return "saml-idp-metadata-url"; } }; @@ -167,20 +166,22 @@ public class ConfigurationService { } /** - * The file that contains the metadata that the SAML client should - * use to communicate with the SAML IdP. This is generated by the - * SAML IdP and should be uploaded to the system where the Guacamole - * client is running. + * The URI that contains the metadata that the SAML client should + * use to communicate with the SAML IdP. This can either be a remote + * URL of a server that provides this, or can be a URI to a file on the + * local filesystem. The metadata file is usually generated by the SAML IdP + * and should be uploaded to the system where the Guacamole client is + * running. * * @return - * The file containing the metadata used by the SAML client + * The URI of the file containing the metadata used by the SAML client * when it communicates with the SAML IdP. * * @throws GuacamoleException * If guacamole.properties cannot be parsed, or if the client * metadata is missing. */ - private File getIdpMetadata() throws GuacamoleException { + private URI getIdpMetadata() throws GuacamoleException { return environment.getProperty(SAML_IDP_METADATA); } @@ -307,11 +308,11 @@ public class ConfigurationService { public Saml2Settings getSamlSettings() throws GuacamoleException { // Try to get the XML file, first. - File idpMetadata = getIdpMetadata(); + URI idpMetadata = getIdpMetadata(); Map samlMap; if (idpMetadata != null) { try { - samlMap = IdPMetadataParser.parseFileXML(idpMetadata.getAbsolutePath()); + samlMap = IdPMetadataParser.parseRemoteXML(idpMetadata.toURL()); } catch (Exception e) { throw new GuacamoleServerException(