Package org.wildfly.security.http.oidc
Class JWTClientCredentialsProvider
- java.lang.Object
-
- org.wildfly.security.http.oidc.JWTClientCredentialsProvider
-
- All Implemented Interfaces:
ClientCredentialsProvider
@MetaInfServices(ClientCredentialsProvider.class) public class JWTClientCredentialsProvider extends Object implements ClientCredentialsProvider
Client authentication based on JWT signed by client private key. See specs for more details.- Author:
- Marek Posolda, Farah Juma
-
-
Field Summary
Fields Modifier and Type Field Description private KeyPair
keyPair
private org.jose4j.jwk.PublicJsonWebKey
publicKeyJwk
private int
tokenTimeout
-
Constructor Summary
Constructors Constructor Description JWTClientCredentialsProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.jose4j.jwt.JwtClaims
createRequestToken(String clientId, String tokenUrl)
String
createSignedRequestToken(String clientId, String tokenUrl)
private static InputStream
findFile(String keystoreFile)
String
getId()
Return the ID of the provider.PublicKey
getPublicKey()
protected int
getTokenTimeout()
void
init(OidcClientConfiguration oidcClientConfiguration, Object credentialsConfig)
Called during deployment of your application.private static KeyPair
loadKeyPairFromKeyStore(String keyStoreFile, String storePassword, String keyPassword, String keyAlias, String keyStoreType)
void
setClientCredentials(OidcClientConfiguration oidcClientConfiguration, Map<String,String> requestHeaders, Map<String,String> formParams)
Called every time a backchannel request is performed.void
setTokenTimeout(int tokenTimeout)
void
setupKeyPair(KeyPair keyPair)
-
-
-
Field Detail
-
keyPair
private KeyPair keyPair
-
publicKeyJwk
private org.jose4j.jwk.PublicJsonWebKey publicKeyJwk
-
tokenTimeout
private int tokenTimeout
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:ClientCredentialsProvider
Return the ID of the provider. Use this ID in the oidc.json configuration as the sub-element of the "credentials" element For example if your provider has ID "some-provider", use the configuration like this in oidc.json "credentials": { "some-provider": { "someAttribute": "someValue" } }- Specified by:
getId
in interfaceClientCredentialsProvider
- Returns:
- the ID of the provider
-
setupKeyPair
public void setupKeyPair(KeyPair keyPair)
-
setTokenTimeout
public void setTokenTimeout(int tokenTimeout)
-
getTokenTimeout
protected int getTokenTimeout()
-
getPublicKey
public PublicKey getPublicKey()
-
init
public void init(OidcClientConfiguration oidcClientConfiguration, Object credentialsConfig)
Description copied from interface:ClientCredentialsProvider
Called during deployment of your application.- Specified by:
init
in interfaceClientCredentialsProvider
- Parameters:
oidcClientConfiguration
- the OIDC client configurationcredentialsConfig
- the configuration of your credentials provider read from oidc.json. For the some-provider example above, it will return map with the single key "someAttribute" with value "someValue"
-
setClientCredentials
public void setClientCredentials(OidcClientConfiguration oidcClientConfiguration, Map<String,String> requestHeaders, Map<String,String> formParams)
Description copied from interface:ClientCredentialsProvider
Called every time a backchannel request is performed.- Specified by:
setClientCredentials
in interfaceClientCredentialsProvider
- Parameters:
oidcClientConfiguration
- the fully resolved OIDC client configurationrequestHeaders
- You should put any HTTP request headers you want to use for authentication of client. These headers will be attached to the HTTP request sent to the OpenID providerformParams
- You should put any request parameters you want to use for authentication of client. These parameters will be attached to the HTTP request sent to the OpenID provider
-
createRequestToken
protected org.jose4j.jwt.JwtClaims createRequestToken(String clientId, String tokenUrl)
-
loadKeyPairFromKeyStore
private static KeyPair loadKeyPairFromKeyStore(String keyStoreFile, String storePassword, String keyPassword, String keyAlias, String keyStoreType)
-
findFile
private static InputStream findFile(String keystoreFile)
-
-