Enum Class SignatureAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<SignatureAlgorithm>, Constable
The signature algorithm invalid input: '&' public/private key crypto logic used by the web editor socket connection.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SignatureAlgorithmThe selectedSignatureAlgorithmfor the current environment. -
Method Summary
Modifier and TypeMethodDescriptionabstract KeyPairGenerate a public/private key pair.parsePublicKey(String base64String) Parse a public key from the given string.intGets the corresponding protocol versionsign(PrivateKey privateKey, String msg) Signsmsgusing the givenPrivateKey.static SignatureAlgorithmReturns the enum constant of this class with the specified name.static SignatureAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.booleanVerify that the given base64 encoded signature matches the given message andPublicKey.
-
Enum Constant Details
-
V1_RSA
-
V2_ECDSA
-
-
Field Details
-
INSTANCE
The selectedSignatureAlgorithmfor the current environment.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
protocolVersion
public int protocolVersion()Gets the corresponding protocol version- Returns:
- the protocol version
-
parsePublicKey
Parse a public key from the given string.- Parameters:
base64String- a base64 string encoding the public key- Returns:
- the parsed public key
- Throws:
IllegalArgumentException- if the input was invalid
-
generateKeyPair
Generate a public/private key pair.- Returns:
- the generated key pair
-
sign
Signsmsgusing the givenPrivateKey.- Parameters:
privateKey- the private key to sign withmsg- the message- Returns:
- a base64 string containing the signature
-
verify
Verify that the given base64 encoded signature matches the given message andPublicKey.- Parameters:
publicKey- the public key that the message was supposedly signed withmsg- the messagesignatureBase64- the provided signature- Returns:
- true if the signature is ok
-