Search in sources :

Example 1 with HashCodeBuilder

use of org.apache.commons.lang3.builder.HashCodeBuilder in project cas by apereo.

the class DefaultHandlerResult method hashCode.

@Override
public int hashCode() {
    final HashCodeBuilder builder = new HashCodeBuilder(109, 31);
    builder.append(this.handlerName);
    builder.append(this.credentialMetaData);
    builder.append(this.principal);
    builder.append(this.warnings);
    return builder.toHashCode();
}
Also used : HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder)

Example 2 with HashCodeBuilder

use of org.apache.commons.lang3.builder.HashCodeBuilder in project cas by apereo.

the class DefaultMessageDescriptor method hashCode.

@Override
public int hashCode() {
    final HashCodeBuilder builder = new HashCodeBuilder(99, 31);
    builder.append(this.code);
    builder.append(this.defaultMessage);
    builder.append(this.params);
    return builder.toHashCode();
}
Also used : HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder)

Example 3 with HashCodeBuilder

use of org.apache.commons.lang3.builder.HashCodeBuilder in project cas by apereo.

the class ImmutableAssertion method hashCode.

@Override
public int hashCode() {
    final HashCodeBuilder builder = new HashCodeBuilder(15, 11);
    builder.append(this.primaryAuthentication);
    builder.append(this.chainedAuthentications);
    builder.append(this.service);
    builder.append(this.fromNewLogin);
    return builder.toHashCode();
}
Also used : HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder)

Example 4 with HashCodeBuilder

use of org.apache.commons.lang3.builder.HashCodeBuilder in project OpenAttestation by OpenAttestation.

the class ArrayCertificateRepository method hashCode.

/**
     * Calculates the hash code based on the order and contents of the 
     * certificates in the repository. Two Array Certficate Repository objects
     * are considered equal if they have the same certificates in the same
     * order. 
     * We might relax the order requirement in the future.
     * The hash code is only calculated once, after that it is cached and
     * reused. This assumes the repository will not be modified outside
     * of this object, and since it's presented as a read-only repository that is not likely
     * to happen.
     * @return 
     */
@Override
public int hashCode() {
    // use cached value when possible
    if (hashCode != null) {
        return hashCode;
    }
    HashCodeBuilder builder = new HashCodeBuilder(11, 31);
    if (keystore != null) {
        for (int i = 0; i < keystore.length; i++) {
            try {
                builder.append(keystore[i].getEncoded());
            } catch (Exception e) {
                builder.append(e.toString());
            }
        }
    }
    hashCode = builder.toHashCode();
    return hashCode;
}
Also used : HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder)

Example 5 with HashCodeBuilder

use of org.apache.commons.lang3.builder.HashCodeBuilder in project OpenAttestation by OpenAttestation.

the class KeystoreCertificateRepository method hashCode.

/**
     * Calculates the hash code based on the order and contents of the 
     * certificates in the repository. Two Array Certficate Repository objects
     * are considered equal if they have the same certificates in the same
     * order. 
     * We might relax the order requirement in the future.
     * The hash code is only calculated once, after that it is cached and
     * reused. This assumes the repository will not be modified outside
     * of this object, and since it's presented as a read-only repository that is not likely
     * to happen.
     * @return 
     */
@Override
public int hashCode() {
    // use cached value when possible
    if (hashCode != null) {
        return hashCode;
    }
    HashCodeBuilder builder = new HashCodeBuilder(11, 37);
    if (keystore != null) {
        List<X509Certificate> certificates = getCertificates();
        Collections.sort(certificates, new X509CertificateComparator());
        for (X509Certificate certificate : certificates) {
            try {
                builder.append(certificate.getEncoded());
            } catch (Exception e) {
                builder.append(e.toString());
            }
        }
    }
    hashCode = builder.toHashCode();
    return hashCode;
}
Also used : HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder) X509Certificate(java.security.cert.X509Certificate) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) KeyStoreException(java.security.KeyStoreException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)70 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1