Module org.kohsuke.github.api
Class JWTTokenProvider
java.lang.Object
org.kohsuke.github.extras.authorization.JWTTokenProvider
- All Implemented Interfaces:
AuthorizationProvider
A authorization provider that gives valid JWT tokens. These tokens are then used to create a time-based token to
authenticate as an application. This token provider does not provide any kind of caching, and will always request a
new token to the API.
-
Field Summary
Fields inherited from interface org.kohsuke.github.authorization.AuthorizationProvider
ANONYMOUS
-
Constructor Summary
ConstructorDescriptionJWTTokenProvider
(String applicationId, File keyFile) Create a JWTTokenProviderJWTTokenProvider
(String applicationId, String keyString) Create a JWTTokenProviderJWTTokenProvider
(String applicationId, Path keyPath) Create a JWTTokenProviderJWTTokenProvider
(String applicationId, PrivateKey privateKey) Create a JWTTokenProvider -
Method Summary
Modifier and TypeMethodDescriptionReturns the credentials to be used with a given request.
-
Constructor Details
-
JWTTokenProvider
public JWTTokenProvider(String applicationId, File keyFile) throws GeneralSecurityException, IOException Create a JWTTokenProvider- Parameters:
applicationId
- the application idkeyFile
- the key file- Throws:
GeneralSecurityException
- when an error occursIOException
- when an error occurs
-
JWTTokenProvider
public JWTTokenProvider(String applicationId, Path keyPath) throws GeneralSecurityException, IOException Create a JWTTokenProvider- Parameters:
applicationId
- the application idkeyPath
- the key path- Throws:
GeneralSecurityException
- when an error occursIOException
- when an error occurs
-
JWTTokenProvider
Create a JWTTokenProvider- Parameters:
applicationId
- the application idkeyString
- the key string- Throws:
GeneralSecurityException
- when an error occurs
-
JWTTokenProvider
Create a JWTTokenProvider- Parameters:
applicationId
- the application idprivateKey
- the private key
-
-
Method Details
-
getEncodedAuthorization
Returns the credentials to be used with a given request. As an example, a authorization provider for a bearer token will return something like:@Override public String getEncodedAuthorization() { return "Bearer myBearerToken"; }
- Specified by:
getEncodedAuthorization
in interfaceAuthorizationProvider
- Returns:
- encoded authorization string, can be null
- Throws:
IOException
- on any error that prevents the provider from returning a valid authorization
-