Skip to content

Commit

Permalink
Merge pull request wildfly-extras#77 from mchoma/elytron
Browse files Browse the repository at this point in the history
Address WFCORE-2393
  • Loading branch information
mchoma authored Mar 21, 2017
2 parents e8b0e7a + 39e2246 commit 3f5f5a7
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.wildfly.extras.creaper.core.online.OnlineCommand;
import org.wildfly.extras.creaper.core.online.OnlineCommandContext;
import org.wildfly.extras.creaper.core.online.operations.Address;
Expand Down Expand Up @@ -41,6 +42,8 @@ public void apply(OnlineCommandContext ctx) throws Exception {
.andListOptional(String.class, "issuer", jwt.getIssuer())
.andListOptional(String.class, "audience", jwt.getAudience())
.andOptional("public-key", jwt.getPublicKey())
.andOptional("key-store", jwt.getKeyStore())
.andOptional("certificate", jwt.getCertificate())
: null;

Values oauth2IntrospectionProperties = oauth2Introspection != null
Expand Down Expand Up @@ -122,11 +125,15 @@ public static final class Jwt {
private final List<String> issuer;
private final List<String> audience;
private final String publicKey;
private final String keyStore;
private final String certificate;

public Jwt(JwtBuilder builder) {
this.issuer = builder.issuer;
this.audience = builder.audience;
this.publicKey = builder.publicKey;
this.keyStore = builder.keyStore;
this.certificate = builder.certificate;
}

public List<String> getIssuer() {
Expand All @@ -141,13 +148,23 @@ public String getPublicKey() {
return publicKey;
}

public String getKeyStore() {
return keyStore;
}

public String getCertificate() {
return certificate;
}

}

public static final class JwtBuilder {

private List<String> issuer;
private List<String> audience;
private String publicKey;
private String keyStore;
private String certificate;

public JwtBuilder addIssuer(String... issuer) {
if (issuer == null) {
Expand All @@ -174,13 +191,20 @@ public JwtBuilder addAudience(String... audience) {
}

public JwtBuilder publicKey(String publicKey) {
if (publicKey == null || publicKey.isEmpty()) {
throw new IllegalArgumentException("Public-key must not be null and must have a minimum length of 1 character");
}
this.publicKey = publicKey;
return this;
}

public JwtBuilder keyStore(String keyStore) {
this.keyStore = keyStore;
return this;
}

public JwtBuilder certificate(String certificate) {
this.certificate = certificate;
return this;
}

public Jwt build() {
return new Jwt(this);
}
Expand Down

0 comments on commit 3f5f5a7

Please sign in to comment.