Class OpenPGPDefaultPolicy
- All Implemented Interfaces:
OpenPGPPolicy
-
Nested Class Summary
Nested classes/interfaces inherited from interface OpenPGPPolicy
OpenPGPPolicy.OpenPGPNotationRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptCertificationSignatureHashAlgorithm(int hashAlgorithmId) acceptCertificationSignatureHashAlgorithmUntil(int hashAlgorithmId, Date until) acceptDocumentSignatureHashAlgorithm(int hashAlgorithmId) acceptDocumentSignatureHashAlgorithmUntil(int hashAlgorithmId, Date until) acceptPublicKeyAlgorithm(int publicKeyAlgorithmId) acceptPublicKeyAlgorithmWithMinimalStrength(int publicKeyAlgorithmId, int minBitStrength) acceptSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) acceptSymmetricKeyAlgorithmUntil(int symmetricKeyAlgorithmId, Date until) intReturn the default certification signature hash algorithm ID.intReturn the default document signature hash algorithm ID.intReturn the default symmetric-key algorithm, which is used as a fallback if symmetric encryption algorithm negotiation fails.longReturn the maximum number of bytes a compressed data packet may decompress to before message processing fails, or a negative value for no limit.Return the policiesOpenPGPPolicy.OpenPGPNotationRegistrycontaining known notation names.booleanisAcceptableCertificationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable certification signature hash algorithm.booleanisAcceptableDocumentSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable document signature hash algorithm.booleanisAcceptablePublicKeyStrength(int publicKeyAlgorithmId, int bitStrength) Return true, if the given bitStrength is acceptable for the given public key algorithm ID.booleanisAcceptableRevocationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable revocation signature hash algorithm.booleanisAcceptableSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) Return true, if the given symmetric-key algorithm is acceptable.rejectHashAlgorithm(int hashAlgorithmId) rejectPublicKeyAlgorithm(int publicKeyAlgorithmId) rejectSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) setDefaultCertificationSignatureHashAlgorithm(int hashAlgorithmId) setDefaultDocumentSignatureHashAlgorithm(int hashAlgorithmId) setDefaultSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) setMaximumDecompressedDataSize(long maximumDecompressedDataSize) Set the maximum number of bytes a compressed data packet may decompress to.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface OpenPGPPolicy
hasAcceptableCertificationSignatureHashAlgorithm, hasAcceptableDocumentSignatureHashAlgorithm, hasAcceptableRevocationSignatureHashAlgorithm, hasAcceptableSignatureHashAlgorithm, hasNoCriticalUnknownNotations, hasNoCriticalUnknownSubpackets, isAcceptableDecryptionKey, isAcceptableEncryptionKey, isAcceptablePublicKey, isAcceptableSignature, isAcceptableSigningKey, isAcceptableVerificationKey, isKnownSignatureSubpacket
-
Constructor Details
-
OpenPGPDefaultPolicy
public OpenPGPDefaultPolicy()
-
-
Method Details
-
rejectHashAlgorithm
-
acceptCertificationSignatureHashAlgorithm
-
acceptCertificationSignatureHashAlgorithmUntil
public OpenPGPDefaultPolicy acceptCertificationSignatureHashAlgorithmUntil(int hashAlgorithmId, Date until) -
acceptDocumentSignatureHashAlgorithm
-
acceptDocumentSignatureHashAlgorithmUntil
public OpenPGPDefaultPolicy acceptDocumentSignatureHashAlgorithmUntil(int hashAlgorithmId, Date until) -
rejectSymmetricKeyAlgorithm
-
acceptSymmetricKeyAlgorithm
-
acceptSymmetricKeyAlgorithmUntil
public OpenPGPDefaultPolicy acceptSymmetricKeyAlgorithmUntil(int symmetricKeyAlgorithmId, Date until) -
rejectPublicKeyAlgorithm
-
acceptPublicKeyAlgorithm
-
acceptPublicKeyAlgorithmWithMinimalStrength
public OpenPGPDefaultPolicy acceptPublicKeyAlgorithmWithMinimalStrength(int publicKeyAlgorithmId, int minBitStrength) -
isAcceptableDocumentSignatureHashAlgorithm
public boolean isAcceptableDocumentSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Description copied from interface:OpenPGPPolicyReturn true, if the given hash algorithm is - at signature creation time - an acceptable document signature hash algorithm.- Specified by:
isAcceptableDocumentSignatureHashAlgorithmin interfaceOpenPGPPolicy- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
isAcceptableRevocationSignatureHashAlgorithm
public boolean isAcceptableRevocationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Description copied from interface:OpenPGPPolicyReturn true, if the given hash algorithm is - at signature creation time - an acceptable revocation signature hash algorithm.- Specified by:
isAcceptableRevocationSignatureHashAlgorithmin interfaceOpenPGPPolicy- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
isAcceptableCertificationSignatureHashAlgorithm
public boolean isAcceptableCertificationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Description copied from interface:OpenPGPPolicyReturn true, if the given hash algorithm is - at signature creation time - an acceptable certification signature hash algorithm.- Specified by:
isAcceptableCertificationSignatureHashAlgorithmin interfaceOpenPGPPolicy- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
getDefaultCertificationSignatureHashAlgorithm
public int getDefaultCertificationSignatureHashAlgorithm()Description copied from interface:OpenPGPPolicyReturn the default certification signature hash algorithm ID. This is used as fallback, if negotiation of a commonly supported hash algorithm fails.- Specified by:
getDefaultCertificationSignatureHashAlgorithmin interfaceOpenPGPPolicy- Returns:
- default certification signature hash algorithm ID
-
setDefaultCertificationSignatureHashAlgorithm
-
getDefaultDocumentSignatureHashAlgorithm
public int getDefaultDocumentSignatureHashAlgorithm()Description copied from interface:OpenPGPPolicyReturn the default document signature hash algorithm ID. This is used as fallback, if negotiation of a commonly supported hash algorithm fails.- Specified by:
getDefaultDocumentSignatureHashAlgorithmin interfaceOpenPGPPolicy- Returns:
- default document signature hash algorithm ID
-
setDefaultDocumentSignatureHashAlgorithm
-
isAcceptableSymmetricKeyAlgorithm
public boolean isAcceptableSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) Description copied from interface:OpenPGPPolicyReturn true, if the given symmetric-key algorithm is acceptable.- Specified by:
isAcceptableSymmetricKeyAlgorithmin interfaceOpenPGPPolicy- Parameters:
symmetricKeyAlgorithmId- symmetric-key algorithm- Returns:
- true if symmetric-key algorithm is acceptable
-
getDefaultSymmetricKeyAlgorithm
public int getDefaultSymmetricKeyAlgorithm()Description copied from interface:OpenPGPPolicyReturn the default symmetric-key algorithm, which is used as a fallback if symmetric encryption algorithm negotiation fails.- Specified by:
getDefaultSymmetricKeyAlgorithmin interfaceOpenPGPPolicy- Returns:
- default symmetric-key algorithm
-
setDefaultSymmetricKeyAlgorithm
-
isAcceptablePublicKeyStrength
public boolean isAcceptablePublicKeyStrength(int publicKeyAlgorithmId, int bitStrength) Description copied from interface:OpenPGPPolicyReturn true, if the given bitStrength is acceptable for the given public key algorithm ID.- Specified by:
isAcceptablePublicKeyStrengthin interfaceOpenPGPPolicy- Parameters:
publicKeyAlgorithmId- ID of a public key algorithmbitStrength- key bit strength- Returns:
- true if strength is acceptable
-
getMaximumDecompressedDataSize
public long getMaximumDecompressedDataSize()Description copied from interface:OpenPGPPolicyReturn the maximum number of bytes a compressed data packet may decompress to before message processing fails, or a negative value for no limit.An OpenPGP compressed data packet carries no decompressed-length field, so a small packet can expand into an arbitrarily large amount of data (a "decompression bomb"). The nesting limit (
OpenPGPMessageInputStream.MAX_RECURSION) bounds how many compression layers a message may carry but says nothing about how much any one of them may produce, so this is the bound on the latter. It is applied per compressed data packet, as the bytes are produced, which is the only point at which decompression can usefully be stopped - a consumer counting bytes off the returned stream has already paid the cost it is trying to avoid. Exceeding it surfaces as aStreamOverflowException(anIOException) from reading themessage input stream.This mirrors the
PGPCompressedData.getDataStream()/PGPCompressedData.getDataStream(long)pair on the low-level API: the default is unbounded, and bounding it is the caller's decision, because no one limit suits every application. An application processing untrusted messages whose plaintext has a known upper bound should set one.- Specified by:
getMaximumDecompressedDataSizein interfaceOpenPGPPolicy- Returns:
- maximum decompressed size in bytes, or a negative value for no limit
-
setMaximumDecompressedDataSize
Set the maximum number of bytes a compressed data packet may decompress to. Unbounded by default, mirroring the low-levelPGPCompressedData.getDataStream(); an application processing untrusted messages whose plaintext has a known upper bound should set one. A negative value restores the unbounded behaviour.- Parameters:
maximumDecompressedDataSize- maximum decompressed size in bytes- Returns:
- this
-
getNotationRegistry
Description copied from interface:OpenPGPPolicyReturn the policiesOpenPGPPolicy.OpenPGPNotationRegistrycontaining known notation names.- Specified by:
getNotationRegistryin interfaceOpenPGPPolicy- Returns:
- notation registry
-