Package org.pgpainless.policy
Class Policy.SymmetricKeyAlgorithmPolicy
- java.lang.Object
-
- org.pgpainless.policy.Policy.SymmetricKeyAlgorithmPolicy
-
- Enclosing class:
- Policy
public static final class Policy.SymmetricKeyAlgorithmPolicy extends Object
-
-
Constructor Summary
Constructors Constructor Description SymmetricKeyAlgorithmPolicy(SymmetricKeyAlgorithm defaultSymmetricKeyAlgorithm, List<SymmetricKeyAlgorithm> acceptableSymmetricKeyAlgorithms)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Policy.SymmetricKeyAlgorithmPolicy
defaultSymmetricKeyDecryptionAlgorithmPolicy()
The default symmetric decryption algorithm policy of PGPainless.static Policy.SymmetricKeyAlgorithmPolicy
defaultSymmetricKeyEncryptionAlgorithmPolicy()
The default symmetric encryption algorithm policy of PGPainless.SymmetricKeyAlgorithm
getDefaultSymmetricKeyAlgorithm()
Return the default symmetric key algorithm.boolean
isAcceptable(int algorithmId)
Return true if the given symmetric encryption algorithm is acceptable by this policy.boolean
isAcceptable(SymmetricKeyAlgorithm algorithm)
Return true if the given symmetric encryption algorithm is acceptable by this policy.SymmetricKeyAlgorithm
selectBest(List<SymmetricKeyAlgorithm> options)
Select the best acceptable algorithm from the options list.
-
-
-
Constructor Detail
-
SymmetricKeyAlgorithmPolicy
public SymmetricKeyAlgorithmPolicy(SymmetricKeyAlgorithm defaultSymmetricKeyAlgorithm, List<SymmetricKeyAlgorithm> acceptableSymmetricKeyAlgorithms)
-
-
Method Detail
-
getDefaultSymmetricKeyAlgorithm
public SymmetricKeyAlgorithm getDefaultSymmetricKeyAlgorithm()
Return the default symmetric key algorithm. This algorithm is used as a fallback when no consensus about symmetric algorithms can be reached.- Returns:
- default symmetric encryption algorithm
-
isAcceptable
public boolean isAcceptable(SymmetricKeyAlgorithm algorithm)
Return true if the given symmetric encryption algorithm is acceptable by this policy.- Parameters:
algorithm
- algorithm- Returns:
- true if algorithm is acceptable, false otherwise
-
isAcceptable
public boolean isAcceptable(int algorithmId)
Return true if the given symmetric encryption algorithm is acceptable by this policy.- Parameters:
algorithmId
- algorithm- Returns:
- true if algorithm is acceptable, false otherwise
-
defaultSymmetricKeyEncryptionAlgorithmPolicy
public static Policy.SymmetricKeyAlgorithmPolicy defaultSymmetricKeyEncryptionAlgorithmPolicy()
The default symmetric encryption algorithm policy of PGPainless.- Returns:
- default symmetric encryption algorithm policy
-
defaultSymmetricKeyDecryptionAlgorithmPolicy
public static Policy.SymmetricKeyAlgorithmPolicy defaultSymmetricKeyDecryptionAlgorithmPolicy()
The default symmetric decryption algorithm policy of PGPainless.- Returns:
- default symmetric decryption algorithm policy
-
selectBest
public SymmetricKeyAlgorithm selectBest(List<SymmetricKeyAlgorithm> options)
Select the best acceptable algorithm from the options list. The best algorithm is the first algorithm we encounter in our list of acceptable algorithms that is also contained in the list of options.- Parameters:
options
- list of algorithm options- Returns:
- best
-
-