@@ -110,22 +110,22 @@ public SamlMetadataCommand(CheckedFunction<Environment, KeyStoreWrapper, Excepti
110
110
attributeSpec = parser .accepts ("attribute" , "additional SAML attributes to request" ).withRequiredArg ();
111
111
orgNameSpec = parser .accepts ("organisation-name" , "the name of the organisation operating this service" ).withRequiredArg ();
112
112
orgDisplayNameSpec = parser .accepts ("organisation-display-name" , "the display-name of the organisation operating this service" )
113
- .availableIf (orgNameSpec ).withRequiredArg ();
113
+ .availableIf (orgNameSpec ).withRequiredArg ();
114
114
orgUrlSpec = parser .accepts ("organisation-url" , "the URL of the organisation operating this service" )
115
- .requiredIf (orgNameSpec ).withRequiredArg ();
115
+ .requiredIf (orgNameSpec ).withRequiredArg ();
116
116
contactsSpec = parser .accepts ("contacts" , "Include contact information in metadata" ).availableUnless (batchSpec );
117
117
signingPkcs12PathSpec = parser .accepts ("signing-bundle" , "path to an existing key pair (in PKCS#12 format) to be used for " +
118
- "signing " )
119
- .withRequiredArg ();
118
+ "signing " )
119
+ .withRequiredArg ();
120
120
signingCertPathSpec = parser .accepts ("signing-cert" , "path to an existing signing certificate" )
121
- .availableUnless (signingPkcs12PathSpec )
122
- .withRequiredArg ();
121
+ .availableUnless (signingPkcs12PathSpec )
122
+ .withRequiredArg ();
123
123
signingKeyPathSpec = parser .accepts ("signing-key" , "path to an existing signing private key" )
124
- .availableIf (signingCertPathSpec )
125
- .requiredIf (signingCertPathSpec )
126
- .withRequiredArg ();
124
+ .availableIf (signingCertPathSpec )
125
+ .requiredIf (signingCertPathSpec )
126
+ .withRequiredArg ();
127
127
keyPasswordSpec = parser .accepts ("signing-key-password" , "password for an existing signing private key or keypair" )
128
- .withOptionalArg ();
128
+ .withOptionalArg ();
129
129
this .keyStoreFunction = keyStoreFunction ;
130
130
}
131
131
@@ -159,19 +159,19 @@ EntityDescriptor buildEntityDescriptor(Terminal terminal, OptionSet options, Env
159
159
final RealmConfig realm = findRealm (terminal , options , env );
160
160
final Settings realmSettings = realm .settings ().getByPrefix (RealmSettings .realmSettingPrefix (realm .identifier ()));
161
161
terminal .println (Terminal .Verbosity .VERBOSE ,
162
- "Using realm configuration\n =====\n " + realmSettings .toDelimitedString ('\n' ) + "=====" );
162
+ "Using realm configuration\n =====\n " + realmSettings .toDelimitedString ('\n' ) + "=====" );
163
163
final Locale locale = findLocale (options );
164
164
terminal .println (Terminal .Verbosity .VERBOSE , "Using locale: " + locale .toLanguageTag ());
165
165
166
166
final SpConfiguration spConfig = SamlRealm .getSpConfiguration (realm );
167
167
final SamlSpMetadataBuilder builder = new SamlSpMetadataBuilder (locale , spConfig .getEntityId ())
168
- .assertionConsumerServiceUrl (spConfig .getAscUrl ())
169
- .singleLogoutServiceUrl (spConfig .getLogoutUrl ())
170
- .encryptionCredentials (spConfig .getEncryptionCredentials ())
171
- .signingCredential (spConfig .getSigningConfiguration ().getCredential ())
172
- .authnRequestsSigned (spConfig .getSigningConfiguration ().shouldSign (AuthnRequest .DEFAULT_ELEMENT_LOCAL_NAME ))
173
- .nameIdFormat (realm .getSetting (SamlRealmSettings .NAMEID_FORMAT ))
174
- .serviceName (option (serviceNameSpec , options , env .settings ().get ("cluster.name" )));
168
+ .assertionConsumerServiceUrl (spConfig .getAscUrl ())
169
+ .singleLogoutServiceUrl (spConfig .getLogoutUrl ())
170
+ .encryptionCredentials (spConfig .getEncryptionCredentials ())
171
+ .signingCredential (spConfig .getSigningConfiguration ().getCredential ())
172
+ .authnRequestsSigned (spConfig .getSigningConfiguration ().shouldSign (AuthnRequest .DEFAULT_ELEMENT_LOCAL_NAME ))
173
+ .nameIdFormat (realm .getSetting (SamlRealmSettings .NAMEID_FORMAT ))
174
+ .serviceName (option (serviceNameSpec , options , env .settings ().get ("cluster.name" )));
175
175
176
176
Map <String , String > attributes = getAttributeNames (options , realm );
177
177
for (String attr : attributes .keySet ()) {
@@ -185,22 +185,22 @@ EntityDescriptor buildEntityDescriptor(Terminal terminal, OptionSet options, Env
185
185
friendlyName = settingName ;
186
186
} else {
187
187
friendlyName = terminal .readText ("What is the friendly name for " +
188
- attributeSource
189
- + " attribute \" " + attr + "\" [default: " +
190
- (settingName == null ? "none" : settingName ) +
191
- "] " );
188
+ attributeSource
189
+ + " attribute \" " + attr + "\" [default: " +
190
+ (settingName == null ? "none" : settingName ) +
191
+ "] " );
192
192
if (Strings .isNullOrEmpty (friendlyName )) {
193
193
friendlyName = settingName ;
194
194
}
195
195
}
196
196
} else {
197
197
if (batch ) {
198
198
throw new UserException (ExitCodes .CONFIG , "Option " + batchSpec .toString () + " is specified, but attribute "
199
- + attr + " appears to be a FriendlyName value" );
199
+ + attr + " appears to be a FriendlyName value" );
200
200
}
201
201
friendlyName = attr ;
202
202
name = requireText (terminal ,
203
- "What is the standard (urn) name for " + attributeSource + " attribute \" " + attr + "\" (required): " );
203
+ "What is the standard (urn) name for " + attributeSource + " attribute \" " + attr + "\" (required): " );
204
204
}
205
205
terminal .println (Terminal .Verbosity .VERBOSE , "Requesting attribute '" + name + "' (FriendlyName: '" + friendlyName + "')" );
206
206
builder .withAttribute (friendlyName , name );
@@ -225,7 +225,7 @@ EntityDescriptor buildEntityDescriptor(Terminal terminal, OptionSet options, Env
225
225
break ;
226
226
} else {
227
227
terminal .errorPrintln ("Type '" + type + "' is not valid. Valid values are "
228
- + Strings .collectionToCommaDelimitedString (ContactInfo .TYPES .keySet ()));
228
+ + Strings .collectionToCommaDelimitedString (ContactInfo .TYPES .keySet ()));
229
229
}
230
230
}
231
231
builder .withContact (type , givenName , surName , email );
@@ -237,13 +237,13 @@ EntityDescriptor buildEntityDescriptor(Terminal terminal, OptionSet options, Env
237
237
238
238
// package-protected for testing
239
239
Element possiblySignDescriptor (Terminal terminal , OptionSet options , EntityDescriptor descriptor , Environment env )
240
- throws UserException {
240
+ throws UserException {
241
241
try {
242
242
final EntityDescriptorMarshaller marshaller = new EntityDescriptorMarshaller ();
243
243
if (options .has (signingPkcs12PathSpec ) || (options .has (signingCertPathSpec ) && options .has (signingKeyPathSpec ))) {
244
244
Signature signature = (Signature ) XMLObjectProviderRegistrySupport .getBuilderFactory ()
245
- .getBuilder (Signature .DEFAULT_ELEMENT_NAME )
246
- .buildObject (Signature .DEFAULT_ELEMENT_NAME );
245
+ .getBuilder (Signature .DEFAULT_ELEMENT_NAME )
246
+ .buildObject (Signature .DEFAULT_ELEMENT_NAME );
247
247
signature .setSigningCredential (buildSigningCredential (terminal , options , env ));
248
248
signature .setSignatureAlgorithm (SignatureConstants .ALGO_ID_SIGNATURE_RSA_SHA256 );
249
249
signature .setCanonicalizationAlgorithm (SignatureConstants .ALGO_ID_C14N_EXCL_OMIT_COMMENTS );
@@ -279,18 +279,18 @@ private Path writeOutput(Terminal terminal, OptionSet options, Element element)
279
279
}
280
280
281
281
private Credential buildSigningCredential (Terminal terminal , OptionSet options , Environment env ) throws
282
- Exception {
282
+ Exception {
283
283
X509Certificate signingCertificate ;
284
284
PrivateKey signingKey ;
285
285
char [] password = getChars (keyPasswordSpec .value (options ));
286
286
if (options .has (signingPkcs12PathSpec )) {
287
287
Path p12Path = resolvePath (signingPkcs12PathSpec .value (options ));
288
288
Map <Certificate , Key > keys = withPassword ("certificate bundle (" + p12Path + ")" , password ,
289
- terminal , keyPassword -> CertParsingUtils .readPkcs12KeyPairs (p12Path , keyPassword , a -> keyPassword ));
289
+ terminal , keyPassword -> CertParsingUtils .readPkcs12KeyPairs (p12Path , keyPassword , a -> keyPassword ));
290
290
291
291
if (keys .size () != 1 ) {
292
292
throw new IllegalArgumentException ("expected a single key in file [" + p12Path .toAbsolutePath () + "] but found [" +
293
- keys .size () + "]" );
293
+ keys .size () + "]" );
294
294
}
295
295
final Map .Entry <Certificate , Key > pair = keys .entrySet ().iterator ().next ();
296
296
signingCertificate = (X509Certificate ) pair .getKey ();
@@ -302,7 +302,7 @@ private Credential buildSigningCredential(Terminal terminal, OptionSet options,
302
302
Certificate [] certificates = CertParsingUtils .readCertificates (Collections .singletonList (resolvedSigningCertPath ), env );
303
303
if (certificates .length != 1 ) {
304
304
throw new IllegalArgumentException ("expected a single certificate in file [" + resolvedSigningCertPath + "] but found [" +
305
- certificates .length + "]" );
305
+ certificates .length + "]" );
306
306
}
307
307
signingCertificate = (X509Certificate ) certificates [0 ];
308
308
signingKey = readSigningKey (key , password , terminal );
@@ -329,7 +329,7 @@ private static char[] getChars(String password) {
329
329
}
330
330
331
331
private static PrivateKey readSigningKey (Path path , char [] password , Terminal terminal )
332
- throws Exception {
332
+ throws Exception {
333
333
AtomicReference <char []> passwordReference = new AtomicReference <>(password );
334
334
try {
335
335
return PemUtils .readPrivateKey (path , () -> {
@@ -447,18 +447,18 @@ private RealmConfig findRealm(Terminal terminal, OptionSet options, Environment
447
447
}
448
448
} else {
449
449
final List <Map .Entry <RealmConfig .RealmIdentifier , Settings >> saml = realms .entrySet ().stream ()
450
- .filter (entry -> isSamlRealm (entry .getKey ()))
451
- .collect (Collectors .toList ());
450
+ .filter (entry -> isSamlRealm (entry .getKey ()))
451
+ .collect (Collectors .toList ());
452
452
if (saml .isEmpty ()) {
453
453
throw new UserException (ExitCodes .CONFIG , "There is no SAML realm configured in " + env .configFile ());
454
454
}
455
455
if (saml .size () > 1 ) {
456
456
terminal .errorPrintln ("Using configuration in " + env .configFile ());
457
457
terminal .errorPrintln ("Found multiple SAML realms: "
458
- + saml .stream ().map (Map .Entry ::getKey ).map (Object ::toString ).collect (Collectors .joining (", " )));
458
+ + saml .stream ().map (Map .Entry ::getKey ).map (Object ::toString ).collect (Collectors .joining (", " )));
459
459
terminal .errorPrintln ("Use the -" + optionName (realmSpec ) + " option to specify an explicit realm" );
460
460
throw new UserException (ExitCodes .CONFIG ,
461
- "Found multiple SAML realms, please specify one with '-" + optionName (realmSpec ) + "'" );
461
+ "Found multiple SAML realms, please specify one with '-" + optionName (realmSpec ) + "'" );
462
462
}
463
463
final Map .Entry <RealmConfig .RealmIdentifier , Settings > entry = saml .get (0 );
464
464
terminal .println ("Building metadata for SAML realm " + entry .getKey ());
0 commit comments