Class JWTTokenProvider
- java.lang.Object
-
- org.kohsuke.github.extras.authorization.JWTTokenProvider
-
- All Implemented Interfaces:
AuthorizationProvider
public class JWTTokenProvider extends Object implements 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
Constructors Constructor Description JWTTokenProvider(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getEncodedAuthorization()
Returns the credentials to be used with a given request.
-
-
-
Constructor Detail
-
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
public JWTTokenProvider(String applicationId, String keyString) throws GeneralSecurityException
Create a JWTTokenProvider- Parameters:
applicationId
- the application idkeyString
- the key string- Throws:
GeneralSecurityException
- when an error occurs
-
JWTTokenProvider
public JWTTokenProvider(String applicationId, PrivateKey privateKey)
Create a JWTTokenProvider- Parameters:
applicationId
- the application idprivateKey
- the private key
-
-
Method Detail
-
getEncodedAuthorization
public String getEncodedAuthorization() throws IOException
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
-
-