Skip to content

Most visited

Recently visited

navigation
Added in API level 1

KeyRep

public class KeyRep
extends Object implements Serializable

java.lang.Object
   ↳ java.security.KeyRep


KeyRep is a standardized representation for serialized Key objects.

Summary

Nested classes

enum KeyRep.Type

Type enumerates the supported key types. 

Public constructors

KeyRep(KeyRep.Type type, String algorithm, String format, byte[] encoded)

Constructs a new instance of KeyRep with the specified arguments.

Protected methods

Object readResolve()

Resolves and returns the Key object.

Inherited methods

From class java.lang.Object

Public constructors

KeyRep

Added in API level 1
KeyRep (KeyRep.Type type, 
                String algorithm, 
                String format, 
                byte[] encoded)

Constructs a new instance of KeyRep with the specified arguments. The arguments should be obtained from the Key object that has to be serialized.

Parameters
type KeyRep.Type: the type of the key.
algorithm String: the algorithm (obtained by getAlgorithm()).
format String: the format of the key (obtained by getFormat()).
encoded byte: the encoded byte[] (obtained by getEncoded()).
Throws
NullPointerException if type, algorithm, format or encoded is null .

Protected methods

readResolve

Added in API level 1
Object readResolve ()

Resolves and returns the Key object. Three KeyRep.Type|format combinations are supported:

  • Type.PRIVATE | "PKCS#8" : returns a PrivateKey instance, generated from a key factory (suitable for the algorithm) that is initialized with a PKCS8EncodedKeySpec using the encoded key bytes.
  • Type.SECRET | "RAW" : returns a SecretKeySpec instance, created with the encoded key bytes and the algorithm.
  • Type.PUBLIC | "X.509": returns a PublicKey instance, generated from a key factory (suitable for the algorithm) that is initialized with a X509EncodedKeySpec using the encoded key bytes.

Returns
Object the resolved Key object.
Throws
ObjectStreamException if the Type|format combination is not recognized, or the resolution of any key parameter fails.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.