blob: a9ccbb86824ee1c590260bc556b9884dae65787b [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2005 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.security.x509;
27
28import java.security.cert.*;
29import java.io.IOException;
30
31import sun.security.util.*;
32
33/**
34 * @author Ram Marti
35 */
36
37public final class AccessDescription {
38
39 private int myhash = -1;
40
41 private ObjectIdentifier accessMethod;
42
43 private GeneralName accessLocation;
44
45 public static final ObjectIdentifier Ad_OCSP_Id =
46 ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 1});
47
48 public static final ObjectIdentifier Ad_CAISSUERS_Id =
49 ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 2});
50
51 public AccessDescription(DerValue derValue) throws IOException {
52 DerInputStream derIn = derValue.getData();
53 accessMethod = derIn.getOID();
54 accessLocation = new GeneralName(derIn.getDerValue());
55 }
56
57 public ObjectIdentifier getAccessMethod() {
58 return accessMethod;
59 }
60
61 public GeneralName getAccessLocation() {
62 return accessLocation;
63 }
64
65 public void encode(DerOutputStream out) throws IOException {
66 DerOutputStream tmp = new DerOutputStream();
67 tmp.putOID(accessMethod);
68 accessLocation.encode(tmp);
69 out.write(DerValue.tag_Sequence, tmp);
70 }
71
72 public int hashCode() {
73 if (myhash == -1) {
74 myhash = accessMethod.hashCode() + accessLocation.hashCode();
75 }
76 return myhash;
77 }
78
79 public boolean equals(Object obj) {
80 if (obj == null || (!(obj instanceof AccessDescription))) {
81 return false;
82 }
83 AccessDescription that = (AccessDescription)obj;
84
85 if (this == that) {
86 return true;
87 }
88 return (accessMethod.equals(that.getAccessMethod()) &&
89 accessLocation.equals(that.getAccessLocation()));
90 }
91
92 public String toString() {
93 return ("accessMethod: " + accessMethod.toString() +
94 "\n accessLocation: " + accessLocation.toString());
95 }
96}