jmuehlner commented on code in PR #741:
URL: https://github.com/apache/guacamole-client/pull/741#discussion_r914148948
##########
extensions/guacamole-auth-sso/modules/guacamole-auth-sso-saml/src/main/java/org/apache/guacamole/auth/saml/conf/ConfigurationService.java:
##########
@@ -329,6 +366,69 @@ public int getAuthenticationTimeout() throws
GuacamoleException {
return environment.getProperty(SAML_AUTH_TIMEOUT, 5);
}
+ /**
+ * Returns the file containing the x509 certificate to use when signing
+ * requests to the SAML IdP. If the property is not set, null will be
+ * returned.
+ *
+ * @return
+ * The file containing the x509 certificate to use when signing
+ * requests to the SAML IdP, or null if not defined.
+ *
+ * @throws GuacamoleException
+ * If the authentication timeout cannot be parsed.
+ */
+ public File getCertificateFile() throws GuacamoleException {
+ return environment.getProperty(SAML_X509_CERT_PATH);
+ }
+
+ /**
+ * Returns the file containing the private key to use when signing
+ * requests to the SAML IdP. If the property is not set, null will be
+ * returned.
+ *
+ * @return
+ * The file containing the private key to use when signing
+ * requests to the SAML IdP, or null if not defined.
+ *
+ * @throws GuacamoleException
+ * If the authentication timeout cannot be parsed.
+ */
+ public File getPrivateKeyFile() throws GuacamoleException {
+ return environment.getProperty(SAML_PRIVATE_KEY_PATH);
+ }
+
+ /**
+ * Returns the contents of a small file, such as a private key or
certificate into
+ * a String. If the file does not exist, or cannot be read for any reason,
a warning
+ * will be logged and null will be returned.
+ *
+ * @param file
+ * The file to read into a string.
+ *
+ * @param name
+ * A human-readable name for the file, to be used when formatting log
messages.
+ *
+ * @return
+ * The contents of the file having the given path, or null if the file
does not
+ * exist or cannot be read.
+ */
+ private String readFileContentsIntoString(File file, String name) {
+
+ // Attempt to read the file directly into a String
+ try {
+ return new String(Files.readAllBytes(file.toPath()),
StandardCharsets.UTF_8);
+ }
+
+ // If the file cannot be read, log a warning and treat it as if it
does not exist
+ catch (IOException e) {
+ logger.warn("{} \"{}\" could not be read.", name, file);
Review Comment:
Am I not already doing that?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]