93
93
public class SAMLConfiguration {
94
94
95
95
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
+
97
107
@ Inject
98
108
private Environment environment ;
99
109
@@ -152,7 +162,7 @@ public SimpleUrlLogoutSuccessHandler successLogoutHandler() {
152
162
public WebSSOProfileOptions defaultWebSSOProfileOptions () {
153
163
WebSSOProfileOptions webSSOProfileOptions = new WebSSOProfileOptions ();
154
164
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" )));
156
166
return webSSOProfileOptions ;
157
167
}
158
168
@@ -168,13 +178,13 @@ public WebSSOProfile webSSOprofile() {
168
178
169
179
@ Bean
170
180
public KeyManager keyManager () {
171
- String keystore = environment .getProperty ("proxy.saml.keystore" );
181
+ String keystore = environment .getProperty (PROP_KEYSTORE );
172
182
if (keystore == null || keystore .isEmpty ()) {
173
183
return new EmptyKeyManager ();
174
184
} 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 );
178
188
179
189
Resource keystoreFile = new FileSystemResource (keystore );
180
190
Map <String , String > passwords = new HashMap <>();
@@ -238,8 +248,8 @@ public MetadataDisplayFilter metadataDisplayFilter() throws MetadataProviderExce
238
248
239
249
@ Bean
240
250
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 );
243
253
244
254
MetadataGenerator metadataGenerator = new MetadataGenerator ();
245
255
metadataGenerator .setEntityId (appEntityId );
@@ -260,7 +270,7 @@ public ExtendedMetadata extendedMetadata() {
260
270
261
271
@ Bean
262
272
public ExtendedMetadataDelegate idpMetadata () throws MetadataProviderException , ResourceException {
263
- String metadataURL = environment .getProperty ("proxy.saml.idp-metadata-url" );
273
+ String metadataURL = environment .getProperty (PROP_METADATA_URL );
264
274
265
275
Timer backgroundTaskTimer = new Timer (true );
266
276
HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider (backgroundTaskTimer , new HttpClient (), metadataURL ); httpMetadataProvider .setParserPool (parserPool ());
@@ -342,7 +352,7 @@ public SAMLAuthenticationProvider samlAuthenticationProvider() {
342
352
public Object loadUserBySAML (SAMLCredential credential ) throws UsernameNotFoundException {
343
353
List <Attribute > attributes = credential .getAttributes ();
344
354
345
- if (Boolean .parseBoolean (environment .getProperty ("proxy.saml.log-attributes" , "false" ))) {
355
+ if (Boolean .parseBoolean (environment .getProperty (PROP_LOG_ATTRIBUTES , "false" ))) {
346
356
// don't use nameValue from below so that in the case this attribute isn't correctly setup,
347
357
// we can still log the attribtues (and the correct attribute can be found)
348
358
String userID = credential .getNameID ().getValue ();
0 commit comments