Stay organized with collections
Save and categorize content based on your preferences.
KeyRep
open class KeyRep : Serializable
Standardized representation for serialized Key objects.
Note that a serialized Key may contain sensitive information which should not be exposed in untrusted environments. See the Security Appendix of the Serialization Specification for more information.
Summary
Public constructors |
Construct the alternate Key class.
|
Protected methods |
open Any! |
Resolve the Key object.
|
Public constructors
KeyRep
KeyRep(
type: KeyRep.Type!,
algorithm: String!,
format: String!,
encoded: ByteArray!)
Construct the alternate Key class.
Parameters |
type |
KeyRep.Type!: either one of Type.SECRET, Type.PUBLIC, or Type.PRIVATE |
algorithm |
String!: the algorithm returned from Key.getAlgorithm() |
format |
String!: the encoding format returned from Key.getFormat() |
encoded |
ByteArray!: the encoded bytes returned from Key.getEncoded() |
Exceptions |
java.lang.NullPointerException |
if type is null , if algorithm is null , if format is null , or if encoded is null |
Protected methods
readResolve
protected open fun readResolve(): Any!
Resolve the Key object.
This method supports three Type/format combinations:
- Type.SECRET/"RAW" - returns a SecretKeySpec object constructed using encoded key bytes and algorithm
- Type.PUBLIC/"X.509" - gets a KeyFactory instance for the key algorithm, constructs an X509EncodedKeySpec with the encoded key bytes, and generates a public key from the spec
- Type.PRIVATE/"PKCS#8" - gets a KeyFactory instance for the key algorithm, constructs a PKCS8EncodedKeySpec with the encoded key bytes, and generates a private key from the spec
Return |
Any! |
the resolved Key object |
Exceptions |
java.io.ObjectStreamException |
if the Type/format combination is unrecognized, if the algorithm, key format, or encoded key bytes are unrecognized/invalid, of if the resolution of the key fails for any reason |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# KeyRep\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nKeyRep\n======\n\n```\nopen class KeyRep : Serializable\n```\n\n|---|---------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.security.KeyRep](#) |\n\nStandardized representation for serialized Key objects.\n\nNote that a serialized Key may contain sensitive information which should not be exposed in untrusted environments. See the [Security Appendix](https://docs.oracle.com/en/java/javase/17/docs/specs/serialization/security.html) of the Serialization Specification for more information.\n\nSummary\n-------\n\n| Nested classes ||\n|---|---------------------------------------------------------------|\n| | [Type](/reference/kotlin/java/security/KeyRep.Type) Key type. |\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [KeyRep](#KeyRep(java.security.KeyRep.Type,%20kotlin.String,%20kotlin.String,%20kotlin.ByteArray))`(`type:` `[KeyRep.Type](/reference/kotlin/java/security/KeyRep.Type)!`, `algorithm:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `format:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `encoded:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`)` Construct the alternate Key class. |\n\n| Protected methods ||\n|----------------------------------------------------------------------------------|-----------------------------------------------------------|\n| open [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | [readResolve](#readResolve())`()` Resolve the Key object. |\n\nPublic constructors\n-------------------\n\n### KeyRep\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nKeyRep(\n type: KeyRep.Type!, \n algorithm: String!, \n format: String!, \n encoded: ByteArray!)\n```\n\nConstruct the alternate Key class.\n\n| Parameters ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `type` | [KeyRep.Type](/reference/kotlin/java/security/KeyRep.Type)!: either one of Type.SECRET, Type.PUBLIC, or Type.PRIVATE |\n| `algorithm` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the algorithm returned from `Key.getAlgorithm()` |\n| `format` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the encoding format returned from `Key.getFormat()` |\n| `encoded` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: the encoded bytes returned from `Key.getEncoded()` |\n\n| Exceptions ||\n|----------------------------------|-----------------------------------------------------------------------------------------|\n| `java.lang.NullPointerException` | if type is `null`, if algorithm is `null`, if format is `null`, or if encoded is `null` |\n\nProtected methods\n-----------------\n\n### readResolve\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected open fun readResolve(): Any!\n```\n\nResolve the Key object.\n\nThis method supports three Type/format combinations:\n\n- Type.SECRET/\"RAW\" - returns a SecretKeySpec object constructed using encoded key bytes and algorithm\n- Type.PUBLIC/\"X.509\" - gets a KeyFactory instance for the key algorithm, constructs an X509EncodedKeySpec with the encoded key bytes, and generates a public key from the spec\n- Type.PRIVATE/\"PKCS#8\" - gets a KeyFactory instance for the key algorithm, constructs a PKCS8EncodedKeySpec with the encoded key bytes, and generates a private key from the spec\n\n| Return ||\n|-----------------------------------------------------------------------------|-------------------------|\n| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the resolved Key object |\n\n| Exceptions ||\n|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.io.ObjectStreamException` | if the Type/format combination is unrecognized, if the algorithm, key format, or encoded key bytes are unrecognized/invalid, of if the resolution of the key fails for any reason |"]]