GUACAMOLE-210: Move OpenID configuration property definitions into ConfigurationService.

This commit is contained in:
Michael Jumper
2017-02-21 12:45:37 -08:00
parent d04d61225a
commit 82c6048d50
2 changed files with 79 additions and 114 deletions

View File

@@ -22,6 +22,7 @@ package org.apache.guacamole.auth.openid.conf;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment; import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.properties.StringGuacamoleProperty;
/** /**
* Service for retrieving configuration information regarding the OpenID * Service for retrieving configuration information regarding the OpenID
@@ -29,6 +30,78 @@ import org.apache.guacamole.environment.Environment;
*/ */
public class ConfigurationService { public class ConfigurationService {
/**
* The authorization endpoint (URI) of the OpenID service.
*/
private static final StringGuacamoleProperty OPENID_AUTHORIZATION_ENDPOINT =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-authorization-endpoint"; }
};
/**
* The endpoint (URI) of the JWKS service which defines how received ID
* tokens (JWTs) shall be validated.
*/
private static final StringGuacamoleProperty OPENID_JWKS_ENDPOINT =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-jwks-endpoint"; }
};
/**
* The issuer to expect for all received ID tokens.
*/
private static final StringGuacamoleProperty OPENID_ISSUER =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-issuer"; }
};
/**
* The claim type which contains the authenticated user's username within
* any valid JWT.
*/
private static final StringGuacamoleProperty OPENID_USERNAME_CLAIM_TYPE =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-username-claim-type"; }
};
/**
* OpenID client ID which should be submitted to the OpenID service when
* necessary. This value is typically provided by the OpenID service when
* OpenID credentials are generated for your application.
*/
private static final StringGuacamoleProperty OPENID_CLIENT_ID =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-client-id"; }
};
/**
* The URI that the OpenID service should redirect to after the
* authentication process is complete. This must be the full URL that a
* user would enter into their browser to access Guacamole.
*/
private static final StringGuacamoleProperty OPENID_REDIRECT_URI =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-redirect-uri"; }
};
/** /**
* The Guacamole server environment. * The Guacamole server environment.
*/ */
@@ -48,7 +121,7 @@ public class ConfigurationService {
* endpoint property is missing. * endpoint property is missing.
*/ */
public String getAuthorizationEndpoint() throws GuacamoleException { public String getAuthorizationEndpoint() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_AUTHORIZATION_ENDPOINT); return environment.getRequiredProperty(OPENID_AUTHORIZATION_ENDPOINT);
} }
/** /**
@@ -66,7 +139,7 @@ public class ConfigurationService {
* property is missing. * property is missing.
*/ */
public String getClientID() throws GuacamoleException { public String getClientID() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_CLIENT_ID); return environment.getRequiredProperty(OPENID_CLIENT_ID);
} }
/** /**
@@ -84,7 +157,7 @@ public class ConfigurationService {
* property is missing. * property is missing.
*/ */
public String getRedirectURI() throws GuacamoleException { public String getRedirectURI() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_REDIRECT_URI); return environment.getRequiredProperty(OPENID_REDIRECT_URI);
} }
/** /**
@@ -100,7 +173,7 @@ public class ConfigurationService {
* is missing. * is missing.
*/ */
public String getIssuer() throws GuacamoleException { public String getIssuer() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_ISSUER); return environment.getRequiredProperty(OPENID_ISSUER);
} }
/** /**
@@ -118,7 +191,7 @@ public class ConfigurationService {
* property is missing. * property is missing.
*/ */
public String getJWKSEndpoint() throws GuacamoleException { public String getJWKSEndpoint() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_JWKS_ENDPOINT); return environment.getRequiredProperty(OPENID_JWKS_ENDPOINT);
} }
/** /**
@@ -134,7 +207,7 @@ public class ConfigurationService {
* type property is missing. * type property is missing.
*/ */
public String getUsernameClaimType() throws GuacamoleException { public String getUsernameClaimType() throws GuacamoleException {
return environment.getRequiredProperty(OpenIDGuacamoleProperties.OPENID_USERNAME_CLAIM_TYPE); return environment.getRequiredProperty(OPENID_USERNAME_CLAIM_TYPE);
} }
} }

View File

@@ -1,108 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.guacamole.auth.openid.conf;
import org.apache.guacamole.properties.StringGuacamoleProperty;
/**
* Provides properties required for use of the OpenID authentication provider.
* These properties will be read from guacamole.properties when the OpenID
* authentication provider is used.
*/
public class OpenIDGuacamoleProperties {
/**
* This class should not be instantiated.
*/
private OpenIDGuacamoleProperties() {}
/**
* The authorization endpoint (URI) of the OpenID service.
*/
public static final StringGuacamoleProperty OPENID_AUTHORIZATION_ENDPOINT =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-authorization-endpoint"; }
};
/**
* The endpoint (URI) of the JWKS service which defines how received ID
* tokens (JWTs) shall be validated.
*/
public static final StringGuacamoleProperty OPENID_JWKS_ENDPOINT =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-jwks-endpoint"; }
};
/**
* The issuer to expect for all received ID tokens.
*/
public static final StringGuacamoleProperty OPENID_ISSUER =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-issuer"; }
};
/**
* The claim type which contains the authenticated user's username within
* any valid JWT.
*/
public static final StringGuacamoleProperty OPENID_USERNAME_CLAIM_TYPE =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-username-claim-type"; }
};
/**
* OpenID client ID which should be submitted to the OpenID service when
* necessary. This value is typically provided by the OpenID service when
* OpenID credentials are generated for your application.
*/
public static final StringGuacamoleProperty OPENID_CLIENT_ID =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-client-id"; }
};
/**
* The URI that the OpenID service should redirect to after the
* authentication process is complete. This must be the full URL that a
* user would enter into their browser to access Guacamole.
*/
public static final StringGuacamoleProperty OPENID_REDIRECT_URI =
new StringGuacamoleProperty() {
@Override
public String getName() { return "openid-redirect-uri"; }
};
}