Package org.wildfly.security.ssl
Class CipherSuiteSelector
- java.lang.Object
- 
- org.wildfly.security.ssl.CipherSuiteSelector
 
- 
- Direct Known Subclasses:
- CipherSuiteSelector.AddingCipherSuiteSelector,- CipherSuiteSelector.FullyDeletingCipherSuiteSelector,- CipherSuiteSelector.PushToEndCipherSuiteSelector,- CipherSuiteSelector.RemovingCipherSuiteSelector,- CipherSuiteSelector.SortByAlgorithmKeyLengthCipherSuiteSelector
 
 public abstract class CipherSuiteSelector extends Object An immutable filter for SSL/TLS cipher suites.- Author:
- David M. Lloyd
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description (package private) static classCipherSuiteSelector.AddingCipherSuiteSelector(package private) static classCipherSuiteSelector.FullyDeletingCipherSuiteSelector(package private) static classCipherSuiteSelector.PushToEndCipherSuiteSelector(package private) static classCipherSuiteSelector.RemovingCipherSuiteSelector(package private) static classCipherSuiteSelector.SortByAlgorithmKeyLengthCipherSuiteSelector
 - 
Field SummaryFields Modifier and Type Field Description private static CipherSuiteSelectorEMPTY(package private) static CipherSuiteSelectorOPENSSL_ALL(package private) static CipherSuiteSelectorOPENSSL_COMBINED_DEFAULT(package private) static CipherSuiteSelectorOPENSSL_DEFAULTstatic StringOPENSSL_DEFAULT_CIPHER_SUITE_NAMESOpenSSL default cipher suites for TLSv1.3.(package private) static CipherSuiteSelectorOPENSSL_DEFAULT_CIPHER_SUITES(package private) CipherSuiteSelectorprevprivate static CipherSuiteSelectorTLS13_EMPTY
 - 
Constructor SummaryConstructors Constructor Description CipherSuiteSelector(CipherSuiteSelector prev)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CipherSuiteSelectoradd(String cipherSuiteName)A convenience method to add a cipher suite by name.CipherSuiteSelectoradd(CipherSuitePredicate predicate)Add all cipher suites which are matched by the given predicate.static CipherSuiteSelectoraggregate(CipherSuiteSelector cipherSuiteSelector1, CipherSuiteSelector cipherSuiteSelector2)Create an aggregateCipherSuiteSelector.(package private) abstract voidapplyFilter(Set<String> enabled, Map<MechanismDatabase.Entry,String> supported)CipherSuiteSelectordeleteFully(String cipherSuiteName)A convenience method to permanently delete a cipher suite by name.CipherSuiteSelectordeleteFully(CipherSuitePredicate predicate)Permanently delete all cipher suites which are matched by the given predicate.private voiddoEvaluate(Set<String> enabled, Map<MechanismDatabase.Entry,String> supported)static CipherSuiteSelectorempty()Get the basic empty SSL cipher suite selector.static CipherSuiteSelectorempty(boolean useTLS13)Get the basic empty SSL cipher suite selector.String[]evaluate(String[] supportedMechanisms)Evaluate this selector against the given list of JSSE supported mechanisms.static CipherSuiteSelectorfromNamesString(String names)Create a cipher suite selector from the given OpenSSL-style TLSv1.3 cipher suites string.static CipherSuiteSelectorfromString(String string)Create a cipher suite selector from the given OpenSSL-style cipher list string.(package private) MechanismDatabasegetMechanismDatabase()private static CipherSuitePredicategetSimplePredicateByName(String word)static CipherSuiteSelectoropenSslAll()Get the cipher selector which OpenSSL defines asALL.static CipherSuiteSelectoropenSslCombinedDefault()Get the cipher selector which OpenSSL defines asDEFAULTcombined with the cipher suites which OpenSSL defines as the default cipher suites for TLSv1.3.static CipherSuiteSelectoropenSslDefault()Get the cipher selector which OpenSSL defines asDEFAULT.static CipherSuiteSelectoropenSslDefaultCipherSuites()Get the cipher selector which OpenSSL defines as the default cipher suites for TLSv1.3.private static CipherSuitePredicateparseAndPredicate(CipherSuitePredicate item, org.wildfly.common.iteration.CodePointIterator i)private static CipherSuiteSelectorparseDelete(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i)private static CipherSuiteSelectorparseMoveToEnd(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i)private static CipherSuitePredicateparsePredicate(org.wildfly.common.iteration.CodePointIterator i)private static CipherSuitePredicateparsePredicate(org.wildfly.common.iteration.CodePointIterator i, String word)private static CipherSuiteSelectorparseRemove(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i)private static CipherSuiteSelectorparseSpecial(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i)CipherSuiteSelectorpushToEnd(String cipherSuiteName)A convenience method to push a cipher suite by name to the end of the enabled ciphers list.CipherSuiteSelectorpushToEnd(CipherSuitePredicate predicate)Push all cipher suites which are matched by the given predicate to the end of the enabled ciphers list.CipherSuiteSelectorremove(String cipherSuiteName)A convenience method to remove a cipher suite by name.CipherSuiteSelectorremove(CipherSuitePredicate predicate)Remove all cipher suites which are matched by the given predicate.CipherSuiteSelectorsortByAlgorithmKeyLength()Sort all of the enabled ciphers by decreasing key length.StringtoString()(package private) abstract voidtoString(StringBuilder b)
 
- 
- 
- 
Field Detail- 
prevfinal CipherSuiteSelector prev 
 - 
EMPTYprivate static final CipherSuiteSelector EMPTY 
 - 
TLS13_EMPTYprivate static final CipherSuiteSelector TLS13_EMPTY 
 - 
OPENSSL_DEFAULT_CIPHER_SUITE_NAMESpublic static final String OPENSSL_DEFAULT_CIPHER_SUITE_NAMES OpenSSL default cipher suites for TLSv1.3.- See Also:
- Constant Field Values
 
 - 
OPENSSL_ALLstatic final CipherSuiteSelector OPENSSL_ALL 
 - 
OPENSSL_DEFAULTstatic final CipherSuiteSelector OPENSSL_DEFAULT 
 - 
OPENSSL_DEFAULT_CIPHER_SUITESstatic final CipherSuiteSelector OPENSSL_DEFAULT_CIPHER_SUITES 
 - 
OPENSSL_COMBINED_DEFAULTstatic final CipherSuiteSelector OPENSSL_COMBINED_DEFAULT 
 
- 
 - 
Constructor Detail- 
CipherSuiteSelectorCipherSuiteSelector(CipherSuiteSelector prev) 
 
- 
 - 
Method Detail- 
emptypublic static CipherSuiteSelector empty() Get the basic empty SSL cipher suite selector.- Returns:
- the empty selector
 
 - 
emptypublic static CipherSuiteSelector empty(boolean useTLS13) Get the basic empty SSL cipher suite selector.- Parameters:
- useTLS13-- trueif the TLSv1.3 mechanism database should be used by this selector and- falseotherwise
- Returns:
- the empty selector
 
 - 
openSslDefaultpublic static CipherSuiteSelector openSslDefault() Get the cipher selector which OpenSSL defines asDEFAULT.- Returns:
- the selector
- See Also:
- CipherSuitePredicate.matchOpenSslDefaultDeletes()
 
 - 
openSslAllpublic static CipherSuiteSelector openSslAll() Get the cipher selector which OpenSSL defines asALL.- Returns:
- the selector
- See Also:
- CipherSuitePredicate.matchOpenSslAll()
 
 - 
openSslDefaultCipherSuitespublic static CipherSuiteSelector openSslDefaultCipherSuites() Get the cipher selector which OpenSSL defines as the default cipher suites for TLSv1.3.- Returns:
- the selector
 
 - 
openSslCombinedDefaultpublic static CipherSuiteSelector openSslCombinedDefault() Get the cipher selector which OpenSSL defines asDEFAULTcombined with the cipher suites which OpenSSL defines as the default cipher suites for TLSv1.3.- Returns:
- the selector
 
 - 
deleteFullypublic CipherSuiteSelector deleteFully(CipherSuitePredicate predicate) Permanently delete all cipher suites which are matched by the given predicate. Matching ciphers cannot be re-added by a later rule (such rules will be ignored).- Parameters:
- predicate- the predicate to match
- Returns:
- a new selector which includes the new rule
 
 - 
deleteFullypublic CipherSuiteSelector deleteFully(String cipherSuiteName) A convenience method to permanently delete a cipher suite by name. This is a shortcut for callingdeleteFully(Predicate.matchName(cipherSuiteName)). The cipher suite name must be a standard or OpenSSL-style mechanism name identifying a single mechanism.- Parameters:
- cipherSuiteName- the cipher suite name
- Returns:
- a new selector which includes the new rule
 
 - 
removepublic CipherSuiteSelector remove(CipherSuitePredicate predicate) Remove all cipher suites which are matched by the given predicate. Matching ciphers may be re-added by a later rule.- Parameters:
- predicate- the predicate to match
- Returns:
- a new selector which includes the new rule
 
 - 
removepublic CipherSuiteSelector remove(String cipherSuiteName) A convenience method to remove a cipher suite by name. This is a shortcut for callingremove(Predicate.matchName(cipherSuiteName)). The cipher suite name must be a standard or OpenSSL-style mechanism name identifying a single mechanism.- Parameters:
- cipherSuiteName- the cipher suite name
- Returns:
- a new selector which includes the new rule
 
 - 
addpublic CipherSuiteSelector add(CipherSuitePredicate predicate) Add all cipher suites which are matched by the given predicate. The cipher suites are added in a reasonably logical order. Any suites which are not supported by the underlying socket layer will not be added.- Parameters:
- predicate- the predicate to match
- Returns:
- a new selector which includes the new rule
 
 - 
addpublic CipherSuiteSelector add(String cipherSuiteName) A convenience method to add a cipher suite by name. If the underlying socket layer does not support the named cipher suite, or if the cipher suite is invalid, it will not be added. This is a shortcut for callingadd(Predicate.matchName(cipherSuiteName)). The cipher suite name must be a standard or OpenSSL-style mechanism name identifying a single mechanism.- Parameters:
- cipherSuiteName- the cipher suite name
- Returns:
- a new selector which includes the new rule
 
 - 
pushToEndpublic CipherSuiteSelector pushToEnd(CipherSuitePredicate predicate) Push all cipher suites which are matched by the given predicate to the end of the enabled ciphers list. Only cipher suites which are already enabled will be moved; no cipher suites are added by this transformation.- Parameters:
- predicate- the predicate to match
- Returns:
- a new selector which includes the new rule
 
 - 
pushToEndpublic CipherSuiteSelector pushToEnd(String cipherSuiteName) A convenience method to push a cipher suite by name to the end of the enabled ciphers list. This is a shortcut for callingpushToEnd(Predicate.matchName(cipherSuiteName)). In particular, no cipher suites are added by this transformation. The cipher suite name must be a standard or OpenSSL-style mechanism name identifying a single mechanism.- Parameters:
- cipherSuiteName- the cipher suite name
- Returns:
- a new selector which includes the new rule
 
 - 
sortByAlgorithmKeyLengthpublic CipherSuiteSelector sortByAlgorithmKeyLength() Sort all of the enabled ciphers by decreasing key length. Only the ciphers which were added by previous rules will be sorted.- Returns:
- a new selector which includes the sort
 
 - 
toStringabstract void toString(StringBuilder b) 
 - 
applyFilterabstract void applyFilter(Set<String> enabled, Map<MechanismDatabase.Entry,String> supported) 
 - 
doEvaluateprivate void doEvaluate(Set<String> enabled, Map<MechanismDatabase.Entry,String> supported) 
 - 
getMechanismDatabaseMechanismDatabase getMechanismDatabase() 
 - 
evaluatepublic String[] evaluate(String[] supportedMechanisms) Evaluate this selector against the given list of JSSE supported mechanisms.- Parameters:
- supportedMechanisms- the supported mechanisms
- Returns:
- the enabled mechanisms (not null)
 
 - 
fromStringpublic static CipherSuiteSelector fromString(String string) throws IllegalArgumentException Create a cipher suite selector from the given OpenSSL-style cipher list string. The rules of the string are as follows:- Each item is separated from the other items by a colon (":"), though for compatibility, commas (",") or spaces (" ") are allowed delimiters as well.
- The items are evaluated in order from left to right.
- 
         Each item may consist of one of the following:
         - An OpenSSL-style cipher suite name like DH-RSA-AES256-SHA256, which adds the named cipher suite to the end of the list (if it is supported and not already present).
- A standard SSL/TLS cipher suite name like TLS_DH_RSA_WITH_AES_256_CBC_SHA256, which adds the named cipher suite to the end of the list (if it is supported and not already present).
- 
                 Any of the following special keywords:
                 - HIGH, which matches all supported cipher suites with "high" encryption, presently defined as all cipher suites with key lengths larger than 128 bits, and some with key lengths of exactly 128 bits (see- SecurityLevel.HIGH).
- MEDIUM, which matches all supported cipher suites with "medium" encryption, presently defined as some cipher suites with 128 bit keys (see- SecurityLevel.MEDIUM).
- LOW, which matches all supported cipher suites with "low" encryption, presently defined as cipher suites which use 64- or 56-bit encryption but excluding export cipher suites (see- SecurityLevel.LOW).
- EXPor- EXPORT, which matches supported cipher suites using export algorithms, presently defined as cipher suites which include those that use 56- or 40-bit encryption algorithms (see- SecurityLevel.EXP40and- SecurityLevel.EXP56) .
- EXPORT40, which matches supported cipher suites using export algorithms with 40-bit encryption (see- SecurityLevel.EXP40).
- EXPORT56, which matches supported cipher suites using export algorithms with 56-bit encryption (see- SecurityLevel.EXP56).
- eNULLor- NULL, which matches supported cipher suites without encryption (see- Encryption.NULL).
- aNULL, which matches supported cipher suites without authentication (i.e. they are anonymous) (see- Authentication.NULL).
- kRSA, which matches supported cipher suites using RSA key exchange (see- KeyAgreement.RSA).
- aRSA, which matches supported cipher suites using RSA authentication (see- Authentication.RSA).
- RSA, which matches supported cipher suites using either RSA key exchange or RSA authentication.
- kDHr, which matches supported cipher suites using DH key agreement with DH certificates signed with a RSA key (see- KeyAgreement.DHr).
- kDHd, which matches supported cipher suites using DH key agreement with DH certificates signed with a DSS key (see- KeyAgreement.DHd).
- kDH, which matches any supported cipher suite using DH key agreement.
- kDHEor- kEDH, which matches supported cipher suites using ephemeral DH key agreement (including anonymous cipher suites; see- KeyAgreement.DHE).
- DHEor- EDH, which matches supported cipher suites using non-anonymous ephemeral DH key agreement.
- ADH, which matches supported cipher suites using anonymous DH, not including anonymous elliptic curve suites.
- DH, which matches any supported cipher suite using DH.
- kECDHr, which matches supported cipher suites using fixed ECDH key agreement signed using RSA keys (see- KeyAgreement.ECDHr).
- kECDHe, which matches supported cipher suites using fixed ECDH key agreement signed by ECDSA keys (see- KeyAgreement.ECDHe).
- kECDH, which matches supported cipher suites using fixed ECDH key agreement.
- kEECDHor- kECDHE, which matches supported cipher suites using ephemeral ECDH key agreement (including anonymous cipher suites; see- KeyAgreement.ECDHE).
- ECDHEor- EECDHE, which matches supported cipher suites using authenticated (non-anonymous) ephemeral ECDH key agreement.
- AECDH, which matches supported cipher suites using anonymous ephemeral ECDH key agreement.
- ECDH, which matches all supported cipher suites using ECDH key agreement.
- aDSSor- DSS, which matches supported cipher suites using DSS authentication (see- Authentication.DSS).
- aDH, which matches supported cipher suites using DH authentication (see- Authentication.DH).
- aECDH, which matches supported cipher suites using ECDH authentication (see- Authentication.ECDH).
- aECDSAor- ECDSA, which matches supported cipher suites using ECDSA authentication (see- Authentication.ECDSA).
- kFZA, which matches supported cipher suites using Fortezza key agreement (see- KeyAgreement.FZA).
- aFZA, which matches supported cipher suites using Fortezza authentication (see- Authentication.FZA).
- eFZA, which matches supported cipher suites using Fortezza encryption (see- Encryption.FZA).
- FZA, which matches all supported cipher suites using any Fortezza algorithm.
- TLSv1.2, which matches supported cipher suites defined in TLS v1.2 (see- Protocol.TLSv1_2).
- TLSv1, which matches supported cipher suites defined in TLS v1 (see- Protocol.TLSv1).
- SSLv3, which matches supported cipher suites defined in SSL v3.0 (see- Protocol.SSLv3).
- SSLv2, which matches supported cipher suites defined in SSL v2.0 (see- Protocol.SSLv2).
- AES256, which matches supported cipher suites using 256-bit AES (see- Encryption.AES256).
- AES128, which matches supported cipher suites using 128-bit AES (see- Encryption.AES128).
- AES, which matches all supported cipher suites using AES.
- AESGCM, which matches supported cipher suites using AES in Galois Counter Mode (GCM) (see- Encryption.AES256GCMand- Encryption.AES128GCM).
- CAMELLIA256, which matches supported cipher suites using 256-bit Camellia encryption (see- Encryption.CAMELLIA256).
- CAMELLIA128, which matches supported cipher suites using 128-bit Camellia encryption (see- Encryption.CAMELLIA128).
- CAMELLIA, which matches all supported cipher suites using any Camellia encryption.
- 3DES, which matches supported cipher suites using triple DES encryption (see- Encryption._3DES).
- DES, which matches supported cipher suites using plain DES encryption (see- Encryption.DES).
- RC4, which matches supported cipher suites using RC4 encryption (see- Encryption.RC4).
- RC2, which matches supported cipher suites using RC2 encryption (see- Encryption.RC2).
- IDEA, which matches supported cipher suites using IDEA encryption (see- Encryption.IDEA).
- SEED, which matches supported cipher suites using SEED encryption (see- Encryption.SEED).
- MD5, which matches supported cipher suites using the MD5 digest algorithm (see- Digest.MD5).
- SHA1or- SHA, which matches supported cipher suites using the SHA-1 digest algorithm (see- Digest.SHA1).
- SHA256, which matches supported cipher suites using the SHA-256 digest algorithm (see- Digest.SHA256).
- SHA384, which matches supported cipher suites using the SHA-384 digest algorithm (see- Digest.SHA384).
- aGOST, which matches supported cipher suites using GOST authentication.
- aGOST01, which matches supported cipher suites using GOST R 34.10-2001 authentication (see- Authentication.GOST01).
- aGOST94, which matches supported cipher suites using GOST R 34.10-94 authentication (see- Authentication.GOST94).
- kGOST, which matches supported cipher suites using VKO 34.10 key exchange (see- KeyAgreement.GOST).
- GOST94, which matches supported cipher suites using GOST R 34.11-94 based HMAC (see- Digest.GOST94).
- GOST89MAC, which matches supported cipher suites using GOST 28147-89 based MAC (not HMAC) (see- Digest.GOST89MAC).
- kPSK, which matches supported cipher suites using pre-shared keys key agreement (see- KeyAgreement.PSK).
- aPSK, which matches supported cipher suites using pre-shared keys authentication (see- Authentication.PSK).
- PSK, which matches supported cipher suites using pre-shared keys (see- Authentication.PSKand- KeyAgreement.PSK).
- RSAPSKor- kRSAPSK, which matches supported cipher suites using RSA-based pre-shared keys (see- KeyAgreement.RSAPSK).
- kEDHPSK,- kDHEPSK,- EDHPSKor- DHEPSK, which matches supported cipher suites using ephemeral DH-based pre-shared keys (see- KeyAgreement.DHEPSK).
- kEECDHPSK,- EECDHPSK,- kECDHEPSKor- ECDHEPSK, which matches supported cipher suites using ephemeral elliptic-curve DH-based pre-shared keys (see- KeyAgreement.ECDHEPSK).
 
- More than one of any of the above keywords or cipher suite names joined by +symbols, which indicates that all of the items must be matched (i.e. a logical "and" operation).
- The special unary !operator followed by any of the above keywords or cipher names, which removes the matching cipher suite(s) from the enabled list and also deletes it from the supported list, preventing any matching cipher suites from being re-added by a later rule.
- The special unary -operator followed by any of the above keywords or cipher names, which removes the matching cipher suite(s) from the enabled list (though they may still be re-added).
- The special unary +operator followed by any of the above keywords or cipher names, which causes any of the matching cipher suite(s) to be moved to the end of the list of enabled cipher suites.
- The special ALLkeyword, which includes all cipher suites (except for encryptionless suites; in other words, this keyword implies-eNULL).
- The special COMPLEMENTOFALLkeyword, which is presently equivalent toeNULL.
- The special DEFAULTkeyword, which is equivalent toALL:!EXPORT:!LOW:!aNULL:!eNULL:!SSLv2.
- The special COMPLEMENTOFDEFAULTkeyword, which presently includes any anonymous cipher suites (but excludes those without encryption, which must always be enabled manually).
- The special @STRENGTHkeyword, which causes all the mechanisms enabled thus far to be automatically sorted by encryption algorithm key length in descending order.
 
- An OpenSSL-style cipher suite name like 
 - Parameters:
- string- the string to parse
- Returns:
- the parsed cipher suite selector
- Throws:
- IllegalArgumentException- if the given string is not valid
 
 - 
fromNamesStringpublic static CipherSuiteSelector fromNamesString(String names) throws IllegalArgumentException Create a cipher suite selector from the given OpenSSL-style TLSv1.3 cipher suites string. The format for this string is a simple colon (":") separated list of TLSv1.3 cipher suite names.- Parameters:
- names- the string to parse
- Returns:
- the parsed cipher suite selector
- Throws:
- IllegalArgumentException- if the given string is not valid
 
 - 
aggregatepublic static CipherSuiteSelector aggregate(CipherSuiteSelector cipherSuiteSelector1, CipherSuiteSelector cipherSuiteSelector2) Create an aggregateCipherSuiteSelector. Each cipher suite selector is executed in order.- Parameters:
- cipherSuiteSelector1- the first cipher suite selector
- cipherSuiteSelector2- the second cipher suite selector
- Returns:
- the aggregate cipher suite selector (not null)
 
 - 
parseMoveToEndprivate static CipherSuiteSelector parseMoveToEnd(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i) 
 - 
parseRemoveprivate static CipherSuiteSelector parseRemove(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i) 
 - 
parseDeleteprivate static CipherSuiteSelector parseDelete(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i) 
 - 
parseSpecialprivate static CipherSuiteSelector parseSpecial(CipherSuiteSelector current, org.wildfly.common.iteration.CodePointIterator i) 
 - 
parsePredicateprivate static CipherSuitePredicate parsePredicate(org.wildfly.common.iteration.CodePointIterator i) 
 - 
parsePredicateprivate static CipherSuitePredicate parsePredicate(org.wildfly.common.iteration.CodePointIterator i, String word) 
 - 
parseAndPredicateprivate static CipherSuitePredicate parseAndPredicate(CipherSuitePredicate item, org.wildfly.common.iteration.CodePointIterator i) 
 - 
getSimplePredicateByNameprivate static CipherSuitePredicate getSimplePredicateByName(String word) 
 
- 
 
-