9393public class SAMLConfiguration {
9494
9595 private static final String DEFAULT_NAME_ATTRIBUTE = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" ;
96-
96+
97+ private static final String PROP_LOG_ATTRIBUTES = "proxy.saml.log-attributes" ;
98+ private static final String PROP_FORCE_AUTHN = "proxy.saml.force-authn" ;
99+ private static final String PROP_KEYSTORE = "proxy.saml.keystore" ;
100+ private static final String PROP_ENCRYPTION_CERT_NAME = "proxy.saml.encryption-cert-name" ;
101+ private static final String PROP_ENCRYPTION_CERT_PASSWORD = "proxy.saml.encryption-cert-password" ;
102+ private static final String PROP_ENCRYPTION_KEYSTORE_PASSWORD = "proxy.saml.keystore-password" ;
103+ private static final String PROP_APP_ENTITY_ID = "proxy.saml.app-entity-id" ;
104+ private static final String PROP_BASE_URL = "proxy.saml.app-base-url" ;
105+ private static final String PROP_METADATA_URL = "proxy.saml.idp-metadata-url" ;
106+
97107 @ Inject
98108 private Environment environment ;
99109
@@ -152,7 +162,7 @@ public SimpleUrlLogoutSuccessHandler successLogoutHandler() {
152162 public WebSSOProfileOptions defaultWebSSOProfileOptions () {
153163 WebSSOProfileOptions webSSOProfileOptions = new WebSSOProfileOptions ();
154164 webSSOProfileOptions .setIncludeScoping (false );
155- webSSOProfileOptions .setForceAuthN (Boolean .valueOf (environment .getProperty ("proxy.saml.force-authn" , "false" )));
165+ webSSOProfileOptions .setForceAuthN (Boolean .valueOf (environment .getProperty (PROP_FORCE_AUTHN , "false" )));
156166 return webSSOProfileOptions ;
157167 }
158168
@@ -168,13 +178,13 @@ public WebSSOProfile webSSOprofile() {
168178
169179 @ Bean
170180 public KeyManager keyManager () {
171- String keystore = environment .getProperty ("proxy.saml.keystore" );
181+ String keystore = environment .getProperty (PROP_KEYSTORE );
172182 if (keystore == null || keystore .isEmpty ()) {
173183 return new EmptyKeyManager ();
174184 } else {
175- String certName = environment .getProperty ("proxy.saml.encryption-cert-name" );
176- String certPW = environment .getProperty ("proxy.saml.encryption-cert-password" );
177- String keystorePW = environment .getProperty ("proxy.saml.keystore-password" , certPW );
185+ String certName = environment .getProperty (PROP_ENCRYPTION_CERT_NAME );
186+ String certPW = environment .getProperty (PROP_ENCRYPTION_CERT_PASSWORD );
187+ String keystorePW = environment .getProperty (PROP_ENCRYPTION_KEYSTORE_PASSWORD , certPW );
178188
179189 Resource keystoreFile = new FileSystemResource (keystore );
180190 Map <String , String > passwords = new HashMap <>();
@@ -238,8 +248,8 @@ public MetadataDisplayFilter metadataDisplayFilter() throws MetadataProviderExce
238248
239249 @ Bean
240250 public MetadataGenerator metadataGenerator () {
241- String appEntityId = environment .getProperty ("proxy.saml.app-entity-id" );
242- String appBaseURL = environment .getProperty ("proxy.saml.app-base-url" );
251+ String appEntityId = environment .getProperty (PROP_APP_ENTITY_ID );
252+ String appBaseURL = environment .getProperty (PROP_BASE_URL );
243253
244254 MetadataGenerator metadataGenerator = new MetadataGenerator ();
245255 metadataGenerator .setEntityId (appEntityId );
@@ -260,7 +270,7 @@ public ExtendedMetadata extendedMetadata() {
260270
261271 @ Bean
262272 public ExtendedMetadataDelegate idpMetadata () throws MetadataProviderException , ResourceException {
263- String metadataURL = environment .getProperty ("proxy.saml.idp-metadata-url" );
273+ String metadataURL = environment .getProperty (PROP_METADATA_URL );
264274
265275 Timer backgroundTaskTimer = new Timer (true );
266276 HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider (backgroundTaskTimer , new HttpClient (), metadataURL ); httpMetadataProvider .setParserPool (parserPool ());
@@ -342,7 +352,7 @@ public SAMLAuthenticationProvider samlAuthenticationProvider() {
342352 public Object loadUserBySAML (SAMLCredential credential ) throws UsernameNotFoundException {
343353 List <Attribute > attributes = credential .getAttributes ();
344354
345- if (Boolean .parseBoolean (environment .getProperty ("proxy.saml.log-attributes" , "false" ))) {
355+ if (Boolean .parseBoolean (environment .getProperty (PROP_LOG_ATTRIBUTES , "false" ))) {
346356 // don't use nameValue from below so that in the case this attribute isn't correctly setup,
347357 // we can still log the attribtues (and the correct attribute can be found)
348358 String userID = credential .getNameID ().getValue ();
0 commit comments