Class TokenService
- java.lang.Object
-
- fr.paris.lutece.plugins.oauth2.service.TokenService
-
public final class TokenService extends java.lang.ObjectTokenService
-
-
Constructor Summary
Constructors Constructor Description TokenService(AuthClientConf defaultClientConfig, AuthServerConf defaultauthServerConfig)Constructs a TokenService
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static TokenServicegetService()Deprecated.use dependency injection insteadTokengetToken(java.lang.String strRedirectUri, AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strAuthorizationCode, javax.servlet.http.HttpSession session, JWTParser jWTParser, java.lang.String strStoredNonce, java.lang.String strCodeVerifier)Retrieve a token using an authorization codeTokengetToken(java.lang.String strAuthorizationCode, javax.servlet.http.HttpSession session, JWTParser jWTParser, java.lang.String strStoredNonce)Retrieve a token using an authorization codeTokengetTokenByRefreshToken(AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strRefreshToken)Get new Token using refresh tokenTokengetTokenByRefreshToken(java.lang.String strRefreshToken)Get new Token using refresh tokenTokenparse(java.lang.String strJson, AuthClientConf clientConfig, AuthServerConf serverConfig, JWTParser jwtParser, java.lang.String strStoredNonce)parse the JSON for a tokenTokenparse(java.lang.String strJson, java.time.Instant creationTime, AuthClientConf clientConfig, AuthServerConf serverConfig, JWTParser jwtParser, java.lang.String strStoredNonce)parse the JSON for a tokenbooleanvalidateRefreshToken(AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strRefreshToken)Validate refresh tokenbooleanvalidateRefreshToken(java.lang.String strRefreshToken)Validate refresh token
-
-
-
Constructor Detail
-
TokenService
public TokenService(@Named("oauth2.client") AuthClientConf defaultClientConfig, @Named("oauth2.server") AuthServerConf defaultauthServerConfig)Constructs a TokenService- Parameters:
defaultClientConfig- default client configdefaultauthServerConfig- default server config
-
-
Method Detail
-
getToken
public Token getToken(java.lang.String strAuthorizationCode, javax.servlet.http.HttpSession session, JWTParser jWTParser, java.lang.String strStoredNonce) throws java.io.IOException, fr.paris.lutece.util.httpaccess.HttpAccessException, TokenValidationException
Retrieve a token using an authorization code- Parameters:
strAuthorizationCode- The authorization codesession- The HTTP session- Returns:
- The token
- Throws:
java.io.IOException- if an error occursfr.paris.lutece.util.httpaccess.HttpAccessException- if an error occursTokenValidationException- If the token validation failed
-
getToken
public Token getToken(java.lang.String strRedirectUri, AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strAuthorizationCode, javax.servlet.http.HttpSession session, JWTParser jWTParser, java.lang.String strStoredNonce, java.lang.String strCodeVerifier) throws java.io.IOException, fr.paris.lutece.util.httpaccess.HttpAccessException, TokenValidationException
Retrieve a token using an authorization code- Parameters:
the- strRedirectUristrAuthorizationCode- The authorization codesession- The HTTP session- Returns:
- The token
- Throws:
java.io.IOException- if an error occursfr.paris.lutece.util.httpaccess.HttpAccessException- if an error occursTokenValidationException- If the token validation failed
-
validateRefreshToken
public boolean validateRefreshToken(java.lang.String strRefreshToken)
Validate refresh token- Parameters:
clientConfig- ClientConfauthServerConf- AutConfstrRefreshToken- refreshToken- Returns:
- true if the refresh token is already good
-
validateRefreshToken
public boolean validateRefreshToken(AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strRefreshToken)
Validate refresh token- Parameters:
clientConfig- ClientConfauthServerConf- AutConfstrRefreshToken- refreshToken- Returns:
- true if the refresh token is already good
-
getTokenByRefreshToken
public Token getTokenByRefreshToken(java.lang.String strRefreshToken)
Get new Token using refresh token- Parameters:
clientConfig- ClientConfauthServerConf- AutConfstrRefreshToken- refreshToken- Returns:
- true if the refresh token is already good
-
getTokenByRefreshToken
public Token getTokenByRefreshToken(AuthClientConf clientConfig, AuthServerConf authServerConf, java.lang.String strRefreshToken)
Get new Token using refresh token- Parameters:
clientConfig- ClientConfauthServerConf- AutConfstrRefreshToken- refreshToken- Returns:
- true if the refresh token is already good
-
parse
public Token parse(java.lang.String strJson, AuthClientConf clientConfig, AuthServerConf serverConfig, JWTParser jwtParser, java.lang.String strStoredNonce) throws java.io.IOException, TokenValidationException
parse the JSON for a token- Parameters:
strJson- The JSONclientConfig- The client configurationserverConfig- The server configurationstrStoredNonce- The stored nonce- Returns:
- The Token
- Throws:
java.io.IOException- if an error occursTokenValidationException- If the token validation failed
-
parse
public Token parse(java.lang.String strJson, java.time.Instant creationTime, AuthClientConf clientConfig, AuthServerConf serverConfig, JWTParser jwtParser, java.lang.String strStoredNonce) throws java.io.IOException, TokenValidationException
parse the JSON for a token- Parameters:
strJson- The JSONcreationTime- The creation time of the tokenclientConfig- The client configurationserverConfig- The server configurationstrStoredNonce- The stored nonce- Returns:
- The Token
- Throws:
java.io.IOException- if an error occursTokenValidationException- If the token validation failed- Since:
- 2.0.0
-
getService
public static TokenService getService()
Deprecated.use dependency injection insteadThe token service instance- Returns:
- the token service instance
-
-