Package org.bouncycastle.openpgp.api
Class OpenPGPKey
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPCertificate
org.bouncycastle.openpgp.api.OpenPGPKey
An
OpenPGPKey
(TSK - transferable secret key) is the pendant to an OpenPGPCertificate
,
but containing the secret key material in addition to the public components.
It consists of one or multiple OpenPGPKey.OpenPGPSecretKey
objects.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
UnlockedOpenPGPKey.OpenPGPSecretKey
.static class
Secret key component of aOpenPGPCertificate.OpenPGPPrimaryKey
orOpenPGPCertificate.OpenPGPSubkey
.Nested classes/interfaces inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate
OpenPGPCertificate.OpenPGPCertificateComponent, OpenPGPCertificate.OpenPGPComponentKey, OpenPGPCertificate.OpenPGPComponentSignature, OpenPGPCertificate.OpenPGPIdentityComponent, OpenPGPCertificate.OpenPGPPrimaryKey, OpenPGPCertificate.OpenPGPSignatureChain, OpenPGPCertificate.OpenPGPSignatureChains, OpenPGPCertificate.OpenPGPSubkey, OpenPGPCertificate.OpenPGPUserAttribute, OpenPGPCertificate.OpenPGPUserId
-
Field Summary
Fields inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate
keyRing
-
Constructor Summary
ConstructorsConstructorDescriptionOpenPGPKey
(PGPSecretKeyRing keyRing) Create anOpenPGPKey
instance based on aPGPSecretKeyRing
.OpenPGPKey
(PGPSecretKeyRing keyRing, OpenPGPImplementation implementation) Create anOpenPGPKey
instance based on aPGPSecretKeyRing
, a providedOpenPGPImplementation
and itsOpenPGPPolicy
.OpenPGPKey
(PGPSecretKeyRing keyRing, OpenPGPImplementation implementation, OpenPGPPolicy policy) Create anOpenPGPKey
instance based on aPGPSecretKeyRing
, a providedOpenPGPImplementation
andOpenPGPPolicy
. -
Method Summary
Modifier and TypeMethodDescriptionReturn aList
containing allcomponents
of the certificate.byte[]
getEncoded
(PacketFormat packetFormat) Return a byte array containing the binary representation of the certificate, encoded using the given packet length encoding format.Return thePGPKeyRing
that this certificate is based on.Return the underlyingPGPSecretKeyRing
.Return theOpenPGPKey.OpenPGPSecretKey
of this key's primary key.getSecretKey
(KeyIdentifier identifier) Return theOpenPGPKey.OpenPGPSecretKey
identified by the passedKeyIdentifier
.Return theOpenPGPKey.OpenPGPSecretKey
that corresponds to the passedOpenPGPCertificate.OpenPGPComponentKey
.Return aMap
containing allOpenPGPKey.OpenPGPSecretKey
components (secret subkeys) of the key.boolean
Return true, if this object is anOpenPGPKey
, false otherwise.Return theOpenPGPCertificate
of thisOpenPGPKey
.Methods inherited from class org.bouncycastle.openpgp.api.OpenPGPCertificate
getAllKeyIdentifiers, getAllUserIds, getCertification, getCertification, getCertificationKeys, getCertificationKeys, getComponentKeysWithFlag, getDelegationBy, getDelegationBy, getEncoded, getEncryptionKeys, getEncryptionKeys, getExpirationTime, getExpirationTime, getFingerprint, getIdentities, getKey, getKeyIdentifier, getKeys, getLastModificationDate, getLastModificationDateAt, getPGPPublicKeyRing, getPrettyFingerprint, getPrimaryKey, getPrimaryUserId, getPrimaryUserId, getPublicKeys, getRevocation, getRevocation, getRevocationBy, getRevocationBy, getSigningKeyFor, getSigningKeys, getSigningKeys, getSubkeys, getUserId, getValidKeys, getValidKeys, getValidUserIds, getValidUserIds, join, join, toAsciiArmoredString, toAsciiArmoredString, toAsciiArmoredString
-
Constructor Details
-
OpenPGPKey
Create anOpenPGPKey
instance based on aPGPSecretKeyRing
. TheOpenPGPImplementation
will be acquired by invokingOpenPGPImplementation.getInstance()
.- Parameters:
keyRing
- secret key ring
-
OpenPGPKey
Create anOpenPGPKey
instance based on aPGPSecretKeyRing
, a providedOpenPGPImplementation
and itsOpenPGPPolicy
.- Parameters:
keyRing
- secret key ringimplementation
- OpenPGP implementation
-
OpenPGPKey
public OpenPGPKey(PGPSecretKeyRing keyRing, OpenPGPImplementation implementation, OpenPGPPolicy policy) Create anOpenPGPKey
instance based on aPGPSecretKeyRing
, a providedOpenPGPImplementation
andOpenPGPPolicy
.- Parameters:
keyRing
- secret key ringimplementation
- OpenPGP implementationpolicy
- OpenPGP policy
-
-
Method Details
-
isSecretKey
public boolean isSecretKey()Description copied from class:OpenPGPCertificate
Return true, if this object is anOpenPGPKey
, false otherwise.- Overrides:
isSecretKey
in classOpenPGPCertificate
- Returns:
- true if this is a secret key
-
toCertificate
Return theOpenPGPCertificate
of thisOpenPGPKey
.- Returns:
- certificate
-
getComponents
Description copied from class:OpenPGPCertificate
Return aList
containing allcomponents
of the certificate. Components are primary key, subkeys and identities (user-ids, user attributes).- Overrides:
getComponents
in classOpenPGPCertificate
- Returns:
- list of components
-
getPrimarySecretKey
Return theOpenPGPKey.OpenPGPSecretKey
of this key's primary key.- Returns:
- primary secret key
-
getSecretKeys
Return aMap
containing allOpenPGPKey.OpenPGPSecretKey
components (secret subkeys) of the key.- Returns:
- secret key components
-
getSecretKey
Return theOpenPGPKey.OpenPGPSecretKey
identified by the passedKeyIdentifier
.- Parameters:
identifier
- key identifier- Returns:
- corresponding secret key or null
-
getSecretKey
Return theOpenPGPKey.OpenPGPSecretKey
that corresponds to the passedOpenPGPCertificate.OpenPGPComponentKey
.- Parameters:
key
- component key- Returns:
- corresponding secret key or null
-
getPGPKeyRing
Description copied from class:OpenPGPCertificate
Return thePGPKeyRing
that this certificate is based on.- Overrides:
getPGPKeyRing
in classOpenPGPCertificate
- Returns:
- underlying key ring
-
getPGPSecretKeyRing
Return the underlyingPGPSecretKeyRing
.- Returns:
- secret key ring
-
getEncoded
Description copied from class:OpenPGPCertificate
Return a byte array containing the binary representation of the certificate, encoded using the given packet length encoding format.- Overrides:
getEncoded
in classOpenPGPCertificate
- Parameters:
packetFormat
- packet length encoding format- Returns:
- binary encoded certificate
- Throws:
IOException
- if the certificate cannot be encoded
-