Package java.security
Class KeyRep
- java.lang.Object
-
- java.security.KeyRep
-
- All Implemented Interfaces:
Serializable
public class KeyRep extends Object implements Serializable
KeyRepis a standardized representation for serializedKeyobjects.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyRep.TypeTypeenumerates the supported key types.
-
Constructor Summary
Constructors Constructor Description KeyRep(KeyRep.Type type, String algorithm, String format, byte[] encoded)Constructs a new instance ofKeyRepwith the specified arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectreadResolve()Resolves and returns theKeyobject.
-
-
-
Constructor Detail
-
KeyRep
public KeyRep(KeyRep.Type type, String algorithm, String format, byte[] encoded)
Constructs a new instance ofKeyRepwith the specified arguments. The arguments should be obtained from theKeyobject that has to be serialized.- Parameters:
type- the type of the key.algorithm- the algorithm (obtained byKey.getAlgorithm()).format- the format of the key (obtained byKey.getFormat()).encoded- the encodedbyte[](obtained byKey.getEncoded()).- Throws:
NullPointerException- iftype, algorithm, format or encodedisnull.
-
-
Method Detail
-
readResolve
protected Object readResolve() throws ObjectStreamException
Resolves and returns theKeyobject. ThreeKeyRep.Type|format combinations are supported:-
Type.PRIVATE| "PKCS#8" : returns aPrivateKeyinstance, generated from a key factory (suitable for the algorithm) that is initialized with aPKCS8EncodedKeySpecusing the encoded key bytes. -
Type.SECRET| "RAW" : returns aSecretKeySpecinstance, created with the encoded key bytes and the algorithm. -
Type.PUBLIC| "X.509": returns aPublicKeyinstance, generated from a key factory (suitable for the algorithm) that is initialized with aX509EncodedKeySpecusing the encoded key bytes.
- Returns:
- the resolved
Keyobject. - Throws:
ObjectStreamException- if theType|format combination is not recognized, or the resolution of any key parameter fails.
-
-
-