77import java .time .temporal .ChronoUnit ;
88import java .util .HashMap ;
99import java .util .Map ;
10+ import java .util .Objects ;
1011
1112/**
1213 * Class representing a cache for KAS (Key Access Server) information.
@@ -31,7 +32,7 @@ public Config.KASInfo get(String url, String algorithm, String kid) {
3132 TimeStampedKASInfo cachedValue = cache .get (cacheKey );
3233
3334 if (cachedValue == null ) {
34- log .debug ("didn't find kasinfo for url = [{}], algorithm = [{}] " , url , algorithm );
35+ log .debug ("didn't find kasinfo for key = [{}]" , cacheKey );
3536 return null ;
3637 }
3738
@@ -93,24 +94,26 @@ public KASKeyRequest(String url, String algorithm, String kid) {
9394 this .kid = kid ;
9495 }
9596
96- // Override equals and hashCode to ensure proper functioning of the HashMap
9797 @ Override
9898 public boolean equals (Object o ) {
99- if (this == o ) return true ;
100- if (o == null || !(o instanceof KASKeyRequest )) return false ;
99+ if (o == null || getClass () != o .getClass ()) return false ;
101100 KASKeyRequest that = (KASKeyRequest ) o ;
102- if (algorithm == null ){
103- return url .equals (that .url );
104- }
105- return url .equals (that .url ) && algorithm .equals (that .algorithm );
101+ return Objects .equals (url , that .url ) && Objects .equals (algorithm , that .algorithm ) && Objects .equals (kid , that .kid );
106102 }
107103
108104 @ Override
109105 public int hashCode () {
110- int result = 31 * url .hashCode ();
111- if (algorithm != null ) {
112- result = result + algorithm .hashCode ();
113- }
114- return result ;
106+ return Objects .hash (url , algorithm , kid );
107+ }
108+
109+ @ Override
110+ public String toString () {
111+ return "KASKeyRequest{" +
112+ "url='" + url + '\'' +
113+ ", algorithm='" + algorithm + '\'' +
114+ ", kid='" + kid + '\'' +
115+ '}' ;
115116 }
117+
118+ // Override equals and hashCode to ensure proper functioning of the HashMap
116119}
0 commit comments