Package org.asynchttpclient.scram
Class ScramContext
- java.lang.Object
-
- org.asynchttpclient.scram.ScramContext
-
public class ScramContext extends Object
Per-exchange mutable state for a SCRAM authentication handshake (RFC 7804). Attached to NettyResponseFuture during a SCRAM exchange. Not thread-safe: accessed only from EventLoop.
-
-
Constructor Summary
Constructors Constructor Description ScramContext(String username, String password, @Nullable String realmName, String mechanism)Create a ScramContext and initialize the client-first step.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcomputeClientFinal()Compute the client-final-message with proof.@Nullable StringgetClientFinalMessageWithoutProof()StringgetClientFirstMessage()StringgetClientFirstMessageBare()@org.jetbrains.annotations.Nullable byte[]getClientKey()StringgetClientNonce()ScramMessageParser.ScramChallengeParamsgetInitialChallengeParams()intgetIterationCount()StringgetMechanism()@Nullable StringgetRealmName()@org.jetbrains.annotations.Nullable byte[]getSalt()@Nullable StringgetServerFirstMessage()@org.jetbrains.annotations.Nullable byte[]getServerKey()@Nullable StringgetServerNonce()@Nullable StringgetSid()ScramStategetState()@org.jetbrains.annotations.Nullable byte[]getStoredKey()StringgetUsername()voidprocessServerFirst(String serverFirstMsg, int maxIterationCount)Process the server-first-message: validate nonce, extract salt/iterations, compute derived keys, and zero SaltedPassword.voidsetInitialChallengeParams(ScramMessageParser.ScramChallengeParams params)voidsetSid(@Nullable String sid)voidsetState(ScramState state)ScramSessionCache.EntrytoSessionCacheEntry(@Nullable String serverNoncePart, int ttl)Create a session cache entry from the current context after successful authentication.booleanverifyServerFinal(String serverFinalMsg)Verify the server-final-message (ServerSignature).
-
-
-
Method Detail
-
processServerFirst
public void processServerFirst(String serverFirstMsg, int maxIterationCount)
Process the server-first-message: validate nonce, extract salt/iterations, compute derived keys, and zero SaltedPassword.- Parameters:
serverFirstMsg- the verbatim server-first-message (decoded from base64)maxIterationCount- maximum allowed iteration count for DoS protection
-
computeClientFinal
public String computeClientFinal()
Compute the client-final-message with proof.- Returns:
- the full client-final-message string
-
verifyServerFinal
public boolean verifyServerFinal(String serverFinalMsg)
Verify the server-final-message (ServerSignature).- Parameters:
serverFinalMsg- the decoded server-final-message- Returns:
- true if ServerSignature is valid, false otherwise
-
toSessionCacheEntry
public ScramSessionCache.Entry toSessionCacheEntry(@Nullable @Nullable String serverNoncePart, int ttl)
Create a session cache entry from the current context after successful authentication.
-
getState
public ScramState getState()
-
setState
public void setState(ScramState state)
-
getMechanism
public String getMechanism()
-
getUsername
public String getUsername()
-
getRealmName
@Nullable public @Nullable String getRealmName()
-
getClientNonce
public String getClientNonce()
-
getServerNonce
@Nullable public @Nullable String getServerNonce()
-
getSid
@Nullable public @Nullable String getSid()
-
setSid
public void setSid(@Nullable @Nullable String sid)
-
getClientFirstMessage
public String getClientFirstMessage()
-
getClientFirstMessageBare
public String getClientFirstMessageBare()
-
getServerFirstMessage
@Nullable public @Nullable String getServerFirstMessage()
-
getClientKey
@Nullable public @org.jetbrains.annotations.Nullable byte[] getClientKey()
-
getStoredKey
@Nullable public @org.jetbrains.annotations.Nullable byte[] getStoredKey()
-
getServerKey
@Nullable public @org.jetbrains.annotations.Nullable byte[] getServerKey()
-
getInitialChallengeParams
@Nullable public ScramMessageParser.ScramChallengeParams getInitialChallengeParams()
-
setInitialChallengeParams
public void setInitialChallengeParams(@Nullable ScramMessageParser.ScramChallengeParams params)
-
getIterationCount
public int getIterationCount()
-
getSalt
@Nullable public @org.jetbrains.annotations.Nullable byte[] getSalt()
-
getClientFinalMessageWithoutProof
@Nullable public @Nullable String getClientFinalMessageWithoutProof()
-
-