6969import java .util .ArrayList ;
7070import java .util .Arrays ;
7171import java .util .Collection ;
72+ import java .util .Collections ;
7273import java .util .List ;
7374import java .util .Locale ;
7475import java .util .Map ;
@@ -757,11 +758,12 @@ private CertOptions getCertificateConfiguration(
757758
758759 printHeader ("What key usage should your certificate have?" , terminal );
759760 terminal .println ("The key usage extension defines the purpose of the key contained in the certificate." );
760- terminal .println (
761- "The usage restriction might be employed when a key, that could be used for more than one operation, is to be restricted."
762- );
761+ terminal .println ("The usage restriction might be employed when a key, that could be used for more than " );
762+ terminal .println ("one operation, is to be restricted." );
763763 terminal .println ("You may enter the key usage as a comma-delimited list of following values: " );
764- terminal .println (" - " + CertGenUtils .KEY_USAGE_MAPPINGS .keySet ().stream ().sorted ());
764+ for (String keyUsageName : CertGenUtils .KEY_USAGE_MAPPINGS .keySet ()) {
765+ terminal .println (" - " + keyUsageName );
766+ }
765767 terminal .println ("" );
766768
767769 keyUsage = readKeyUsage (terminal , keyUsage );
@@ -939,11 +941,12 @@ private CertificateTool.CAInfo createNewCA(Terminal terminal) {
939941
940942 printHeader ("What key usage should your CA have?" , terminal );
941943 terminal .println ("The key usage extension defines the purpose of the key contained in the certificate." );
942- terminal .println (
943- "The usage restriction might be employed when a key, that could be used for more than one operation, is to be restricted."
944- );
944+ terminal .println ("The usage restriction might be employed when a key, that could be used for more than " );
945+ terminal .println ("one operation, is to be restricted." );
945946 terminal .println ("You may enter the key usage as a comma-delimited list of following values: " );
946- terminal .println (" - " + CertGenUtils .KEY_USAGE_MAPPINGS .keySet ().stream ().sorted ());
947+ for (String keyUsageName : CertGenUtils .KEY_USAGE_MAPPINGS .keySet ()) {
948+ terminal .println (" - " + keyUsageName );
949+ }
947950 terminal .println ("" );
948951
949952 keyUsage = readKeyUsage (terminal , keyUsage );
@@ -1040,6 +1043,7 @@ private static List<String> readKeyUsage(Terminal terminal, List<String> default
10401043 final String [] keyUsages = input .split ("," );
10411044 final List <String > resolvedKeyUsages = new ArrayList <>(keyUsages .length );
10421045 for (String keyUsage : keyUsages ) {
1046+ keyUsage = keyUsage .trim ();
10431047 if (keyUsage .isEmpty ()) {
10441048 terminal .println ("Key usage cannot be empty" );
10451049 return null ;
@@ -1053,7 +1057,7 @@ private static List<String> readKeyUsage(Terminal terminal, List<String> default
10531057 }
10541058 resolvedKeyUsages .add (keyUsage );
10551059 }
1056- return resolvedKeyUsages ;
1060+ return Collections . unmodifiableList ( resolvedKeyUsages ) ;
10571061 });
10581062 }
10591063
0 commit comments