/** * Return a predicate which matches a cipher suite with the given name. The cipher suite name must be a * standard or OpenSSL-style mechanism name identifying a single mechanism. * * @return the predicate */ public static CipherSuitePredicate matchName(final String name) { return name == null ? matchFalse() : new CipherSuitePredicate() { void toString(final StringBuilder b) { b.append("cipher name is \"").append(name).append("\""); } boolean test(final MechanismDatabase.Entry entry) { return entry.getOpenSslNames().contains(name) || entry.getAliases().contains(name) || entry.getName().equals(name); } }; }
/** * Return a predicate which matches the given protocol. * * @param protocol the protocol * @return the predicate */ public static CipherSuitePredicate matchProtocol(Protocol protocol) { return protocol == null ? matchFalse() : new ProtocolCipherSuitePredicate(EnumSet.of(protocol)); }
/** * Return a predicate which matches the given encryption scheme. * * @param encryption the encryption scheme * @return the predicate */ public static CipherSuitePredicate matchEncryption(Encryption encryption) { return encryption == null ? matchFalse() : new EncryptionCipherSuitePredicate(EnumSet.of(encryption)); }
/** * Return a predicate which matches the given security level. * * @param level the security level * @return the predicate */ public static CipherSuitePredicate matchLevel(SecurityLevel level) { return level == null ? matchFalse() : new LevelCipherSuitePredicate(EnumSet.of(level)); }
/** * Return a predicate which matches the given key exchange scheme. * * @param keyAgreement the key exchange scheme * @return the predicate */ public static CipherSuitePredicate matchKeyAgreement(KeyAgreement keyAgreement) { return keyAgreement == null ? matchFalse() : new KeyAgreementCipherSuitePredicate(EnumSet.of(keyAgreement)); }
/** * Return a predicate which matches the given digest scheme. * * @param digest the digest scheme * @return the predicate */ public static CipherSuitePredicate matchDigest(Digest digest) { return digest == null ? matchFalse() : new DigestCipherSuitePredicate(EnumSet.of(digest)); }
/** * Return a predicate which matches the given authentication scheme. * * @param authentication the authentication scheme * @return the predicate */ public static CipherSuitePredicate matchAuthentication(Authentication authentication) { return authentication == null ? matchFalse() : new AuthenticationCipherSuitePredicate(true, EnumSet.of(authentication)); }
/** * Return a predicate which matches any of the given encryption schemes. * * @param encryptions the encryption schemes * @return the predicate */ public static CipherSuitePredicate matchEncryption(Encryption... encryptions) { encryptions = withoutNulls(encryptions); return encryptions == null || encryptions.length == 0 ? matchFalse() : encryptions.length == Encryption.fullSize ? matchTrue() : new EncryptionCipherSuitePredicate(EnumSet.of(encryptions[0], encryptions)); }
/** * Return a predicate which matches any of the given digest schemes. * * @param digests the digest schemes * @return the predicate */ public static CipherSuitePredicate matchDigest(Digest... digests) { digests = withoutNulls(digests); return digests == null || digests.length == 0 ? matchFalse() : digests.length == Digest.fullSize ? matchTrue() : new DigestCipherSuitePredicate(EnumSet.of(digests[0], digests)); }
/** * Return a predicate which matches any of the given protocols. * * @param protocols the protocols * @return the predicate */ public static CipherSuitePredicate matchProtocol(EnumSet<Protocol> protocols) { return protocols == null || protocols.isEmpty() ? matchFalse() : Protocol.isFull(protocols) ? matchTrue() : new ProtocolCipherSuitePredicate(protocols); }
/** * Return a predicate which matches any of the given security levels. * * @param levels the security levels * @return the predicate */ public static CipherSuitePredicate matchLevel(EnumSet<SecurityLevel> levels) { return levels == null || levels.isEmpty() ? matchFalse() : SecurityLevel.isFull(levels) ? matchTrue() : new LevelCipherSuitePredicate(levels); }
/** * Return a predicate which matches any of the given authentication schemes. * * @param authentications the authentication schemes * @return the predicate */ public static CipherSuitePredicate matchAuthentication(Authentication... authentications) { authentications = withoutNulls(authentications); return authentications == null || authentications.length == 0 ? matchFalse() : authentications.length == Authentication.fullSize ? matchTrue() : new AuthenticationCipherSuitePredicate(true, EnumSet.of(authentications[0], authentications)); }
/** * Return a predicate which matches any of the given protocols. * * @param protocols the protocols * @return the predicate */ public static CipherSuitePredicate matchProtocol(Protocol... protocols) { protocols = withoutNulls(protocols); return protocols == null || protocols.length == 0 ? matchFalse() : protocols.length == Protocol.fullSize ? matchTrue() : new ProtocolCipherSuitePredicate(EnumSet.of(protocols[0], protocols)); }
/** * Return a predicate which matches any of the given key exchange schemes. * * @param keyAgreements the key exchange schemes * @return the predicate */ public static CipherSuitePredicate matchKeyExchange(KeyAgreement... keyAgreements) { keyAgreements = withoutNulls(keyAgreements); return keyAgreements == null || keyAgreements.length == 0 ? matchFalse() : keyAgreements.length == KeyAgreement.fullSize ? matchTrue() : new KeyAgreementCipherSuitePredicate(EnumSet.of(keyAgreements[0], keyAgreements)); }
/** * Return a predicate which matches any of the given key exchange schemes. * * @param keyAgreements the key exchange schemes * @return the predicate */ public static CipherSuitePredicate matchKeyExchange(EnumSet<KeyAgreement> keyAgreements) { return keyAgreements == null || keyAgreements.isEmpty() ? matchFalse() : KeyAgreement.isFull(keyAgreements) ? matchTrue() : new KeyAgreementCipherSuitePredicate(keyAgreements); }
/** * Return a predicate which matches any of the given security levels. * * @param levels the security levels * @return the predicate */ public static CipherSuitePredicate matchLevel(SecurityLevel... levels) { levels = withoutNulls(levels); return levels == null || levels.length == 0 ? matchFalse() : levels.length == SecurityLevel.fullSize ? matchTrue() : new LevelCipherSuitePredicate(EnumSet.of(levels[0], levels)); }
/** * Return a predicate which matches any of the given encryption schemes. * * @param encryptions the encryption schemes * @return the predicate */ public static CipherSuitePredicate matchEncryption(EnumSet<Encryption> encryptions) { return encryptions == null || encryptions.isEmpty() ? matchFalse() : Encryption.isFull(encryptions) ? matchTrue() : new EncryptionCipherSuitePredicate(encryptions); }
/** * Return a predicate which matches any of the given digest schemes. * * @param digests the digest schemes * @return the predicate */ public static CipherSuitePredicate matchDigest(EnumSet<Digest> digests) { return digests == null || digests.isEmpty() ? matchFalse() : Digest.isFull(digests) ? matchTrue() : new DigestCipherSuitePredicate(digests); }
/** * Return a predicate which matches any of the given authentication schemes. * * @param authentications the authentication schemes * @return the predicate */ public static CipherSuitePredicate matchAuthentication(EnumSet<Authentication> authentications) { return authentications == null || authentications.isEmpty() ? matchFalse() : Authentication.isFull(authentications) ? matchTrue() : optimize(new AuthenticationCipherSuitePredicate(true, authentications)); }
static CipherSuitePredicate optimize(CipherSuitePredicate predicate) { return predicate.isAlwaysFalse() ? matchFalse() : predicate.isAlwaysTrue() ? matchTrue() : predicate; }