Skip to content

Commit

Permalink
Added basic maven publishing. Added more comments. Added the simpler
Browse files Browse the repository at this point in the history
generateJWTToken method.
  • Loading branch information
Stephen Agneta committed May 20, 2016
1 parent 6ba76b9 commit 4d28eef
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Build jar file within ./build/libs/jwtutil.jar
$ gradle all
```

## Publish Maven locally for testing

This will generate the default Maven POM file within ./build/publications/maven/pom-default.xml

```shell
$ gradle publishToMavenLocal
```



## Documentation

Expand Down
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ tasks.withType(FindBugs) {



/////////////////////////////////////////////////////////////////////////
// Maven publication //
/////////////////////////////////////////////////////////////////////////
publishing {
publications {
maven(MavenPublication) {
groupId 'org.bjond.jwtutils'
artifactId 'jwtutils'
version '1.0'

from components.java
}
}
}



// Does nothing. Compatability with my emacs macros
task deployroot (type: Copy){

Expand Down
30 changes: 21 additions & 9 deletions src/main/java/com/bjond/jwtutils/JWTUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,34 @@ public static JwtClaims validateTokenAndProcessClaims(final Key key,


/**
* Generates a JWT Token given a set of parameters common to JWT implementations.
* Generates a JWT Token given a set of parameters common to JWT
* implementations.
*
* @param bjondServerEncryptionKey The Base64 encoded Encyrption key
* @param bjondAdapterSubject The indended Subject of the generated token
* @param bjondAdapterAudience The intended Audience of the generated token
* @param issuer The indended Issuer of the generated token
* @param json JSON snippet that will be inserted into the claim under the key 'json'
* @param bjondServerEncryptionKey
* The Base64 encoded Encyrption key
* @param bjondAdapterSubject
* The indended Subject of the generated token
* @param bjondAdapterAudience
* The intended Audience of the generated token
* @param issuer
* The indended Issuer of the generated token
* @param json
* JSON snippet that will be inserted into the claim under the
* key 'json'
* @param expirationTimeMinutesInTheFuture
* The maximum number of minutes this generated token is valid.
* @return JWT token string of the form string.string.string
*
* @throws JoseException if any issue occurs during generation. Mostly likely a key issue.
* @throws JoseException
* if any issue occurs during generation. Mostly likely a key
* issue.
*/
public static String generateJWTToken(final String bjondServerEncryptionKey,
final String bjondAdapterSubject,
final String bjondAdapterAudience,
final String issuer,
final String json) throws JoseException {
final String json,
final int expirationTimeMinutesInTheFuture) throws JoseException {

final Key key = JWTUtil.generateAESKey(JWTUtil.base64Decode(bjondServerEncryptionKey));
final Map<String, List<String>> claimsMap = new HashMap<>();
Expand All @@ -122,7 +134,7 @@ public static String generateJWTToken(final String bjondServerEncryptionKey,
bjondAdapterAudience,
bjondAdapterSubject,
claimsMap,
1
expirationTimeMinutesInTheFuture
);
}

Expand Down

0 comments on commit 4d28eef

Please sign in to comment.