OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [javax/] [security/] [cert/] [Certificate.java] - Blame information for rev 772

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 772 jeremybenn
/* Certificate.java -- base class of public-key certificates.
2
   Copyright (C) 2004 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package javax.security.cert;
40
 
41
import java.security.InvalidKeyException;
42
import java.security.NoSuchAlgorithmException;
43
import java.security.NoSuchProviderException;
44
import java.security.PublicKey;
45
import java.security.SignatureException;
46
 
47
import java.util.Arrays;
48
import java.util.zip.Adler32;
49
 
50
/**
51
 * <p>The base class for public-key certificates.</p>
52
 *
53
 * <p><b>This class is deprecated in favor of the {@link
54
 * java.security.cert.Certificate} class. It should not be used in new
55
 * applications.</b></p>
56
 */
57
public abstract class Certificate
58
{
59
 
60
  // Constructors.
61
  // -------------------------------------------------------------------------
62
 
63
  public Certificate()
64
  {
65
    super();
66
  }
67
 
68
  // Instance methods.
69
  // -------------------------------------------------------------------------
70
 
71
  /**
72
   * <p>Tests if this certificate equals another.</p>
73
   *
74
   * @param other The object to test.
75
   * @return True if the certificates are equal.
76
   */
77
  public boolean equals(Object other)
78
  {
79
    if (other == null || !(other instanceof Certificate))
80
      {
81
        return false;
82
      }
83
    if (other == this)
84
      {
85
        return true;
86
      }
87
    try
88
      {
89
        return Arrays.equals(getEncoded(), ((Certificate) other).getEncoded());
90
      }
91
    catch (CertificateEncodingException cee)
92
      {
93
        return false;
94
      }
95
  }
96
 
97
  /**
98
   * <p>Computes a hash code for this certificate.</p>
99
   *
100
   * @return The hash code.
101
   */
102
  public int hashCode()
103
  {
104
    try
105
      {
106
        Adler32 csum = new Adler32();
107
        csum.update(getEncoded());
108
        return (int) csum.getValue();
109
      }
110
    catch (CertificateEncodingException cee)
111
      {
112
        return 0;
113
      }
114
  }
115
 
116
  // Abstract methods.
117
  // -------------------------------------------------------------------------
118
 
119
  /**
120
   * <p>Return the encoded form of this certificate.</p>
121
   *
122
   * @return The encoded form.
123
   * @throws CertificateEncodingException If the certificate could not be
124
   *   encoded.
125
   */
126
  public abstract byte[] getEncoded() throws CertificateEncodingException;
127
 
128
  /**
129
   * <p>Verifies the signature of this certificate.</p>
130
   *
131
   * @param key The signer's public key.
132
   * @throws CertificateException
133
   * @throws NoSuchAlgorithmException If the algorithm used to sign the
134
   *   certificate is not available.
135
   * @throws InvalidKeyException If the supplied key is not appropriate for the
136
   *   certificate's signature algorithm.
137
   * @throws NoSuchProviderException
138
   * @throws SignatureException If the signature could not be verified.
139
   */
140
  public abstract void verify(PublicKey key)
141
    throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
142
           NoSuchProviderException, SignatureException;
143
 
144
  /**
145
   * <p>Verifies the signature of this certificate, using the specified security
146
   * provider.</p>
147
   *
148
   * @param key The signer's public key.
149
   * @param sigProvider The name of the signature provider.
150
   * @throws CertificateException
151
   * @throws NoSuchAlgorithmException If the algorithm used to sign the
152
   *   certificate is not available.
153
   * @throws InvalidKeyException If the supplied key is not appropriate for the
154
   *   certificate's signature algorithm.
155
   * @throws NoSuchProviderException If <i>sigProvider</i> is not the name of an
156
   *   installed provider.
157
   * @throws SignatureException If the signature could not be verified.
158
   */
159
  public abstract void verify(PublicKey key, String sigProvider)
160
    throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,
161
           NoSuchProviderException, SignatureException;
162
 
163
  /**
164
   * <p>Returns a printable representation of this certificate.</p>
165
   *
166
   * @return The string.
167
   */
168
  public abstract String toString();
169
 
170
  /**
171
   * <p>Returns this certificate's public key.</p>
172
   *
173
   * @return The public key.
174
   */
175
  public abstract PublicKey getPublicKey();
176
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.