equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
42 |
42 |
43 private static final Pattern COLON_SEPARATED_HEX_PAIRS = |
43 private static final Pattern COLON_SEPARATED_HEX_PAIRS = |
44 Pattern.compile("^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2})+$"); |
44 Pattern.compile("^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2})+$"); |
45 private String name; |
45 private String name; |
46 private String value; |
46 private String value; |
47 private byte[] encoded; |
47 private final byte[] encoded; |
48 private int hashValue = -1; |
48 private int hashValue = -1; |
49 |
49 |
50 /** |
50 /** |
51 * Constructs a PKCS12 attribute from its name and value. |
51 * Constructs a PKCS12 attribute from its name and value. |
52 * The name is an ASN.1 Object Identifier represented as a list of |
52 * The name is an ASN.1 Object Identifier represented as a list of |
197 return true; |
197 return true; |
198 } |
198 } |
199 if (!(obj instanceof PKCS12Attribute)) { |
199 if (!(obj instanceof PKCS12Attribute)) { |
200 return false; |
200 return false; |
201 } |
201 } |
202 return Arrays.equals(encoded, ((PKCS12Attribute) obj).getEncoded()); |
202 return Arrays.equals(encoded, ((PKCS12Attribute) obj).encoded); |
203 } |
203 } |
204 |
204 |
205 /** |
205 /** |
206 * Returns the hashcode for this {@code PKCS12Attribute}. |
206 * Returns the hashcode for this {@code PKCS12Attribute}. |
207 * The hash code is computed from its DER encoding. |
207 * The hash code is computed from its DER encoding. |
208 * |
208 * |
209 * @return the hash code |
209 * @return the hash code |
210 */ |
210 */ |
211 @Override |
211 @Override |
212 public int hashCode() { |
212 public int hashCode() { |
213 if (hashValue == -1) { |
213 int h = hashValue; |
214 Arrays.hashCode(encoded); |
214 if (h == -1) { |
215 } |
215 hashValue = h = Arrays.hashCode(encoded); |
216 return hashValue; |
216 } |
|
217 return h; |
217 } |
218 } |
218 |
219 |
219 /** |
220 /** |
220 * Returns a string representation of this {@code PKCS12Attribute}. |
221 * Returns a string representation of this {@code PKCS12Attribute}. |
221 * |
222 * |