public class SaslEcdsaNist256PChallenge extends AbstractAccountSaslProtocol
Modifier and Type | Class and Description |
---|---|
static class |
SaslEcdsaNist256PChallenge.ECKeyPair
Holds a private and public key.
|
Constructor and Description |
---|
SaslEcdsaNist256PChallenge(@NonNull Client client,
@NonNull String accountName,
@NonNull ECPrivateKey privateKey)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
static @NonNull String |
base64Encode(@NonNull ECPrivateKey privateKey)
Encodes a given
ECPrivateKey to base64. |
static @NonNull String |
base64Encode(@NonNull ECPublicKey publicKey)
Encodes a given
ECPublicKey to base64. |
protected @NonNull String |
getAuthLine()
Gets the info to base64 encode in the first AUTHENTICATE message.
|
static @NonNull String |
getCompressedBase64PublicKey(@NonNull ECPublicKey publicKey)
Applies point compression to a public key and returns the result,
encoded with base64.
|
@NonNull Object |
getEventListener()
Gets the object for listening.
|
static @NonNull SaslEcdsaNist256PChallenge.ECKeyPair |
getNewKey()
Generates a new
SaslEcdsaNist256PChallenge.ECKeyPair for use with this SASL protocol. |
static @NonNull ECPrivateKey |
getPrivateKey(@NonNull String base64Encoded)
Gets a
ECPrivateKey from a base64 encoded String. |
static @NonNull ECPublicKey |
getPublicKey(@NonNull String base64Encoded)
Gets a
ECPublicKey from a base64 encoded String. |
static @NonNull String |
sign(@NonNull ECPrivateKey privateKey,
@NonNull String base64Challenge)
Signs a given base64'd challenge via ECDSA.
|
protected void |
toString(ToStringer stringer)
Adds data to toString.
|
static boolean |
verify(@NonNull ECPublicKey publicKey,
@NonNull String base64Challenge,
@NonNull String signature)
Verifies a signature.
|
getAccountName
getAuthentication
getClient, startAuthentication, toString
public SaslEcdsaNist256PChallenge(@NonNull Client client, @NonNull String accountName, @NonNull ECPrivateKey privateKey)
client
- clientaccountName
- account nameprivateKey
- private keyprotected @NonNull String getAuthLine()
AbstractSaslProtocol
getAuthLine
in class AbstractSaslProtocol
public @NonNull Object getEventListener()
EventListening
getEventListener
in interface EventListening
getEventListener
in class AbstractSaslProtocol
protected void toString(ToStringer stringer)
AbstractAuthProtocol
toString
in class AbstractAccountSaslProtocol
stringer
- stringerpublic static @NonNull String base64Encode(@NonNull ECPrivateKey privateKey)
ECPrivateKey
to base64.privateKey
- key to encodeIllegalArgumentException
- if privateKey is nullgetPrivateKey(String)
public static @NonNull String base64Encode(@NonNull ECPublicKey publicKey)
ECPublicKey
to base64.publicKey
- key to encodeIllegalArgumentException
- if publicKey is nullgetPublicKey(String)
public static @NonNull ECPrivateKey getPrivateKey(@NonNull String base64Encoded) throws NoSuchAlgorithmException, InvalidKeySpecException
ECPrivateKey
from a base64 encoded String.base64Encoded
- encoded stringNoSuchAlgorithmException
- if the JVM doesn't support ECInvalidKeySpecException
- if the encoded key is invalidIllegalArgumentException
- if base64Encoded is nullbase64Encode(ECPrivateKey)
public static @NonNull ECPublicKey getPublicKey(@NonNull String base64Encoded) throws NoSuchAlgorithmException, InvalidKeySpecException
ECPublicKey
from a base64 encoded String.base64Encoded
- encoded stringNoSuchAlgorithmException
- if the JVM doesn't support ECInvalidKeySpecException
- if the encoded key is invalidIllegalArgumentException
- if base64Encoded is nullbase64Encode(ECPublicKey)
public static @NonNull String getCompressedBase64PublicKey(@NonNull ECPublicKey publicKey)
publicKey
- the public key to get the compressed X9.62
representation forIllegalArgumentException
- if publicKey is nullpublic static @NonNull String sign(@NonNull ECPrivateKey privateKey, @NonNull String base64Challenge) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException
privateKey
- private key for signingbase64Challenge
- challenge to signSignatureException
- if signing failsNoSuchAlgorithmException
- if the JVM doesn't support NONEwithECDSAInvalidKeyException
- if the key is invalidIllegalArgumentException
- if either parameter is nullpublic static @NonNull SaslEcdsaNist256PChallenge.ECKeyPair getNewKey() throws NoSuchAlgorithmException
SaslEcdsaNist256PChallenge.ECKeyPair
for use with this SASL protocol.NoSuchAlgorithmException
- if the JVM doesn't support NONEwithECDSApublic static boolean verify(@NonNull ECPublicKey publicKey, @NonNull String base64Challenge, @NonNull String signature) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException
publicKey
- public key to use in verificationbase64Challenge
- the challenge that was signedsignature
- signatureSignatureException
- if something has gone horribly wrongNoSuchAlgorithmException
- if the JVM doesn't support NONEwithECDSAInvalidKeyException
- if the key is invalidIllegalArgumentException
- if any parameter is nullCopyright © 2013–2021 Kitteh. All rights reserved.