0N/A/*
2362N/A * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.x509;
0N/A
0N/Aimport java.security.cert.*;
0N/Aimport java.io.IOException;
0N/A
0N/Aimport sun.security.util.*;
0N/A
0N/A/**
0N/A * @author Ram Marti
0N/A */
0N/A
0N/Apublic final class AccessDescription {
0N/A
0N/A private int myhash = -1;
0N/A
0N/A private ObjectIdentifier accessMethod;
0N/A
0N/A private GeneralName accessLocation;
0N/A
0N/A public static final ObjectIdentifier Ad_OCSP_Id =
0N/A ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 1});
0N/A
0N/A public static final ObjectIdentifier Ad_CAISSUERS_Id =
0N/A ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 2});
0N/A
903N/A public static final ObjectIdentifier Ad_TIMESTAMPING_Id =
903N/A ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 3});
903N/A
903N/A public static final ObjectIdentifier Ad_CAREPOSITORY_Id =
903N/A ObjectIdentifier.newInternal(new int[] {1, 3, 6, 1, 5, 5, 7, 48, 5});
903N/A
903N/A public AccessDescription(ObjectIdentifier accessMethod, GeneralName accessLocation) {
903N/A this.accessMethod = accessMethod;
903N/A this.accessLocation = accessLocation;
903N/A }
903N/A
0N/A public AccessDescription(DerValue derValue) throws IOException {
0N/A DerInputStream derIn = derValue.getData();
0N/A accessMethod = derIn.getOID();
0N/A accessLocation = new GeneralName(derIn.getDerValue());
0N/A }
0N/A
0N/A public ObjectIdentifier getAccessMethod() {
0N/A return accessMethod;
0N/A }
0N/A
0N/A public GeneralName getAccessLocation() {
0N/A return accessLocation;
0N/A }
0N/A
0N/A public void encode(DerOutputStream out) throws IOException {
0N/A DerOutputStream tmp = new DerOutputStream();
0N/A tmp.putOID(accessMethod);
0N/A accessLocation.encode(tmp);
0N/A out.write(DerValue.tag_Sequence, tmp);
0N/A }
0N/A
0N/A public int hashCode() {
0N/A if (myhash == -1) {
0N/A myhash = accessMethod.hashCode() + accessLocation.hashCode();
0N/A }
0N/A return myhash;
0N/A }
0N/A
0N/A public boolean equals(Object obj) {
0N/A if (obj == null || (!(obj instanceof AccessDescription))) {
0N/A return false;
0N/A }
0N/A AccessDescription that = (AccessDescription)obj;
0N/A
0N/A if (this == that) {
0N/A return true;
0N/A }
0N/A return (accessMethod.equals(that.getAccessMethod()) &&
0N/A accessLocation.equals(that.getAccessLocation()));
0N/A }
0N/A
0N/A public String toString() {
903N/A String method = null;
903N/A if (accessMethod.equals(Ad_CAISSUERS_Id)) {
903N/A method = "caIssuers";
903N/A } else if (accessMethod.equals(Ad_CAREPOSITORY_Id)) {
903N/A method = "caRepository";
903N/A } else if (accessMethod.equals(Ad_TIMESTAMPING_Id)) {
903N/A method = "timeStamping";
903N/A } else if (accessMethod.equals(Ad_OCSP_Id)) {
903N/A method = "ocsp";
903N/A } else {
903N/A method = accessMethod.toString();
903N/A }
1652N/A return ("\n accessMethod: " + method +
903N/A "\n accessLocation: " + accessLocation.toString() + "\n");
0N/A }
0N/A}