@Singleton public class DefaultCSRFTokenSigner extends java.lang.Object implements CSRFTokenSigner
This trait should not be used as a general purpose encryption utility.
Constructor and Description |
---|
DefaultCSRFTokenSigner(play.api.libs.crypto.CSRFTokenSigner csrfTokenSigner) |
Modifier and Type | Method and Description |
---|---|
play.api.libs.crypto.CSRFTokenSigner |
asScala()
Utility method needed for CSRFCheck.
|
boolean |
compareSignedTokens(java.lang.String tokenA,
java.lang.String tokenB)
Compare two signed tokens.
|
java.lang.String |
extractSignedToken(java.lang.String token)
Extract a signed token that was signed by
CSRFTokenSigner.signToken(String) . |
java.lang.String |
generateSignedToken()
Generates a signed token by calling generateToken / signToken.
|
java.lang.String |
generateToken()
Generates a cryptographically secure token.
|
java.lang.String |
signToken(java.lang.String token)
Sign a token.
|
@Inject public DefaultCSRFTokenSigner(play.api.libs.crypto.CSRFTokenSigner csrfTokenSigner)
public java.lang.String signToken(java.lang.String token)
CSRFTokenSigner
This primarily exists to defeat the BREACH vulnerability, as it allows the token to effectively be random per request, without actually changing the value.
signToken
in interface CSRFTokenSigner
token
- The token to signpublic java.lang.String extractSignedToken(java.lang.String token)
CSRFTokenSigner
CSRFTokenSigner.signToken(String)
.extractSignedToken
in interface CSRFTokenSigner
token
- The signed token to extract.public java.lang.String generateToken()
CSRFTokenSigner
generateToken
in interface CSRFTokenSigner
public java.lang.String generateSignedToken()
CSRFTokenSigner
generateSignedToken
in interface CSRFTokenSigner
public boolean compareSignedTokens(java.lang.String tokenA, java.lang.String tokenB)
CSRFTokenSigner
compareSignedTokens
in interface CSRFTokenSigner
tokenA
- the first tokentokenB
- another tokenpublic play.api.libs.crypto.CSRFTokenSigner asScala()
CSRFTokenSigner
asScala
in interface CSRFTokenSigner