KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > spec > EncodedKeySpec


1 /*
2  * @(#)EncodedKeySpec.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.security.spec;
9
10 /**
11  * This class represents a public or private key in encoded format.
12  *
13  * @author Jan Luehe
14  *
15  * @version 1.20, 12/19/03
16  *
17  * @see java.security.Key
18  * @see java.security.KeyFactory
19  * @see KeySpec
20  * @see X509EncodedKeySpec
21  * @see PKCS8EncodedKeySpec
22  *
23  * @since 1.2
24  */

25
26 public abstract class EncodedKeySpec implements KeySpec JavaDoc {
27
28     private byte[] encodedKey;
29
30     /**
31      * Creates a new EncodedKeySpec with the given encoded key.
32      *
33      * @param encodedKey the encoded key. The contents of the
34      * array are copied to protect against subsequent modification.
35      */

36     public EncodedKeySpec(byte[] encodedKey) {
37     this.encodedKey = (byte[])encodedKey.clone();
38     }
39
40     /**
41      * Returns the encoded key.
42      *
43      * @return the encoded key. Returns a new array each time
44      * this method is called.
45      */

46     public byte[] getEncoded() {
47     return (byte[])this.encodedKey.clone();
48     }
49
50     /**
51      * Returns the name of the encoding format associated with this
52      * key specification.
53      *
54      * <p>If the opaque representation of a key
55      * (see {@link java.security.Key Key}) can be transformed
56      * (see {@link java.security.KeyFactory KeyFactory})
57      * into this key specification (or a subclass of it),
58      * <code>getFormat</code> called
59      * on the opaque key returns the same value as the
60      * <code>getFormat</code> method
61      * of this key specification.
62      *
63      * @return a string representation of the encoding format.
64      */

65     public abstract String JavaDoc getFormat();
66 }
67
Popular Tags