1 /*
2 * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
302 }
303 if (reasonFlags != null) {
304 DerOutputStream reasons = new DerOutputStream();
305 BitArray rf = new BitArray(reasonFlags);
306 reasons.putTruncatedUnalignedBitString(rf);
307 tagged.writeImplicit(
308 DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_REASONS),
309 reasons);
310 }
311 if (crlIssuer != null) {
312 DerOutputStream issuer = new DerOutputStream();
313 crlIssuer.encode(issuer);
314 tagged.writeImplicit(
315 DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_ISSUER),
316 issuer);
317 }
318 out.write(DerValue.tag_Sequence, tagged);
319 }
320
321 /**
322 * Utility function for a.equals(b) where both a and b may be null.
323 */
324 private static boolean equals(Object a, Object b) {
325 return (a == null) ? (b == null) : a.equals(b);
326 }
327
328 /**
329 * Compare an object to this DistributionPoint for equality.
330 *
331 * @param obj Object to be compared to this
332 * @return true if objects match; false otherwise
333 */
334 public boolean equals(Object obj) {
335 if (this == obj) {
336 return true;
337 }
338 if (obj instanceof DistributionPoint == false) {
339 return false;
340 }
341 DistributionPoint other = (DistributionPoint)obj;
342
343 boolean equal = equals(this.fullName, other.fullName)
344 && equals(this.relativeName, other.relativeName)
345 && equals(this.crlIssuer, other.crlIssuer)
346 && Arrays.equals(this.reasonFlags, other.reasonFlags);
347 return equal;
348 }
349
350 public int hashCode() {
351 int hash = hashCode;
352 if (hash == 0) {
353 hash = 1;
354 if (fullName != null) {
355 hash += fullName.hashCode();
356 }
357 if (relativeName != null) {
358 hash += relativeName.hashCode();
359 }
360 if (crlIssuer != null) {
361 hash += crlIssuer.hashCode();
362 }
363 if (reasonFlags != null) {
364 for (int i = 0; i < reasonFlags.length; i++) {
365 if (reasonFlags[i]) {
|
1 /*
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
302 }
303 if (reasonFlags != null) {
304 DerOutputStream reasons = new DerOutputStream();
305 BitArray rf = new BitArray(reasonFlags);
306 reasons.putTruncatedUnalignedBitString(rf);
307 tagged.writeImplicit(
308 DerValue.createTag(DerValue.TAG_CONTEXT, false, TAG_REASONS),
309 reasons);
310 }
311 if (crlIssuer != null) {
312 DerOutputStream issuer = new DerOutputStream();
313 crlIssuer.encode(issuer);
314 tagged.writeImplicit(
315 DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_ISSUER),
316 issuer);
317 }
318 out.write(DerValue.tag_Sequence, tagged);
319 }
320
321 /**
322 * Compare an object to this DistributionPoint for equality.
323 *
324 * @param obj Object to be compared to this
325 * @return true if objects match; false otherwise
326 */
327 public boolean equals(Object obj) {
328 if (this == obj) {
329 return true;
330 }
331 if (obj instanceof DistributionPoint == false) {
332 return false;
333 }
334 DistributionPoint other = (DistributionPoint)obj;
335
336 boolean equal = Objects.equals(this.fullName, other.fullName)
337 && Objects.equals(this.relativeName, other.relativeName)
338 && Objects.equals(this.crlIssuer, other.crlIssuer)
339 && Arrays.equals(this.reasonFlags, other.reasonFlags);
340 return equal;
341 }
342
343 public int hashCode() {
344 int hash = hashCode;
345 if (hash == 0) {
346 hash = 1;
347 if (fullName != null) {
348 hash += fullName.hashCode();
349 }
350 if (relativeName != null) {
351 hash += relativeName.hashCode();
352 }
353 if (crlIssuer != null) {
354 hash += crlIssuer.hashCode();
355 }
356 if (reasonFlags != null) {
357 for (int i = 0; i < reasonFlags.length; i++) {
358 if (reasonFlags[i]) {
|