Class SADFactory
java.lang.Object
se.swedenconnect.opensaml.sweid.saml2.signservice.SADFactory
A bean for building a
SAD
object and a signed JWT holding the SAD.- Author:
- Martin Lindström (martin@idsec.se)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A builder for creating a SAD and a signed SAD JWT. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default size for generated JWT identifiers (24)static final String
The name of the default JWT signature algorithm to be used (RS256).static final String
The default attribute name for the user ID ("urn:oid:1.2.752.29.4.13").static final int
The default validity time for a SAD (five minutes). -
Constructor Summary
ConstructorDescriptionSADFactory
(String idpEntityID, org.opensaml.security.x509.X509Credential signingCredential) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGiven a SAD, the method builds a JWT and signs it using the configured key.Returns a builder that allows building a SAD using a cascading builder pattern.getBuilder
(String userIdAttributeName) 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).
-
Field Details
-
DEFAULT_VALIDITY_TIME
public static final int DEFAULT_VALIDITY_TIMEThe default validity time for a SAD (five minutes).- See Also:
-
DEFAULT_USER_ID_ATTRIBUTE_NAME
The default attribute name for the user ID ("urn:oid:1.2.752.29.4.13").- See Also:
-
DEFAULT_JWT_ID_SIZE
public static final int DEFAULT_JWT_ID_SIZEThe default size for generated JWT identifiers (24)- See Also:
-
DEFAULT_JWT_SIGNING_ALGORITHM
The name of the default JWT signature algorithm to be used (RS256).
-
-
Constructor Details
-
SADFactory
Constructor.- Parameters:
idpEntityID
- the entityID of the issuing IdPsigningCredential
- the IdP signature credential
-
-
Method Details
-
getBuilder
Returns a builder that allows building a SAD using a cascading builder pattern.- Returns:
- a SAD builder
-
getBuilder
Returns a builder that allows building a SAD using a cascading builder pattern. The builder returned has been configured with the supplieduserIdAttributeName
instead of the attribute name that was configured for the factory (setUserIdAttributeName(String)
).- Parameters:
userIdAttributeName
- the user id attribute name- Returns:
- a SAD builder
-
createJwt
Given a SAD, the method builds a JWT and signs it using the configured key.Note: Only RSA keys are supported.
- Parameters:
sad
- the SAD to include in the JWT- Returns:
- a signed JWT (encoded)
- Throws:
IOException
- for JSON processing errorsSignatureException
- for JWT signature errors- See Also:
-
setValidityTime
public void setValidityTime(int seconds) Assigns the validity time for a SAD object (in seconds). The default isDEFAULT_VALIDITY_TIME
.- Parameters:
seconds
- validity time in seconds
-
setUserIdAttributeName
Assigns the attribute name for the attribute holding the user ID. Defaults toDEFAULT_USER_ID_ATTRIBUTE_NAME
.- Parameters:
userIdAttributeName
- attribute name (URI)
-
setJwtIdSize
public void setJwtIdSize(int jwtIdSize) Assigns the size of generated JWT identifiers. The default isDEFAULT_JWT_ID_SIZE
.- Parameters:
jwtIdSize
- the size
-
setJwtSigningAlgorithm
Assigns the JWT signature algorithm. The default isDEFAULT_JWT_SIGNING_ALGORITHM
.- Parameters:
jwtSigningAlgorithm
- JWT algorithm name
-