public class SADFactory extends Object
SAD
object and a signed JWT holding the SAD.Modifier and Type | Class and Description |
---|---|
static class |
SADFactory.SADBuilder
A builder for creating a SAD and a signed SAD JWT.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_JWT_ID_SIZE
The default size for generated JWT identifiers (24)
|
static String |
DEFAULT_JWT_SIGNING_ALGORITHM
The name of the default JWT signature algorithm to be used (RS256).
|
static String |
DEFAULT_USER_ID_ATTRIBUTE_NAME
The default attribute name for the user ID ().
|
static int |
DEFAULT_VALIDITY_TIME
The default validity time for a SAD (five minutes).
|
Constructor and Description |
---|
SADFactory(String idpEntityID,
X509Credential signingCredential)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
createJwt(SAD sad)
Given a SAD, the method builds a JWT and signs it using the configured key.
|
SADFactory.SADBuilder |
getBuilder()
Returns a builder that allows building a SAD using a cascading builder pattern.
|
void |
setJwtIdSize(int jwtIdSize)
Assigns the size of generated JWT identifiers.
|
void |
setJwtSigningAlgorithm(String jwtSigningAlgorithm)
Assigns the JWT signature algorithm.
|
void |
setUserIdAttributeName(String userIdAttributeName)
Assigns the attribute name for the attribute holding the user ID.
|
void |
setValidityTime(int seconds)
Assigns the validity time for a SAD object (in seconds).
|
public static final int DEFAULT_VALIDITY_TIME
public static final String DEFAULT_USER_ID_ATTRIBUTE_NAME
public static final int DEFAULT_JWT_ID_SIZE
public static final String DEFAULT_JWT_SIGNING_ALGORITHM
public SADFactory(String idpEntityID, X509Credential signingCredential)
idpEntityID
- the entityID of the issuing IdPsigningCredential
- the IdP signature credentialpublic SADFactory.SADBuilder getBuilder()
public String createJwt(SAD sad) throws IOException, SignatureException
Note: Only RSA keys are supported.
sad
- the SAD to include in the JWTIOException
- for JSON processing errorsSignatureException
- for JWT signature errorsSADFactory.SADBuilder.buildJwt()
public void setValidityTime(int seconds)
DEFAULT_VALIDITY_TIME
.seconds
- validity time in secondspublic void setUserIdAttributeName(String userIdAttributeName)
DEFAULT_USER_ID_ATTRIBUTE_NAME
.userIdAttributeName
- attribute name (URI)public void setJwtIdSize(int jwtIdSize)
DEFAULT_JWT_ID_SIZE
.jwtIdSize
- the sizepublic void setJwtSigningAlgorithm(String jwtSigningAlgorithm)
DEFAULT_JWT_SIGNING_ALGORITHM
.jwtSigningAlgorithm
- JWT algorithm nameCopyright © 2018 Litsec AB. All rights reserved.