Class 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 Detail

      • ScramContext

        public ScramContext​(String username,
                            String password,
                            @Nullable
                            @Nullable String realmName,
                            String mechanism)
        Create a ScramContext and initialize the client-first step.
    • 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.
      • 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()
      • getIterationCount

        public int getIterationCount()
      • getSalt

        @Nullable
        public @org.jetbrains.annotations.Nullable byte[] getSalt()
      • getClientFinalMessageWithoutProof

        @Nullable
        public @Nullable String getClientFinalMessageWithoutProof()