Top Description Fields Constructors Methods
org.conscrypt

public final Class CertificatePriorityComparator

extends Object
implements Comparator<X509Certificate>
Class Inheritance
All Implemented Interfaces
java.util.Comparator
Annotations
@Internal
Imports
java.security.PublicKey, java.security.cert.X509Certificate, java.security.interfaces.ECPublicKey, .RSAPublicKey, java.util.Comparator, .Date, .HashMap, .Map

Comparator for prioritizing certificates in path building.

The sort order is as follows:

  1. Self-issued certificates first.
  2. Strength of certificates descending (EC before RSA, key size descending, signature algorithm strength descending).
  3. notAfter date descending.
  4. notBefore date descending.

Field Summary

Modifier and TypeField and Description
private static final Map<String, Integer>
ALGORITHM_OID_PRIORITY_MAP

Map of signature algorithm OIDs to priorities.

private static final Integer
private static final Integer
private static final Integer
private static final Integer
private static final Integer
private static final Integer
private static final Integer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(X509Certificate
the first object to be compared.
lhs
,
X509Certificate
the second object to be compared.
rhs
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
private int
private int
private int
private int
private int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALGORITHM_OID_PRIORITY_MAPback to summary
private static final Map<String, Integer> ALGORITHM_OID_PRIORITY_MAP

Map of signature algorithm OIDs to priorities. OIDs with a lower priority will be sorted before those with higher.

PRIORITY_MD5back to summary
private static final Integer PRIORITY_MD5
PRIORITY_SHA1back to summary
private static final Integer PRIORITY_SHA1
PRIORITY_SHA224back to summary
private static final Integer PRIORITY_SHA224
PRIORITY_SHA256back to summary
private static final Integer PRIORITY_SHA256
PRIORITY_SHA384back to summary
private static final Integer PRIORITY_SHA384
PRIORITY_SHA512back to summary
private static final Integer PRIORITY_SHA512
PRIORITY_UNKNOWNback to summary
private static final Integer PRIORITY_UNKNOWN

Constructor Detail

CertificatePriorityComparatorback to summary
public CertificatePriorityComparator()

Method Detail

compareback to summary
public int compare(X509Certificate lhs, X509Certificate rhs)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
lhs:X509Certificate

the first object to be compared.

rhs:X509Certificate

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
compareKeyAlgorithmback to summary
private int compareKeyAlgorithm(PublicKey lhs, PublicKey rhs)
compareKeySizeback to summary
private int compareKeySize(PublicKey lhs, PublicKey rhs)
compareSignatureAlgorithmback to summary
private int compareSignatureAlgorithm(X509Certificate lhs, X509Certificate rhs)
compareStrengthback to summary
private int compareStrength(X509Certificate lhs, X509Certificate rhs)
getKeySizeback to summary
private int getKeySize(PublicKey pkey)