8311170: Simplify and modernize equals and hashCode in security area
Reviewed-by: djelinski, rriggs, valeriep
This commit is contained in:
parent
e9f751ab16
commit
19ae62ae2c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,7 @@ import java.lang.ref.Reference;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.KeyRep;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
|
||||
@ -108,26 +109,24 @@ final class DESKey implements SecretKey {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
for (int i = 1; i < this.key.length; i++) {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
return(retval ^= "des".hashCode());
|
||||
return Arrays.hashCode(this.key) ^ "des".hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof SecretKey))
|
||||
if (!(obj instanceof SecretKey that))
|
||||
return false;
|
||||
|
||||
String thatAlg = ((SecretKey)obj).getAlgorithm();
|
||||
String thatAlg = that.getAlgorithm();
|
||||
if (!(thatAlg.equalsIgnoreCase("DES")))
|
||||
return false;
|
||||
|
||||
byte[] thatKey = ((SecretKey)obj).getEncoded();
|
||||
byte[] thatKey = that.getEncoded();
|
||||
boolean ret = MessageDigest.isEqual(this.key, thatKey);
|
||||
java.util.Arrays.fill(thatKey, (byte)0x00);
|
||||
return ret;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,7 @@ import java.lang.ref.Reference;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.KeyRep;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.DESedeKeySpec;
|
||||
|
||||
@ -107,27 +108,25 @@ final class DESedeKey implements SecretKey {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
for (int i = 1; i < this.key.length; i++) {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
return(retval ^= "desede".hashCode());
|
||||
return Arrays.hashCode(this.key) ^ "desede".hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof SecretKey))
|
||||
if (!(obj instanceof SecretKey that))
|
||||
return false;
|
||||
|
||||
String thatAlg = ((SecretKey)obj).getAlgorithm();
|
||||
String thatAlg = that.getAlgorithm();
|
||||
if (!(thatAlg.equalsIgnoreCase("DESede"))
|
||||
&& !(thatAlg.equalsIgnoreCase("TripleDES")))
|
||||
return false;
|
||||
|
||||
byte[] thatKey = ((SecretKey)obj).getEncoded();
|
||||
byte[] thatKey = that.getEncoded();
|
||||
boolean ret = MessageDigest.isEqual(this.key, thatKey);
|
||||
java.util.Arrays.fill(thatKey, (byte)0x00);
|
||||
return ret;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -287,18 +287,18 @@ final class DHPrivateKey implements PrivateKey,
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, p, g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
if (!(obj instanceof javax.crypto.interfaces.DHPrivateKey)) {
|
||||
if (!(obj instanceof javax.crypto.interfaces.DHPrivateKey other)) {
|
||||
return false;
|
||||
}
|
||||
javax.crypto.interfaces.DHPrivateKey other =
|
||||
(javax.crypto.interfaces.DHPrivateKey) obj;
|
||||
DHParameterSpec otherParams = other.getParams();
|
||||
return ((this.x.compareTo(other.getX()) == 0) &&
|
||||
(this.p.compareTo(otherParams.getP()) == 0) &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -279,19 +279,19 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(y, p, g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
if (!(obj instanceof javax.crypto.interfaces.DHPublicKey)) {
|
||||
if (!(obj instanceof javax.crypto.interfaces.DHPublicKey other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
javax.crypto.interfaces.DHPublicKey other =
|
||||
(javax.crypto.interfaces.DHPublicKey) obj;
|
||||
DHParameterSpec otherParams = other.getParams();
|
||||
return ((this.y.compareTo(other.getY()) == 0) &&
|
||||
(this.p.compareTo(otherParams.getP()) == 0) &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -105,23 +105,20 @@ final class PBEKey implements SecretKey {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
for (int i = 1; i < this.key.length; i++) {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode());
|
||||
return Arrays.hashCode(this.key)
|
||||
^ getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof SecretKey))
|
||||
if (!(obj instanceof SecretKey that))
|
||||
return false;
|
||||
|
||||
SecretKey that = (SecretKey)obj;
|
||||
|
||||
if (!(that.getAlgorithm().equalsIgnoreCase(type)))
|
||||
return false;
|
||||
|
||||
|
@ -165,7 +165,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (this.getClass() != obj.getClass()) return false;
|
||||
if (obj == null || this.getClass() != obj.getClass()) return false;
|
||||
SecretKey sk = (SecretKey)obj;
|
||||
return prf.getAlgorithm().equalsIgnoreCase(
|
||||
sk.getAlgorithm()) &&
|
||||
@ -247,32 +247,28 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
try {
|
||||
int retval = 0;
|
||||
for (int i = 1; i < this.key.length; i++) {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
return (retval ^= getAlgorithm().toLowerCase
|
||||
(Locale.ENGLISH).hashCode());
|
||||
return Arrays.hashCode(this.key)
|
||||
^ getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
} finally {
|
||||
// prevent this from being cleaned for the above block
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
try {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof SecretKey)) {
|
||||
if (!(obj instanceof SecretKey that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SecretKey that = (SecretKey) obj;
|
||||
|
||||
if (!(that.getAlgorithm().equalsIgnoreCase(getAlgorithm()))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -764,6 +764,7 @@ public final class AccessControlContext {
|
||||
* and has the same set of {@code ProtectionDomain} objects as this context,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
@ -940,22 +941,20 @@ public final class AccessControlContext {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this context. The hash code
|
||||
* is computed by exclusive or-ing the hash code of all the protection
|
||||
* domains in the context together.
|
||||
*
|
||||
* @return a hash code value for this context.
|
||||
* {@return the hash code value for this context}
|
||||
* The hash code is computed by exclusive or-ing the hash code of all the
|
||||
* protection domains in the context together.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
|
||||
if (context == null)
|
||||
return hashCode;
|
||||
|
||||
for (int i =0; i < context.length; i++) {
|
||||
if (context[i] != null)
|
||||
hashCode ^= context[i].hashCode();
|
||||
for (ProtectionDomain protectionDomain : context) {
|
||||
if (protectionDomain != null)
|
||||
hashCode ^= protectionDomain.hashCode();
|
||||
}
|
||||
|
||||
return hashCode;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -98,16 +98,15 @@ public final class AllPermission extends Permission {
|
||||
* @param obj the object we are testing for equality with this object.
|
||||
* @return true if {@code obj} is an {@code AllPermission}, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof AllPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -217,12 +217,10 @@ public abstract class BasicPermission extends Permission
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
* The hash code used is the hash code of the name, that is,
|
||||
* {@code getName().hashCode()}, where {@code getName} is
|
||||
* from the {@code Permission} superclass.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@ package java.security;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.cert.CertPath;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class encapsulates information about a code signer.
|
||||
@ -98,19 +99,14 @@ public final class CodeSigner implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this code signer.
|
||||
* {@return the hash code value for this code signer}
|
||||
* The hash code is generated using the signer's certificate path and the
|
||||
* timestamp, if present.
|
||||
*
|
||||
* @return a hash code value for this code signer.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myhash == -1) {
|
||||
if (timestamp == null) {
|
||||
myhash = signerCertPath.hashCode();
|
||||
} else {
|
||||
myhash = signerCertPath.hashCode() + timestamp.hashCode();
|
||||
}
|
||||
myhash = signerCertPath.hashCode() + Objects.hashCode(timestamp);
|
||||
}
|
||||
return myhash;
|
||||
}
|
||||
@ -126,25 +122,15 @@ public final class CodeSigner implements Serializable {
|
||||
* @return {@code true} if the objects are considered equal,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ((!(obj instanceof CodeSigner that))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this == that) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
Timestamp thatTimestamp = that.getTimestamp();
|
||||
if (timestamp == null) {
|
||||
if (thatTimestamp != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ((!timestamp.equals(thatTimestamp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return signerCertPath.equals(that.getSignerCertPath());
|
||||
|
||||
return obj instanceof CodeSigner other
|
||||
&& Objects.equals(timestamp, other.getTimestamp())
|
||||
&& signerCertPath.equals(other.getSignerCertPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -130,16 +130,11 @@ public class CodeSource implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (location != null)
|
||||
return location.hashCode();
|
||||
else
|
||||
return 0;
|
||||
return Objects.hashCode(location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -336,6 +336,7 @@ public abstract class Identity implements Principal, Serializable {
|
||||
*
|
||||
* @see #identityEquals
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(Object identity) {
|
||||
if (identity == this) {
|
||||
return true;
|
||||
@ -478,10 +479,9 @@ public abstract class Identity implements Principal, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this {@code Identity}.
|
||||
*
|
||||
* @return a hashcode for this {@code Identity}.
|
||||
* {@return the hashcode for this {@code Identity}}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -196,17 +196,13 @@ public final class PKCS12Attribute implements KeyStore.Entry.Attribute {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof PKCS12Attribute)) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.equals(encoded, ((PKCS12Attribute) obj).encoded);
|
||||
return obj instanceof PKCS12Attribute other
|
||||
&& Arrays.equals(encoded, other.encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashcode for this {@code PKCS12Attribute}.
|
||||
* {@return the hashcode for this {@code PKCS12Attribute}}
|
||||
* The hash code is computed from its DER encoding.
|
||||
*
|
||||
* @return the hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -138,7 +138,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
|
||||
*
|
||||
* @return {@code true} if both {@code Permission} objects are equivalent.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
@ -161,7 +161,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,6 +50,7 @@ public interface Principal {
|
||||
* @return {@code true} if the {@code Principal} passed in is the same as
|
||||
* that encapsulated by this {@code Principal}, and {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object another);
|
||||
|
||||
/**
|
||||
@ -60,10 +61,9 @@ public interface Principal {
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this {@code Principal}.
|
||||
*
|
||||
* @return a hashcode for this {@code Principal}.
|
||||
* {@return a hashcode for this {@code Principal}}
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -240,8 +240,7 @@ public class SecureClassLoader extends ClassLoader {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
String locationNoFrag = cs.getLocationNoFragString();
|
||||
return locationNoFrag != null ? locationNoFrag.hashCode() : 0;
|
||||
return Objects.hashCode(cs.getLocationNoFragString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,6 +35,7 @@ import java.util.Hashtable;
|
||||
import java.lang.reflect.*;
|
||||
import java.security.cert.*;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The {@code UnresolvedPermission} class is used to hold Permissions that
|
||||
@ -349,23 +350,13 @@ implements java.io.Serializable
|
||||
}
|
||||
|
||||
// check name
|
||||
if (this.name == null) {
|
||||
if (that.name != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.name.equals(that.name)) {
|
||||
if (!Objects.equals(this.name, that.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check actions
|
||||
if (this.actions == null) {
|
||||
if (that.actions != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!this.actions.equals(that.actions)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.actions, that.actions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check certs
|
||||
@ -404,18 +395,11 @@ implements java.io.Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = type.hashCode();
|
||||
if (name != null)
|
||||
hash ^= name.hashCode();
|
||||
if (actions != null)
|
||||
hash ^= actions.hashCode();
|
||||
return hash;
|
||||
return Objects.hash(type, name, actions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -177,19 +177,20 @@ public abstract class CertPath implements Serializable {
|
||||
* @return true if the specified object is equal to this certification path,
|
||||
* false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
return other instanceof CertPath that
|
||||
&& that.getType().equals(this.type)
|
||||
&& this.type.equals(that.getType())
|
||||
&& this.getCertificates().equals(that.getCertificates());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashcode for this certification path. The hash code of
|
||||
* a certification path is defined to be the result of the following
|
||||
* calculation:
|
||||
* {@return the hashcode value for this certification path}
|
||||
* The hash code of a certification path is defined to be the result of
|
||||
* the following calculation:
|
||||
* <pre>{@code
|
||||
* hashCode = path.getType().hashCode();
|
||||
* hashCode = 31*hashCode + path.getCertificates().hashCode();
|
||||
@ -198,9 +199,8 @@ public abstract class CertPath implements Serializable {
|
||||
* {@code path1.hashCode()==path2.hashCode()} for any two certification
|
||||
* paths, {@code path1} and {@code path2}, as required by the
|
||||
* general contract of {@code Object.hashCode}.
|
||||
*
|
||||
* @return the hashcode value for this certification path
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = type.hashCode();
|
||||
hashCode = 31*hashCode + getCertificates().hashCode();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -104,6 +104,7 @@ public abstract class Certificate implements java.io.Serializable {
|
||||
* @return true iff the encoded forms of the two certificates
|
||||
* match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
@ -122,11 +123,10 @@ public abstract class Certificate implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this certificate from its
|
||||
* encoded form.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return the hashcode value for this certificate from its
|
||||
* encoded form}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = hash;
|
||||
if (h == -1) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -100,10 +100,8 @@ public final class URICertStoreParameters implements CertStoreParameters {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this parameters object.
|
||||
* {@return a hash code value for this parameters object}
|
||||
* The hash code is generated using the URI supplied at construction.
|
||||
*
|
||||
* @return a hash code value for this parameters object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -127,6 +127,7 @@ public abstract class X509CRL extends CRL implements X509Extension {
|
||||
* @return true iff the encoded forms of the two CRLs
|
||||
* match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
@ -145,19 +146,15 @@ public abstract class X509CRL extends CRL implements X509Extension {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this CRL from its
|
||||
* encoded form.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this CRL from its
|
||||
* encoded form}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
try {
|
||||
byte[] crlData = X509CRLImpl.getEncodedInternal(this);
|
||||
for (int i = 1; i < crlData.length; i++) {
|
||||
retval += crlData[i] * i;
|
||||
}
|
||||
return retval;
|
||||
return Arrays.hashCode(crlData);
|
||||
} catch (CRLException e) {
|
||||
return retval;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@
|
||||
package java.security.cert;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
@ -83,6 +84,7 @@ public abstract class X509CRLEntry implements X509Extension {
|
||||
* @return true iff the encoded forms of the two CRL entries
|
||||
* match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
@ -92,34 +94,23 @@ public abstract class X509CRLEntry implements X509Extension {
|
||||
byte[] thisCRLEntry = this.getEncoded();
|
||||
byte[] otherCRLEntry = ((X509CRLEntry)other).getEncoded();
|
||||
|
||||
if (thisCRLEntry.length != otherCRLEntry.length)
|
||||
return false;
|
||||
for (int i = 0; i < thisCRLEntry.length; i++)
|
||||
if (thisCRLEntry[i] != otherCRLEntry[i])
|
||||
return false;
|
||||
return Arrays.equals(thisCRLEntry, otherCRLEntry);
|
||||
} catch (CRLException ce) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this CRL entry from its
|
||||
* encoded form.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return the hashcode value for this CRL entry from its
|
||||
* encoded form}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
try {
|
||||
byte[] entryData = this.getEncoded();
|
||||
for (int i = 1; i < entryData.length; i++)
|
||||
retval += entryData[i] * i;
|
||||
|
||||
return Arrays.hashCode(this.getEncoded());
|
||||
} catch (CRLException ce) {
|
||||
return(retval);
|
||||
return 0;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@ package java.security.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This immutable class defines an elliptic curve (EC)
|
||||
@ -215,6 +216,7 @@ public class ECFieldF2m implements ECField {
|
||||
* of ECFieldF2m and both {@code m} and the reduction
|
||||
* polynomial match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
@ -226,15 +228,12 @@ public class ECFieldF2m implements ECField {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this characteristic 2
|
||||
* finite field.
|
||||
* @return a hash code value.
|
||||
* {@return the hash code value for this characteristic 2 finite field}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int value = m << 5;
|
||||
value += (rp==null? 0:rp.hashCode());
|
||||
// no need to involve ks here since ks and rp
|
||||
// should be equivalent.
|
||||
return value;
|
||||
return m << 5 + Objects.hashCode(rp);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -79,6 +79,7 @@ public class ECFieldFp implements ECField {
|
||||
* @return true if {@code obj} is an instance
|
||||
* of ECFieldFp and the prime value match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
@ -87,9 +88,9 @@ public class ECFieldFp implements ECField {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this prime finite field.
|
||||
* @return a hash code value.
|
||||
* {@return a hash code value for this prime finite field}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return p.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,6 +93,7 @@ public class ECPoint {
|
||||
* @return true if {@code obj} is an instance of
|
||||
* ECPoint and the affine coordinates match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (this == POINT_INFINITY) return false;
|
||||
@ -103,9 +104,9 @@ public class ECPoint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this elliptic curve point.
|
||||
* @return a hash code value.
|
||||
* {@return the hash code value for this elliptic curve point}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this == POINT_INFINITY) return 0;
|
||||
return x.hashCode() << 5 + y.hashCode();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -76,16 +76,15 @@ final class CryptoAllPermission extends CryptoPermission {
|
||||
* @return {@code true} if <i>obj</i> is a
|
||||
* {@code CryptoAllPermission} object.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@ import java.security.*;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.crypto.spec.*;
|
||||
@ -252,6 +253,7 @@ class CryptoPermission extends java.security.Permission {
|
||||
* @param obj the object to test for equality with this object.
|
||||
* @return {@code true} if {@code obj} is equal to this object.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
@ -266,29 +268,20 @@ class CryptoPermission extends java.security.Permission {
|
||||
if (this.checkParam != that.checkParam) {
|
||||
return false;
|
||||
}
|
||||
return (equalObjects(this.exemptionMechanism,
|
||||
that.exemptionMechanism) &&
|
||||
equalObjects(this.algParamSpec,
|
||||
that.algParamSpec));
|
||||
return Objects.equals(this.exemptionMechanism, that.exemptionMechanism)
|
||||
&& Objects.equals(this.algParamSpec, that.algParamSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = alg.hashCode();
|
||||
retval ^= maxKeySize;
|
||||
if (exemptionMechanism != null) {
|
||||
retval ^= exemptionMechanism.hashCode();
|
||||
}
|
||||
if (checkParam) retval ^= 100;
|
||||
if (algParamSpec != null) {
|
||||
retval ^= algParamSpec.hashCode();
|
||||
}
|
||||
return retval;
|
||||
return alg.hashCode()
|
||||
^ maxKeySize
|
||||
^ Objects.hashCode(exemptionMechanism)
|
||||
^ (checkParam ? 100 : 0)
|
||||
^ Objects.hashCode(algParamSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,14 +430,6 @@ class CryptoPermission extends java.security.Permission {
|
||||
return !this.checkParam;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean equalObjects(Object obj1, Object obj2) {
|
||||
if (obj1 == null) {
|
||||
return (obj2 == null);
|
||||
}
|
||||
|
||||
return obj1.equals(obj2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,7 @@ import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
import static java.util.Locale.ENGLISH;
|
||||
|
||||
@ -616,20 +617,17 @@ final class CryptoPolicyParser {
|
||||
* Calculates a hash code value for the object. Objects
|
||||
* which are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = cryptoPermission.hashCode();
|
||||
if (alg != null) retval ^= alg.hashCode();
|
||||
if (exemptionMechanism != null) {
|
||||
retval ^= exemptionMechanism.hashCode();
|
||||
}
|
||||
retval ^= maxKeySize;
|
||||
if (checkParam) retval ^= 100;
|
||||
if (algParamSpec != null) {
|
||||
retval ^= algParamSpec.hashCode();
|
||||
}
|
||||
return retval;
|
||||
return cryptoPermission.hashCode()
|
||||
^ Objects.hashCode(alg)
|
||||
^ Objects.hashCode(exemptionMechanism)
|
||||
^ maxKeySize
|
||||
^ (checkParam ? 100 : 0)
|
||||
^ Objects.hashCode(algParamSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
@ -637,12 +635,8 @@ final class CryptoPolicyParser {
|
||||
if (!(obj instanceof CryptoPermissionEntry that))
|
||||
return false;
|
||||
|
||||
if (this.cryptoPermission == null) {
|
||||
if (that.cryptoPermission != null) return false;
|
||||
} else {
|
||||
if (!this.cryptoPermission.equals(
|
||||
that.cryptoPermission))
|
||||
return false;
|
||||
if (!Objects.equals(this.cryptoPermission, that.cryptoPermission)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.alg == null) {
|
||||
@ -652,15 +646,11 @@ final class CryptoPolicyParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(this.maxKeySize == that.maxKeySize)) return false;
|
||||
if (this.maxKeySize != that.maxKeySize) return false;
|
||||
|
||||
if (this.checkParam != that.checkParam) return false;
|
||||
|
||||
if (this.algParamSpec == null) {
|
||||
return that.algParamSpec == null;
|
||||
} else {
|
||||
return this.algParamSpec.equals(that.algParamSpec);
|
||||
}
|
||||
return Objects.equals(this.algParamSpec, that.algParamSpec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@
|
||||
package javax.crypto.spec;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class specifies the parameters used with the
|
||||
@ -131,6 +132,7 @@ public class RC2ParameterSpec implements AlgorithmParameterSpec {
|
||||
* @return true if the objects are considered equal, false if
|
||||
* {@code obj} is null or otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
@ -140,20 +142,15 @@ public class RC2ParameterSpec implements AlgorithmParameterSpec {
|
||||
}
|
||||
|
||||
return ((effectiveKeyBits == other.effectiveKeyBits) &&
|
||||
java.util.Arrays.equals(iv, other.iv));
|
||||
Arrays.equals(iv, other.iv));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
if (iv != null) {
|
||||
for (int i = 1; i < iv.length; i++) {
|
||||
retval += iv[i] * i;
|
||||
}
|
||||
}
|
||||
return retval + effectiveKeyBits;
|
||||
return Arrays.hashCode(iv) + effectiveKeyBits;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@
|
||||
package javax.crypto.spec;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class specifies the parameters used with the
|
||||
@ -176,6 +177,7 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec {
|
||||
* @return true if the objects are considered equal, false if
|
||||
* {@code obj} is null or otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
@ -187,21 +189,15 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec {
|
||||
return ((version == other.version) &&
|
||||
(rounds == other.rounds) &&
|
||||
(wordSize == other.wordSize) &&
|
||||
java.util.Arrays.equals(iv, other.iv));
|
||||
Arrays.equals(iv, other.iv));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
if (iv != null) {
|
||||
for (int i = 1; i < iv.length; i++) {
|
||||
retval += iv[i] * i;
|
||||
}
|
||||
}
|
||||
retval += (version + rounds + wordSize);
|
||||
return retval;
|
||||
return Arrays.hashCode(iv) + version + rounds + wordSize;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -198,11 +198,9 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
for (int i = 1; i < this.key.length; i++) {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
int retval = Arrays.hashCode(key);
|
||||
if (this.algorithm.equalsIgnoreCase("TripleDES"))
|
||||
return retval ^ "desede".hashCode();
|
||||
else
|
||||
@ -220,14 +218,15 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
||||
* @return true if the objects are considered equal, false if
|
||||
* <code>obj</code> is null or otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof SecretKey))
|
||||
if (!(obj instanceof SecretKey that))
|
||||
return false;
|
||||
|
||||
String thatAlg = ((SecretKey)obj).getAlgorithm();
|
||||
String thatAlg = that.getAlgorithm();
|
||||
if (!(thatAlg.equalsIgnoreCase(this.algorithm))) {
|
||||
if ((!(thatAlg.equalsIgnoreCase("DESede"))
|
||||
|| !(this.algorithm.equalsIgnoreCase("TripleDES")))
|
||||
@ -236,7 +235,7 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] thatKey = ((SecretKey)obj).getEncoded();
|
||||
byte[] thatKey = that.getEncoded();
|
||||
try {
|
||||
return MessageDigest.isEqual(this.key, thatKey);
|
||||
} finally {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -260,6 +260,7 @@ public final class PrivateCredentialPermission extends Permission {
|
||||
* has the same credential class as this object,
|
||||
* and has the same Principals as this object.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
@ -271,10 +272,9 @@ public final class PrivateCredentialPermission extends Permission {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.credentialClass.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -907,10 +907,6 @@ public final class Subject implements java.io.Serializable {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
@ -1003,9 +999,7 @@ public final class Subject implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this {@code Subject}.
|
||||
*
|
||||
* @return a hashcode for this {@code Subject}.
|
||||
* {@return a hashcode for this {@code Subject}}
|
||||
*
|
||||
* @throws SecurityException if a security manager is installed and the
|
||||
* caller does not have a {@link PrivateCredentialPermission}
|
||||
@ -1486,6 +1480,7 @@ public final class Subject implements java.io.Serializable {
|
||||
return elements.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
@ -1507,14 +1502,11 @@ public final class Subject implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = 0;
|
||||
Iterator<E> i = iterator();
|
||||
while (i.hasNext()) {
|
||||
E obj = i.next();
|
||||
if (obj != null) {
|
||||
h += obj.hashCode();
|
||||
}
|
||||
for (E obj : this) {
|
||||
h += Objects.hashCode(obj);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
@ -457,6 +457,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
||||
* @return {@code true} if the specified {@code Object} is equal
|
||||
* to this {@code X500Principal}, {@code false} otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
@ -468,13 +469,12 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hash code for this {@code X500Principal}.
|
||||
* {@return a hash code for this {@code X500Principal}}
|
||||
*
|
||||
* <p> The hash code is calculated via:
|
||||
* {@code getName(X500Principal.CANONICAL).hashCode()}
|
||||
*
|
||||
* @return a hash code for this {@code X500Principal}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return thisX500Name.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.SignatureException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>Abstract class for managing a variety of identity certificates.
|
||||
@ -72,51 +73,38 @@ public abstract class Certificate {
|
||||
|
||||
/**
|
||||
* Compares this certificate for equality with the specified
|
||||
* object. If the {@code other} object is an
|
||||
* object. If the {@code obj} object is an
|
||||
* {@code instanceof} {@code Certificate}, then
|
||||
* its encoded form is retrieved and compared with the
|
||||
* encoded form of this certificate.
|
||||
*
|
||||
* @param other the object to test for equality with this certificate.
|
||||
* @param obj the object to test for equality with this certificate.
|
||||
* @return true if the encoded forms of the two certificates
|
||||
* match, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(other instanceof Certificate))
|
||||
if (!(obj instanceof Certificate other))
|
||||
return false;
|
||||
try {
|
||||
byte[] thisCert = this.getEncoded();
|
||||
byte[] otherCert = ((Certificate)other).getEncoded();
|
||||
|
||||
if (thisCert.length != otherCert.length)
|
||||
return false;
|
||||
for (int i = 0; i < thisCert.length; i++)
|
||||
if (thisCert[i] != otherCert[i])
|
||||
return false;
|
||||
return true;
|
||||
return Arrays.equals(this.getEncoded(), other.getEncoded());
|
||||
} catch (CertificateException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this certificate from its
|
||||
* encoded form.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this certificate from
|
||||
* its encoded form}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
try {
|
||||
byte[] certData = this.getEncoded();
|
||||
for (int i = 1; i < certData.length; i++) {
|
||||
retval += certData[i] * i;
|
||||
}
|
||||
return (retval);
|
||||
return Arrays.hashCode(this.getEncoded());
|
||||
} catch (CertificateException e) {
|
||||
return (retval);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ final class ProviderConfig {
|
||||
return (provider != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -144,8 +145,9 @@ final class ProviderConfig {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return provName.hashCode() + argument.hashCode();
|
||||
return Objects.hash(provName, argument);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@
|
||||
package sun.security.pkcs;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sun.security.x509.*;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.DerOutputStream;
|
||||
@ -134,33 +136,20 @@ public class EncryptedPrivateKeyInfo {
|
||||
return this.encoded.clone();
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (!(other instanceof EncryptedPrivateKeyInfo))
|
||||
return false;
|
||||
byte[] thisEncrInfo = this.getEncoded();
|
||||
byte[] otherEncrInfo
|
||||
= ((EncryptedPrivateKeyInfo) other).getEncoded();
|
||||
|
||||
if (thisEncrInfo.length != otherEncrInfo.length)
|
||||
return false;
|
||||
for (int i = 0; i < thisEncrInfo.length; i++)
|
||||
if (thisEncrInfo[i] != otherEncrInfo[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return obj instanceof EncryptedPrivateKeyInfo other
|
||||
&& Arrays.equals(this.getEncoded(), other.getEncoded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this EncryptedPrivateKeyInfo.
|
||||
*
|
||||
* @return a hashcode for this EncryptedPrivateKeyInfo.
|
||||
* {@return a hashcode for this EncryptedPrivateKeyInfo}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
|
||||
for (int i = 0; i < this.encryptedData.length; i++)
|
||||
retval += this.encryptedData[i] * i;
|
||||
return retval;
|
||||
return Arrays.hashCode(encryptedData);
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +259,7 @@ public class PKCS8Key implements PrivateKey, InternalPrivateKey {
|
||||
* @return {@code true} if this key has the same encoding as the
|
||||
* object argument; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
@ -288,6 +289,7 @@ public class PKCS8Key implements PrivateKey, InternalPrivateKey {
|
||||
* Calculates a hash code value for this object. Objects
|
||||
* which are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(getEncodedInternal());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@ import java.math.BigInteger;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -324,41 +325,37 @@ public class PKCS10 {
|
||||
|
||||
/**
|
||||
* Compares this object for equality with the specified
|
||||
* object. If the <code>other</code> object is an
|
||||
* object. If the <code>obj</code> object is an
|
||||
* <code>instanceof</code> <code>PKCS10</code>, then
|
||||
* its encoded form is retrieved and compared with the
|
||||
* encoded form of this certificate request.
|
||||
*
|
||||
* @param other the object to test for equality with this object.
|
||||
* @param obj the object to test for equality with this object.
|
||||
* @return true iff the encoded forms of the two certificate
|
||||
* requests match, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(other instanceof PKCS10))
|
||||
if (!(obj instanceof PKCS10 other))
|
||||
return false;
|
||||
if (encoded == null) // not signed yet
|
||||
return false;
|
||||
byte[] otherEncoded = ((PKCS10)other).getEncoded();
|
||||
byte[] otherEncoded = other.getEncoded();
|
||||
if (otherEncoded == null)
|
||||
return false;
|
||||
|
||||
return java.util.Arrays.equals(encoded, otherEncoded);
|
||||
return Arrays.equals(encoded, otherEncoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this certificate request from its
|
||||
* encoded form.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return the hashcode value for this certificate request from its
|
||||
* encoded form}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
if (encoded != null)
|
||||
for (int i = 1; i < encoded.length; i++)
|
||||
retval += encoded[i] * i;
|
||||
return(retval);
|
||||
return Arrays.hashCode(encoded);
|
||||
}
|
||||
|
||||
private X500Name subject;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -153,6 +153,7 @@ public class PKCS10Attributes implements DerEncoder {
|
||||
* @return true if all the entries match that of the Other,
|
||||
* false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
@ -166,26 +167,24 @@ public class PKCS10Attributes implements DerEncoder {
|
||||
int len = attrs.length;
|
||||
if (len != map.size())
|
||||
return false;
|
||||
PKCS10Attribute thisAttr, otherAttr;
|
||||
PKCS10Attribute thisAttr;
|
||||
String key;
|
||||
for (int i=0; i < len; i++) {
|
||||
otherAttr = attrs[i];
|
||||
for (PKCS10Attribute otherAttr : attrs) {
|
||||
key = otherAttr.getAttributeId().toString();
|
||||
|
||||
thisAttr = map.get(key);
|
||||
if (thisAttr == null)
|
||||
return false;
|
||||
if (! thisAttr.equals(otherAttr))
|
||||
if (!thisAttr.equals(otherAttr))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this PKCS10Attributes.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return the hashcode value for this PKCS10Attributes}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return map.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -2129,17 +2129,11 @@ public class PolicyFile extends java.security.Policy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override public int hashCode() {
|
||||
int hash = type.hashCode();
|
||||
if (name != null)
|
||||
hash ^= name.hashCode();
|
||||
if (actions != null)
|
||||
hash ^= actions.hashCode();
|
||||
return hash;
|
||||
return type.hashCode() ^ Objects.hashCode(name)
|
||||
^ Objects.hashCode(actions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1058,9 +1058,7 @@ public class PolicyParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hashcode for this PrincipalEntry.
|
||||
*
|
||||
* @return a hashcode for this PrincipalEntry
|
||||
* {@return a hashcode for this PrincipalEntry}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@ -1119,10 +1117,7 @@ public class PolicyParser {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = permission.hashCode();
|
||||
if (name != null) retval ^= name.hashCode();
|
||||
if (action != null) retval ^= action.hashCode();
|
||||
return retval;
|
||||
return Objects.hash(permission, name, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1130,32 +1125,11 @@ public class PolicyParser {
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (! (obj instanceof PermissionEntry that))
|
||||
return false;
|
||||
|
||||
if (this.permission == null) {
|
||||
if (that.permission != null) return false;
|
||||
} else {
|
||||
if (!this.permission.equals(that.permission)) return false;
|
||||
}
|
||||
|
||||
if (this.name == null) {
|
||||
if (that.name != null) return false;
|
||||
} else {
|
||||
if (!this.name.equals(that.name)) return false;
|
||||
}
|
||||
|
||||
if (this.action == null) {
|
||||
if (that.action != null) return false;
|
||||
} else {
|
||||
if (!this.action.equals(that.action)) return false;
|
||||
}
|
||||
|
||||
if (this.signedBy == null) {
|
||||
return that.signedBy == null;
|
||||
} else {
|
||||
return this.signedBy.equals(that.signedBy);
|
||||
}
|
||||
return obj instanceof PermissionEntry that
|
||||
&& Objects.equals(this.permission, that.permission)
|
||||
&& Objects.equals(this.name, that.name)
|
||||
&& Objects.equals(this.action, that.action)
|
||||
&& Objects.equals(this.signedBy, that.signedBy);
|
||||
}
|
||||
|
||||
public void write(PrintWriter out) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -172,19 +172,13 @@ public class CertId implements DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this CertId.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this CertId}
|
||||
*/
|
||||
@Override public int hashCode() {
|
||||
if (myhash == -1) {
|
||||
myhash = hashAlgId.hashCode();
|
||||
for (int i = 0; i < issuerNameHash.length; i++) {
|
||||
myhash += issuerNameHash[i] * i;
|
||||
}
|
||||
for (int i = 0; i < issuerKeyHash.length; i++) {
|
||||
myhash += issuerKeyHash[i] * i;
|
||||
}
|
||||
myhash += Arrays.hashCode(issuerNameHash);
|
||||
myhash += Arrays.hashCode(issuerKeyHash);
|
||||
myhash += certSerialNumber.getNumber().hashCode();
|
||||
}
|
||||
return myhash;
|
||||
|
@ -226,25 +226,16 @@ public final class ResponderId {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof ResponderId respObj) {
|
||||
return Arrays.equals(encodedRid, respObj.getEncoded());
|
||||
}
|
||||
|
||||
return false;
|
||||
return obj instanceof ResponderId respObj
|
||||
&& Arrays.equals(encodedRid, respObj.getEncoded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this {@code ResponderId}
|
||||
*
|
||||
* @return the hash code value for this {@code ResponderId}
|
||||
* {@return the hash code value for this {@code ResponderId}}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -985,7 +985,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashcode for this session
|
||||
* {@return the hashcode for this session}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@ -1002,12 +1002,9 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof SSLSessionImpl sess) {
|
||||
return (sessionId != null) && (sessionId.equals(
|
||||
sess.getSessionId()));
|
||||
}
|
||||
|
||||
return false;
|
||||
return obj instanceof SSLSessionImpl other
|
||||
&& sessionId != null
|
||||
&& sessionId.equals(other.getSessionId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -5315,13 +5315,15 @@ class Pair<A, B> {
|
||||
return "Pair[" + fst + "," + snd + "]";
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return
|
||||
other instanceof Pair &&
|
||||
Objects.equals(fst, ((Pair)other).fst) &&
|
||||
Objects.equals(snd, ((Pair)other).snd);
|
||||
obj instanceof Pair<?, ?> other &&
|
||||
Objects.equals(fst, other.fst) &&
|
||||
Objects.equals(snd, other.snd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1;
|
||||
else if (snd == null) return fst.hashCode() + 2;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@
|
||||
package sun.security.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import jdk.internal.util.Preconditions;
|
||||
|
||||
@ -68,7 +69,7 @@ public class BitArray {
|
||||
* Creates a BitArray of the specified size, initialized from the
|
||||
* specified byte array. The most significant bit of {@code a[0]} gets
|
||||
* index zero in the BitArray. The array must be large enough to specify
|
||||
* a value for every bit of the BitArray. i.e. {@code 8*a.length <= length}.
|
||||
* a value for every bit of the BitArray, i.e. {@code 8*a.length >= length}.
|
||||
*/
|
||||
public BitArray(int length, byte[] a) throws IllegalArgumentException {
|
||||
this(length, a, 0);
|
||||
@ -79,7 +80,7 @@ public class BitArray {
|
||||
* specified byte array starting at the specified offset. The most
|
||||
* significant bit of {@code a[ofs]} gets index zero in the BitArray.
|
||||
* The array must be large enough to specify a value for every bit of
|
||||
* the BitArray, i.e. {@code 8*(a.length - ofs) <= length}.
|
||||
* the BitArray, i.e. {@code 8*(a.length - ofs) >= length}.
|
||||
*/
|
||||
public BitArray(int length, byte[] a, int ofs)
|
||||
throws IllegalArgumentException {
|
||||
@ -177,16 +178,13 @@ public class BitArray {
|
||||
return repn.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof BitArray ba)) return false;
|
||||
|
||||
if (ba.length != length) return false;
|
||||
|
||||
for (int i = 0; i < repn.length; i += 1) {
|
||||
if (repn[i] != ba.repn[i]) return false;
|
||||
}
|
||||
return true;
|
||||
return obj instanceof BitArray other
|
||||
&& length == other.length
|
||||
&& Arrays.equals(repn, other.repn);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,17 +200,11 @@ public class BitArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this bit array.
|
||||
*
|
||||
* @return a hash code value for this bit array.
|
||||
* {@return a hash code value for this bit array}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
|
||||
for (int i = 0; i < repn.length; i++)
|
||||
hashCode = 31*hashCode + repn[i];
|
||||
|
||||
return hashCode ^ length;
|
||||
return Arrays.hashCode(repn) ^ length;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1261,9 +1261,7 @@ public class DerValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this DerValue.
|
||||
*
|
||||
* @return a hashcode for this DerValue.
|
||||
* {@return a hashcode for this DerValue}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -596,6 +596,7 @@ public class AVA implements DerEncoder {
|
||||
this(in.getDerValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -608,10 +609,9 @@ public class AVA implements DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this AVA.
|
||||
*
|
||||
* @return a hashcode for this AVA.
|
||||
* {@return a hashcode for this AVA}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toRFC2253CanonicalString().hashCode();
|
||||
}
|
||||
|
@ -339,9 +339,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this AlgorithmId.
|
||||
*
|
||||
* @return a hashcode for this AlgorithmId.
|
||||
* {@return a hashcode for this AlgorithmId}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -218,6 +218,7 @@ public class CRLExtensions {
|
||||
* @return true iff all the entries match that of the Other,
|
||||
* false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
@ -242,10 +243,9 @@ public class CRLExtensions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this CRLExtensions.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this CRLExtensions}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return map.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -247,6 +247,7 @@ public class CertificateExtensions implements DerEncoder {
|
||||
* @return true iff all the entries match that of the Other,
|
||||
* false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
@ -272,12 +273,11 @@ public class CertificateExtensions implements DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this CertificateExtensions.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this CertificateExtensions}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return map.hashCode() + getUnparseableExtensions().hashCode();
|
||||
return Objects.hash(map, getUnparseableExtensions());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -92,18 +92,16 @@ public class CertificatePolicyId implements DerEncoder {
|
||||
*
|
||||
* @return true iff the ids are identical.
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof CertificatePolicyId)
|
||||
return id.equals(((CertificatePolicyId) other).getIdentifier());
|
||||
else
|
||||
return false;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CertificatePolicyId other
|
||||
&& id.equals(other.getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this object.
|
||||
*
|
||||
* @return a hash code value
|
||||
* {@return a hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -169,6 +169,7 @@ public class DNSName implements GeneralNameInterface {
|
||||
* @return true iff the names are equivalent
|
||||
* according to RFC5280.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
@ -182,10 +183,9 @@ public class DNSName implements GeneralNameInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.toUpperCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -325,6 +325,7 @@ public class DistributionPoint implements DerEncoder {
|
||||
* @param obj Object to be compared to this
|
||||
* @return true if objects match; false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -339,26 +340,14 @@ public class DistributionPoint implements DerEncoder {
|
||||
&& Arrays.equals(this.reasonFlags, other.reasonFlags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = hashCode;
|
||||
if (hash == 0) {
|
||||
hash = 1;
|
||||
if (fullName != null) {
|
||||
hash += fullName.hashCode();
|
||||
}
|
||||
if (relativeName != null) {
|
||||
hash += relativeName.hashCode();
|
||||
}
|
||||
if (crlIssuer != null) {
|
||||
hash += crlIssuer.hashCode();
|
||||
}
|
||||
if (reasonFlags != null) {
|
||||
for (int i = 0; i < reasonFlags.length; i++) {
|
||||
if (reasonFlags[i]) {
|
||||
hash += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
hash = 1 + Objects.hashCode(fullName)
|
||||
+ Objects.hashCode(relativeName)
|
||||
+ Objects.hash(crlIssuer)
|
||||
+ Arrays.hashCode(reasonFlags);
|
||||
hashCode = hash;
|
||||
}
|
||||
return hash;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -192,6 +192,7 @@ public class DistributionPointName implements DerEncoder {
|
||||
* @param obj Object to be compared to this
|
||||
* @return true if objects match; false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -205,17 +206,15 @@ public class DistributionPointName implements DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this distribution point name.
|
||||
*
|
||||
* @return the hash code.
|
||||
* {@return the hash code for this distribution point name}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = hashCode;
|
||||
if (hash == 0) {
|
||||
hash = 1;
|
||||
if (fullName != null) {
|
||||
hash += fullName.hashCode();
|
||||
|
||||
} else {
|
||||
hash += relativeName.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -170,30 +170,20 @@ public class EDIPartyName implements GeneralNameInterface {
|
||||
*
|
||||
* @return true if the two names match
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof EDIPartyName))
|
||||
return false;
|
||||
String otherAssigner = ((EDIPartyName)other).assigner;
|
||||
if (this.assigner == null) {
|
||||
if (otherAssigner != null)
|
||||
return false;
|
||||
} else {
|
||||
if (!(this.assigner.equals(otherAssigner)))
|
||||
return false;
|
||||
}
|
||||
String otherParty = ((EDIPartyName)other).party;
|
||||
if (this.party == null) {
|
||||
return otherParty == null;
|
||||
} else {
|
||||
return this.party.equals(otherParty);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
return obj instanceof EDIPartyName other
|
||||
&& Objects.equals(this.assigner, other.assigner)
|
||||
&& Objects.equals(this.party, other.party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this EDIPartyName.
|
||||
*
|
||||
* @return a hash code value.
|
||||
* {@return the hash code value for this EDIPartyName}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myhash == -1) {
|
||||
myhash = 37 + (party == null ? 1 : party.hashCode());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -242,20 +242,13 @@ public class Extension implements java.security.cert.Extension, DerEncoder {
|
||||
private static final int hashMagic = 31;
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this Extension.
|
||||
*
|
||||
* @return the hashcode value.
|
||||
* {@return a hashcode value for this Extension}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = 0;
|
||||
if (extensionValue != null) {
|
||||
byte[] val = extensionValue;
|
||||
int len = val.length;
|
||||
while (len > 0)
|
||||
h += len * val[--len];
|
||||
}
|
||||
int h = Arrays.hashCode(extensionValue);
|
||||
h = h * hashMagic + extensionId.hashCode();
|
||||
h = h * hashMagic + (critical?1231:1237);
|
||||
h = h * hashMagic + Boolean.hashCode(critical);
|
||||
return h;
|
||||
}
|
||||
|
||||
@ -271,6 +264,7 @@ public class Extension implements java.security.cert.Extension, DerEncoder {
|
||||
* criticality flag, object identifier and encoded extension value of
|
||||
* the two Extensions match, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -201,28 +201,28 @@ public class GeneralName implements DerEncoder {
|
||||
/**
|
||||
* Compare this GeneralName with another
|
||||
*
|
||||
* @param other GeneralName to compare to this
|
||||
* @param obj GeneralName to compare to this
|
||||
* @return true if match
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof GeneralName))
|
||||
if (!(obj instanceof GeneralName other))
|
||||
return false;
|
||||
GeneralNameInterface otherGNI = ((GeneralName)other).name;
|
||||
try {
|
||||
return name.constrains(otherGNI) == GeneralNameInterface.NAME_MATCH;
|
||||
return name.constrains(other.name)
|
||||
== GeneralNameInterface.NAME_MATCH;
|
||||
} catch (UnsupportedOperationException ioe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this GeneralName.
|
||||
*
|
||||
* @return a hash code value.
|
||||
* {@return the hash code for this GeneralName}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -149,30 +149,24 @@ public class GeneralSubtree implements DerEncoder {
|
||||
/**
|
||||
* Compare this GeneralSubtree with another
|
||||
*
|
||||
* @param other GeneralSubtree to compare to this
|
||||
* @param obj GeneralSubtree to compare to this
|
||||
* @return true if match
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof GeneralSubtree otherGS))
|
||||
return false;
|
||||
if (this.name == null) {
|
||||
if (otherGS.name != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!((this.name).equals(otherGS.name)))
|
||||
return false;
|
||||
}
|
||||
if (this.minimum != otherGS.minimum)
|
||||
return false;
|
||||
return this.maximum == otherGS.maximum;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
return obj instanceof GeneralSubtree other
|
||||
&& Objects.equals(this.name, other.name)
|
||||
&& this.minimum == other.minimum
|
||||
&& this.maximum == other.maximum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this GeneralSubtree.
|
||||
*
|
||||
* @return a hash code value.
|
||||
* {@return the hash code for this GeneralSubtree}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myhash == -1) {
|
||||
myhash = 17;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -310,6 +310,7 @@ public class IPAddressName implements GeneralNameInterface {
|
||||
*
|
||||
* @return true iff the names are identical.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
@ -334,10 +335,8 @@ public class IPAddressName implements GeneralNameInterface {
|
||||
}
|
||||
}
|
||||
// Now compare masks
|
||||
for (int i=maskLen; i < address.length; i++)
|
||||
if (address[i] != other[i])
|
||||
return false;
|
||||
return true;
|
||||
return Arrays.equals(address, maskLen, address.length, other,
|
||||
maskLen, address.length);
|
||||
} else {
|
||||
// Two IPv4 host addresses or two IPv6 host addresses
|
||||
// Compare bytes
|
||||
@ -346,17 +345,11 @@ public class IPAddressName implements GeneralNameInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
|
||||
for (int i=0; i<address.length; i++)
|
||||
retval += address[i] * i;
|
||||
|
||||
return retval;
|
||||
return Arrays.hashCode(address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
@ -133,22 +134,19 @@ public class KeyIdentifier {
|
||||
* Returns a hash code value for this object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode () {
|
||||
int retval = 0;
|
||||
for (int i = 0; i < octetString.length; i++)
|
||||
retval += octetString[i] * i;
|
||||
return retval;
|
||||
return Arrays.hashCode(octetString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether some other object is "equal to" this one.
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(other instanceof KeyIdentifier))
|
||||
return false;
|
||||
byte[] otherString = ((KeyIdentifier)other).octetString;
|
||||
return java.util.Arrays.equals(octetString, otherString);
|
||||
return obj instanceof KeyIdentifier other
|
||||
&& Arrays.equals(octetString, other.octetString);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -111,21 +111,19 @@ public class OIDName implements GeneralNameInterface {
|
||||
*
|
||||
* @return true iff the names are identical
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof OIDName other))
|
||||
return false;
|
||||
|
||||
return oid.equals(other.oid);
|
||||
return obj instanceof OIDName other
|
||||
&& oid.equals(other.oid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -171,6 +171,7 @@ public class OtherName implements GeneralNameInterface {
|
||||
*
|
||||
* @return true iff the names are identical.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
@ -203,16 +204,12 @@ public class OtherName implements GeneralNameInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this OtherName.
|
||||
*
|
||||
* @return a hash code value.
|
||||
* {@return the hash code for this OtherName}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myhash == -1) {
|
||||
myhash = 37 + oid.hashCode();
|
||||
for (int i = 0; i < nameValue.length; i++) {
|
||||
myhash = 37 * myhash + nameValue[i];
|
||||
}
|
||||
myhash = oid.hashCode() + Arrays.hashCode(nameValue);
|
||||
}
|
||||
return myhash;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -122,28 +122,22 @@ public class PolicyInformation implements DerEncoder {
|
||||
/**
|
||||
* Compare this PolicyInformation with another object for equality
|
||||
*
|
||||
* @param other object to be compared with this
|
||||
* @param obj object to be compared with this
|
||||
* @return true iff the PolicyInformation objects match
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof PolicyInformation piOther))
|
||||
return false;
|
||||
|
||||
if (!policyIdentifier.equals(piOther.getPolicyIdentifier()))
|
||||
return false;
|
||||
|
||||
return policyQualifiers.equals(piOther.getPolicyQualifiers());
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PolicyInformation other
|
||||
&& policyIdentifier.equals(other.getPolicyIdentifier())
|
||||
&& policyQualifiers.equals(other.getPolicyQualifiers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this PolicyInformation.
|
||||
*
|
||||
* @return a hash code value.
|
||||
* {@return the hash code for this PolicyInformation}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int myhash = 37 + policyIdentifier.hashCode();
|
||||
myhash = 37 * myhash + policyQualifiers.hashCode();
|
||||
return myhash;
|
||||
return Objects.hash(policyIdentifier, policyQualifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -133,6 +133,7 @@ public class RFC822Name implements GeneralNameInterface
|
||||
* @return true iff the names are equivalent
|
||||
* according to RFC 5280.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
@ -146,10 +147,9 @@ public class RFC822Name implements GeneralNameInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.toUpperCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
@ -215,6 +215,7 @@ public class URIName implements GeneralNameInterface {
|
||||
*
|
||||
* @return true iff the names are equivalent according to RFC 5280.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -275,10 +276,9 @@ public class URIName implements GeneralNameInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return uri.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -395,6 +395,7 @@ public class X500Name implements GeneralNameInterface, Principal {
|
||||
* Calculates a hash code value for the object. Objects
|
||||
* which are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getRFC2253CanonicalName().hashCode();
|
||||
}
|
||||
@ -404,6 +405,7 @@ public class X500Name implements GeneralNameInterface, Principal {
|
||||
*
|
||||
* @return true iff the names are identical.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
|
@ -1296,6 +1296,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
|
||||
* @param o the other object to compare with
|
||||
* @return true if equal, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
@ -1310,16 +1311,13 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this X509IssuerSerial.
|
||||
*
|
||||
* @return the hash code value
|
||||
* {@return a hash code value for this X509IssuerSerial}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = hashcode;
|
||||
if (h == 0) {
|
||||
h = 17;
|
||||
h = 37*h + issuer.hashCode();
|
||||
h = 37*h + serial.hashCode();
|
||||
h = Objects.hash(issuer, serial);
|
||||
if (h != 0) {
|
||||
hashcode = h;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -179,51 +179,27 @@ public class X509CertInfo {
|
||||
* certificates are not both X.509 certs, otherwise it
|
||||
* compares them as binary data.
|
||||
*
|
||||
* @param other the object being compared with this one
|
||||
* @param obj the object being compared with this one
|
||||
* @return true iff the certificates are equivalent
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof X509CertInfo) {
|
||||
return equals((X509CertInfo) other);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two certificates, returning false if any data
|
||||
* differs between the two.
|
||||
*
|
||||
* @param other the object being compared with this one
|
||||
* @return true iff the certificates are equivalent
|
||||
*/
|
||||
public boolean equals(X509CertInfo other) {
|
||||
if (this == other) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
} else if (rawCertInfo == null || other.rawCertInfo == null) {
|
||||
return false;
|
||||
} else if (rawCertInfo.length != other.rawCertInfo.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < rawCertInfo.length; i++) {
|
||||
if (rawCertInfo[i] != other.rawCertInfo[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return obj instanceof X509CertInfo other
|
||||
&& rawCertInfo != null
|
||||
&& other.rawCertInfo != null
|
||||
&& Arrays.equals(rawCertInfo, other.rawCertInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a hash code value for the object. Objects
|
||||
* which are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int retval = 0;
|
||||
|
||||
for (int i = 1; i < rawCertInfo.length; i++) {
|
||||
retval += rawCertInfo[i] * i;
|
||||
}
|
||||
return retval;
|
||||
return Arrays.hashCode(rawCertInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,6 +36,7 @@ import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.util.*;
|
||||
@ -398,6 +399,7 @@ public class X509Key implements PublicKey, DerEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -419,13 +421,9 @@ public class X509Key implements PublicKey, DerEncoder {
|
||||
* Calculates a hash code value for the object. Objects
|
||||
* which are equal will also have the same hashcode.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte[] b1 = getEncodedInternal();
|
||||
int r = b1.length;
|
||||
for (int i = 0; i < b1.length; i++) {
|
||||
r += (b1[i] & 0xff) * 37;
|
||||
}
|
||||
return r;
|
||||
return Arrays.hashCode(getEncodedInternal());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -175,22 +175,17 @@ public final class DelegationPermission extends BasicPermission
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof DelegationPermission that)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.subordinate.equals(that.subordinate) &&
|
||||
this.service.equals(that.service);
|
||||
return obj instanceof DelegationPermission that
|
||||
&& this.subordinate.equals(that.subordinate)
|
||||
&& this.service.equals(that.service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 17 * subordinate.hashCode() + 31 * service.hashCode();
|
||||
return Objects.hash(subordinate, service);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -174,9 +174,7 @@ public final class EncryptionKey implements SecretKey {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code EncryptionKey}.
|
||||
*
|
||||
* @return a hash code for this {@code EncryptionKey}.
|
||||
* {@return a hash code for this {@code EncryptionKey}}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -146,16 +146,14 @@ public final class KerberosCredMessage implements Destroyable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code KerberosCredMessage}.
|
||||
*
|
||||
* @return a hash code for this {@code KerberosCredMessage}.
|
||||
* {@return a hash code for this {@code KerberosCredMessage}}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (isDestroyed()) {
|
||||
return -1;
|
||||
} else {
|
||||
return Objects.hash(sender, recipient, Arrays.hashCode(message));
|
||||
return Arrays.deepHashCode(new Object[]{sender, recipient, message});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@ package javax.security.auth.kerberos;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
|
||||
@ -278,11 +279,10 @@ public class KerberosKey implements SecretKey {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code KerberosKey}.
|
||||
*
|
||||
* @return a hash code for this {@code KerberosKey}.
|
||||
* {@return a hash code for this {@code KerberosKey}}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (isDestroyed()) {
|
||||
@ -308,6 +308,7 @@ public class KerberosKey implements SecretKey {
|
||||
* false otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
||||
if (other == this) {
|
||||
@ -328,10 +329,6 @@ public class KerberosKey implements SecretKey {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (principal == null) {
|
||||
return otherKey.getPrincipal() == null;
|
||||
} else {
|
||||
return principal.equals(otherKey.getPrincipal());
|
||||
}
|
||||
return Objects.equals(principal, otherKey.getPrincipal());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -227,14 +227,13 @@ public final class KerberosPrincipal
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code KerberosPrincipal}. The hash code
|
||||
* is defined to be the result of the following calculation:
|
||||
* {@return a hash code for this {@code KerberosPrincipal}}
|
||||
* The hash code is defined to be the result of the following calculation:
|
||||
* <pre>{@code
|
||||
* hashCode = getName().hashCode();
|
||||
* }</pre>
|
||||
*
|
||||
* @return a hash code for this {@code KerberosPrincipal}.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}
|
||||
@ -247,21 +246,18 @@ public final class KerberosPrincipal
|
||||
* More formally two {@code KerberosPrincipal} instances are equal
|
||||
* if the values returned by {@code getName()} are equal.
|
||||
*
|
||||
* @param other the object to compare to
|
||||
* @param obj the object to compare to
|
||||
* @return true if the object passed in represents the same principal
|
||||
* as this one, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (other == this)
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (! (other instanceof KerberosPrincipal)) {
|
||||
return false;
|
||||
}
|
||||
String myFullName = getName();
|
||||
String otherFullName = ((KerberosPrincipal) other).getName();
|
||||
return myFullName.equals(otherFullName);
|
||||
return obj instanceof KerberosPrincipal other
|
||||
&& getName().equals(other.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -716,11 +716,10 @@ public class KerberosTicket implements Destroyable, Refreshable,
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code KerberosTicket}.
|
||||
*
|
||||
* @return a hash code for this {@code KerberosTicket}.
|
||||
* {@return a hash code for this {@code KerberosTicket}}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
if (isDestroyed()) {
|
||||
@ -768,6 +767,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
|
||||
* false otherwise.
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
||||
if (other == this) {
|
||||
@ -792,39 +792,10 @@ public class KerberosTicket implements Destroyable, Refreshable,
|
||||
return false;
|
||||
}
|
||||
|
||||
// authTime may be null
|
||||
if (authTime == null) {
|
||||
if (otherTicket.getAuthTime() != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!authTime.equals(otherTicket.getAuthTime())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// startTime may be null
|
||||
if (startTime == null) {
|
||||
if (otherTicket.getStartTime() != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!startTime.equals(otherTicket.getStartTime())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (renewTill == null) {
|
||||
if (otherTicket.getRenewTill() != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!renewTill.equals(otherTicket.getRenewTill())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return Objects.equals(proxy, otherTicket.proxy);
|
||||
return Objects.equals(authTime, otherTicket.getAuthTime())
|
||||
&& Objects.equals(startTime, otherTicket.getStartTime())
|
||||
&& Objects.equals(renewTill, otherTicket.getRenewTill())
|
||||
&& Objects.equals(proxy, otherTicket.proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -328,10 +328,9 @@ public final class KeyTab {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this {@code KeyTab}.
|
||||
*
|
||||
* @return a hash code for this {@code KeyTab}.
|
||||
* {@return a hash code for this {@code KeyTab}}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(file, princ, bound);
|
||||
}
|
||||
@ -345,6 +344,7 @@ public final class KeyTab {
|
||||
* @param other the object to compare to
|
||||
* @return true if the specified object is equal to this {@code KeyTab}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this)
|
||||
return true;
|
||||
|
@ -240,9 +240,7 @@ public final class ServicePermission extends Permission
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* {@return the hash code value for this object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -167,6 +167,7 @@ public class ChannelBinding {
|
||||
* the same values for the initiator and acceptor addresses and the
|
||||
* application data.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
@ -193,17 +194,16 @@ public class ChannelBinding {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this ChannelBinding object.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this ChannelBinding object}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (initiator != null)
|
||||
return initiator.hashCode();
|
||||
else if (acceptor != null)
|
||||
return acceptor.hashCode();
|
||||
else if (appData != null)
|
||||
return new String(appData).hashCode();
|
||||
return Arrays.hashCode(appData);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -358,13 +358,13 @@ public interface GSSCredential extends Cloneable{
|
||||
* entity; {@code false} otherwise.
|
||||
* @param another another GSSCredential for comparison to this one
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object another);
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSCredential.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSCredential}
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -198,13 +198,13 @@ public interface GSSName {
|
||||
* @param another the object to compare this name to
|
||||
* @see #equals(GSSName)
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object another);
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSName.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSName}
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -150,11 +150,12 @@ public class Oid {
|
||||
* value, <code>false</code> otherwise.
|
||||
* @param other the Oid object that has to be compared to this one
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
||||
//check if both reference the same object
|
||||
if (this == other)
|
||||
return (true);
|
||||
return true;
|
||||
|
||||
if (other instanceof Oid)
|
||||
return this.oid.equals(((Oid) other).oid);
|
||||
@ -205,10 +206,9 @@ public class Oid {
|
||||
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this Oid.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this Oid}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
}
|
||||
|
@ -476,6 +476,7 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object another) {
|
||||
|
||||
if (destroyed) {
|
||||
@ -512,10 +513,9 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSCredential.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSCredential}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
if (destroyed) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -332,10 +332,9 @@ public final class GSSNameImpl implements GSSName {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSName.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSName}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
/*
|
||||
* XXX
|
||||
@ -350,6 +349,7 @@ public final class GSSNameImpl implements GSSName {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object another) {
|
||||
|
||||
try {
|
||||
|
@ -33,6 +33,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.security.jgss.spi.*;
|
||||
import sun.security.jgss.wrapper.NativeGSSFactory;
|
||||
import sun.security.jgss.wrapper.SunNativeProvider;
|
||||
@ -448,6 +450,7 @@ public final class ProviderList {
|
||||
this.oid = oid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
@ -457,26 +460,13 @@ public final class ProviderList {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.p.getName().equals(that.p.getName())) {
|
||||
if (this.oid != null && that.oid != null) {
|
||||
return this.oid.equals(that.oid);
|
||||
} else {
|
||||
return (this.oid == null && that.oid == null);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return this.p.getName().equals(that.p.getName())
|
||||
&& Objects.equals(this.oid, that.oid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
|
||||
result = 37 * result + p.getName().hashCode();
|
||||
if (oid != null) {
|
||||
result = 37 * result + oid.hashCode();
|
||||
}
|
||||
|
||||
return result;
|
||||
return Objects.hash(p.getName(), oid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -240,6 +240,7 @@ public class Krb5NameElement
|
||||
* @return true if they both refer to the same entity, else false
|
||||
* @see #equals(GSSNameSpi)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object another) {
|
||||
if (this == another) {
|
||||
return true;
|
||||
@ -255,12 +256,11 @@ public class Krb5NameElement
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSNameSpi.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSNameSpi}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 37 * 17 + krb5PrincipalName.getName().hashCode();
|
||||
return krb5PrincipalName.getName().hashCode();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,13 +63,13 @@ public interface GSSNameSpi {
|
||||
* @return true if they both refer to the same entity, else false
|
||||
* @see #equals(GSSNameSpi)
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object another);
|
||||
|
||||
/**
|
||||
* Returns a hashcode value for this GSSNameSpi.
|
||||
*
|
||||
* @return a hashCode value
|
||||
* {@return a hashcode value for this GSSNameSpi}
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,8 @@
|
||||
|
||||
package sun.security.krb5;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.security.krb5.internal.Krb5;
|
||||
import sun.security.krb5.internal.KRBError;
|
||||
|
||||
@ -133,12 +135,7 @@ public class KrbException extends Exception {
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
int result = 17;
|
||||
result = 37 * result + returnCode;
|
||||
if (error != null) {
|
||||
result = 37 * result + error.hashCode();
|
||||
}
|
||||
return result;
|
||||
return Objects.hash(returnCode, error);
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object obj) {
|
||||
@ -146,15 +143,8 @@ public class KrbException extends Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof KrbException)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KrbException other = (KrbException)obj;
|
||||
if (returnCode != other.returnCode) {
|
||||
return false;
|
||||
}
|
||||
return (error == null)?(other.error == null):
|
||||
(error.equals(other.error));
|
||||
return obj instanceof KrbException other
|
||||
&& returnCode == other.returnCode
|
||||
&& Objects.equals(error, other.error);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -209,12 +209,9 @@ public class PrincipalName implements Cloneable {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof PrincipalName) {
|
||||
PrincipalName other = (PrincipalName)o;
|
||||
return nameRealm.equals(other.nameRealm) &&
|
||||
Arrays.equals(nameStrings, other.nameStrings);
|
||||
}
|
||||
return false;
|
||||
return o instanceof PrincipalName other
|
||||
&& nameRealm.equals(other.nameRealm)
|
||||
&& Arrays.equals(nameStrings, other.nameStrings);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -513,6 +510,7 @@ public class PrincipalName implements Cloneable {
|
||||
return temp.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,19 +72,17 @@ public class Realm implements Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Realm)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Realm that = (Realm)obj;
|
||||
return this.realm.equals(that.realm);
|
||||
return obj instanceof Realm that
|
||||
&& this.realm.equals(that.realm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return realm.hashCode();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -78,43 +78,27 @@ public class HostAddress implements Cloneable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hashCode == 0) {
|
||||
int result = 17;
|
||||
result = 37*result + addrType;
|
||||
if (address != null) {
|
||||
for (int i=0; i < address.length; i++) {
|
||||
result = 37*result + address[i];
|
||||
}
|
||||
}
|
||||
hashCode = result;
|
||||
int h = hashCode;
|
||||
if (h == 0) {
|
||||
hashCode = h = (37 * addrType + Arrays.hashCode(address));
|
||||
}
|
||||
return hashCode;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof HostAddress)) {
|
||||
if (!(obj instanceof HostAddress h)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HostAddress h = (HostAddress)obj;
|
||||
if (addrType != h.addrType ||
|
||||
(address != null && h.address == null) ||
|
||||
(address == null && h.address != null))
|
||||
return false;
|
||||
if (address != null && h.address != null) {
|
||||
if (address.length != h.address.length)
|
||||
return false;
|
||||
for (int i = 0; i < address.length; i++)
|
||||
if (address[i] != h.address[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return addrType == h.addrType
|
||||
&& Arrays.equals(address, h.address);
|
||||
}
|
||||
|
||||
private static synchronized InetAddress getLocalInetAddress()
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -130,42 +130,26 @@ public class HostAddresses implements Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hashCode == 0) {
|
||||
int result = 17;
|
||||
if (addresses != null) {
|
||||
for (int i=0; i < addresses.length; i++) {
|
||||
result = 37*result + addresses[i].hashCode();
|
||||
}
|
||||
}
|
||||
hashCode = result;
|
||||
int h = hashCode;
|
||||
if (h == 0) {
|
||||
hashCode = h = Arrays.hashCode(addresses);
|
||||
}
|
||||
return hashCode;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof HostAddresses)) {
|
||||
if (!(obj instanceof HostAddresses addrs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HostAddresses addrs = (HostAddresses)obj;
|
||||
if ((addresses == null && addrs.addresses != null) ||
|
||||
(addresses != null && addrs.addresses == null))
|
||||
return false;
|
||||
if (addresses != null && addrs.addresses != null) {
|
||||
if (addresses.length != addrs.addresses.length)
|
||||
return false;
|
||||
for (int i = 0; i < addresses.length; i++)
|
||||
if (!addresses[i].equals(addrs.addresses[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return Arrays.equals(addresses, addrs.addresses);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,6 +44,8 @@ import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.security.krb5.internal.util.KerberosString;
|
||||
/**
|
||||
* Implements the ASN.1 KRBError type.
|
||||
@ -488,39 +490,34 @@ public class KRBError implements java.io.Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof KRBError)) {
|
||||
if (!(obj instanceof KRBError other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KRBError other = (KRBError)obj;
|
||||
return pvno == other.pvno &&
|
||||
msgType == other.msgType &&
|
||||
isEqual(cTime, other.cTime) &&
|
||||
isEqual(cuSec, other.cuSec) &&
|
||||
isEqual(sTime, other.sTime) &&
|
||||
isEqual(suSec, other.suSec) &&
|
||||
errorCode == other.errorCode &&
|
||||
isEqual(crealm, other.crealm) &&
|
||||
isEqual(cname, other.cname) &&
|
||||
isEqual(sname, other.sname) &&
|
||||
isEqual(eText, other.eText) &&
|
||||
java.util.Arrays.equals(eData, other.eData) &&
|
||||
isEqual(eCksum, other.eCksum);
|
||||
}
|
||||
|
||||
private static boolean isEqual(Object a, Object b) {
|
||||
return (a == null)?(b == null):(a.equals(b));
|
||||
Objects.equals(cTime, other.cTime) &&
|
||||
Objects.equals(cuSec, other.cuSec) &&
|
||||
Objects.equals(sTime, other.sTime) &&
|
||||
Objects.equals(suSec, other.suSec) &&
|
||||
Objects.equals(crealm, other.crealm) &&
|
||||
Objects.equals(cname, other.cname) &&
|
||||
Objects.equals(sname, other.sname) &&
|
||||
Objects.equals(eText, other.eText) &&
|
||||
Arrays.equals(eData, other.eData) &&
|
||||
Objects.equals(eCksum, other.eCksum);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
int result = 17;
|
||||
result = 37 * result + pvno;
|
||||
result = 37 * result + msgType;
|
||||
result = 37 * result + errorCode;
|
||||
if (cTime != null) result = 37 * result + cTime.hashCode();
|
||||
if (cuSec != null) result = 37 * result + cuSec.hashCode();
|
||||
if (sTime != null) result = 37 * result + sTime.hashCode();
|
||||
if (suSec != null) result = 37 * result + suSec.hashCode();
|
||||
result = 37 * result + errorCode;
|
||||
if (crealm != null) result = 37 * result + crealm.hashCode();
|
||||
if (cname != null) result = 37 * result + cname.hashCode();
|
||||
if (sname != null) result = 37 * result + sname.hashCode();
|
||||
|
@ -182,6 +182,7 @@ abstract class P11Key implements Key, Length {
|
||||
|
||||
abstract byte[] getEncodedInternal();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -212,20 +213,13 @@ abstract class P11Key implements Key, Length {
|
||||
return MessageDigest.isEqual(thisEnc, otherEnc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// hashCode() should never throw exceptions
|
||||
if (!token.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
byte[] b1 = getEncodedInternal();
|
||||
if (b1 == null) {
|
||||
return 0;
|
||||
}
|
||||
int r = b1.length;
|
||||
for (int i = 0; i < b1.length; i++) {
|
||||
r += (b1[i] & 0xff) * 37;
|
||||
}
|
||||
return r;
|
||||
return Arrays.hashCode(getEncodedInternal());
|
||||
}
|
||||
|
||||
protected Object writeReplace() throws ObjectStreamException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,9 +44,10 @@ public class TestX509ValidationLog {
|
||||
l.addExpected("FINE: ValidationChain: " +
|
||||
TestCertificate.ROOT_CA.certId + ", " +
|
||||
TestCertificate.ROOT_CA.certId);
|
||||
int hashCode = TestCertificate.ROOT_CA.certificate().getPublicKey().hashCode();
|
||||
l.addExpected("FINE: ValidationChain: " +
|
||||
TestCertificate.ROOT_CA.certificate().getPublicKey().hashCode() +
|
||||
", " + TestCertificate.ROOT_CA.certId);
|
||||
Integer.toUnsignedLong(hashCode) + ", " +
|
||||
TestCertificate.ROOT_CA.certId);
|
||||
l.testExpected();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user