You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2018/04/16 22:45:23 UTC
[19/38] tomee git commit: Formating
Formating
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/812cfed9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/812cfed9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/812cfed9
Branch: refs/heads/master
Commit: 812cfed9bc64f6d5985d507dd00b62cbfa5215bc
Parents: c5964e0
Author: Jean-Louis Monteiro <je...@gmail.com>
Authored: Tue Feb 27 10:23:02 2018 +0100
Committer: Jean-Louis Monteiro <je...@gmail.com>
Committed: Tue Feb 27 10:23:02 2018 +0100
----------------------------------------------------------------------
.../apache/tomee/microprofile/jwt/KeyUtils.java | 5 +-
.../tomee/microprofile/jwt/MPJWTContext.java | 1 -
.../microprofile/jwt/MPJWTInitializer.java | 1 -
.../tomee/microprofile/jwt/TCKTokenParser.java | 4 +-
.../microprofile/jwt/cdi/ClaimLiteral.java | 4 +-
.../jwt/cdi/ClaimProviderBeanAttributes.java | 14 ++--
.../jwt/cdi/ClaimValueProducer.java | 14 ++--
.../microprofile/jwt/cdi/MPJWTCDIExtension.java | 88 ++++++++------------
.../microprofile/jwt/cdi/MPJWTProducer.java | 50 +++++------
.../jwt/config/JWTAuthContextInfo.java | 3 +-
.../DefaultJWTCallerPrincipalFactory.java | 2 +-
.../principal/JWTCallerPrincipalFactory.java | 2 +-
12 files changed, 85 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/KeyUtils.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/KeyUtils.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/KeyUtils.java
index 07e00f2..c65ea98 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/KeyUtils.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/KeyUtils.java
@@ -28,6 +28,9 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
public class KeyUtils {
+ private KeyUtils() {
+ }
+
public static PrivateKey readPrivateKey(String pemResName) throws Exception {
InputStream contentIS = KeyUtils.class.getResourceAsStream(pemResName);
byte[] tmp = new byte[4096];
@@ -79,6 +82,4 @@ public class KeyUtils {
pem = pem.replaceAll("\n", "");
return pem.trim();
}
- private KeyUtils() {
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTContext.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTContext.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTContext.java
index 07dfe0b..50b7d1e 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTContext.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTContext.java
@@ -16,7 +16,6 @@
*/
package org.apache.tomee.microprofile.jwt;
-import javax.enterprise.context.ApplicationScoped;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java
index bb8bb16..8fa9259 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java
@@ -18,7 +18,6 @@ package org.apache.tomee.microprofile.jwt;
import org.eclipse.microprofile.auth.LoginConfig;
-import javax.inject.Inject;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/TCKTokenParser.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/TCKTokenParser.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/TCKTokenParser.java
index 0c65795..aeea598 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/TCKTokenParser.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/TCKTokenParser.java
@@ -32,8 +32,8 @@ public class TCKTokenParser implements ITokenParser {
@Override
public JsonWebToken parse(String bearerToken, String issuer, PublicKey publicKey) throws Exception {
- JWTAuthContextInfo authContextInfo = new JWTAuthContextInfo((RSAPublicKey) publicKey, issuer);
- JWTCallerPrincipalFactory factory = DefaultJWTCallerPrincipalFactory.instance();
+ final JWTAuthContextInfo authContextInfo = new JWTAuthContextInfo((RSAPublicKey) publicKey, issuer);
+ final JWTCallerPrincipalFactory factory = DefaultJWTCallerPrincipalFactory.instance();
return factory.parse(bearerToken, authContextInfo);
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimLiteral.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimLiteral.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimLiteral.java
index 6c07f8c..319f122 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimLiteral.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimLiteral.java
@@ -16,11 +16,11 @@
*/
package org.apache.tomee.microprofile.jwt.cdi;
-import javax.enterprise.util.AnnotationLiteral;
-
import org.eclipse.microprofile.jwt.Claim;
import org.eclipse.microprofile.jwt.Claims;
+import javax.enterprise.util.AnnotationLiteral;
+
public class ClaimLiteral extends AnnotationLiteral<Claim> implements Claim {
public String value() {
return "";
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimProviderBeanAttributes.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimProviderBeanAttributes.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimProviderBeanAttributes.java
index 4c446c0..88e7724 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimProviderBeanAttributes.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimProviderBeanAttributes.java
@@ -16,18 +16,20 @@
*/
package org.apache.tomee.microprofile.jwt.cdi;
+import javax.enterprise.inject.spi.BeanAttributes;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
-import javax.enterprise.inject.spi.BeanAttributes;
-
/**
* An implementation of BeanAttributes<Object> that wraps the generic producer BeanAttributes
* to allow the MPJWTExtension to collect the types of all corresponding injection sites
- *
*/
public class ClaimProviderBeanAttributes implements BeanAttributes<Object> {
+ private BeanAttributes<Object> delegate;
+ private Set<Type> types;
+ private Set<Annotation> qualifiers;
+
/**
* Decorate the ConfigPropertyProducer BeanAttributes to set the types the producer applies to. This set is collected
* from all injection points annotated with @ConfigProperty.
@@ -74,10 +76,4 @@ public class ClaimProviderBeanAttributes implements BeanAttributes<Object> {
return delegate.isAlternative();
}
- private BeanAttributes<Object> delegate;
-
- private Set<Type> types;
-
- private Set<Annotation> qualifiers;
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimValueProducer.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimValueProducer.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimValueProducer.java
index d69df02..1881401 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimValueProducer.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimValueProducer.java
@@ -16,20 +16,20 @@
*/
package org.apache.tomee.microprofile.jwt.cdi;
+import org.eclipse.microprofile.jwt.Claim;
+import org.eclipse.microprofile.jwt.ClaimValue;
+import org.eclipse.microprofile.jwt.Claims;
+
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Optional;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.eclipse.microprofile.jwt.Claim;
-import org.eclipse.microprofile.jwt.ClaimValue;
-import org.eclipse.microprofile.jwt.Claims;
-
/**
* A producer for the ClaimValue<T> wrapper injection sites.
+ *
* @param <T> the raw claim type
*/
public class ClaimValueProducer<T> {
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
index 95e1aea..3700494 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
@@ -16,10 +16,10 @@
*/
package org.apache.tomee.microprofile.jwt.cdi;
-import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfoProvider;
import org.apache.tomee.microprofile.jwt.MPJWTFilter;
import org.apache.tomee.microprofile.jwt.MPJWTInitializer;
import org.apache.tomee.microprofile.jwt.TCKTokenParser;
+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfoProvider;
import org.eclipse.microprofile.jwt.Claim;
import org.eclipse.microprofile.jwt.Claims;
@@ -64,6 +64,15 @@ import java.util.logging.Logger;
*/
public class MPJWTCDIExtension implements Extension {
private static Logger log = Logger.getLogger(MPJWTCDIExtension.class.getName());
+ /**
+ * A map of claim,type pairs to the injection site information
+ */
+ private HashMap<ClaimIPType, ClaimIP> claims = new HashMap<>();
+ private Set<Type> providerOptionalTypes = new HashSet<>();
+ private Set<Type> providerTypes = new HashSet<>();
+ private Set<Type> rawTypes = new HashSet<>();
+ private Set<Annotation> rawTypeQualifiers = new HashSet<>();
+ private Set<Annotation> providerQualifiers = new HashSet<>();
/**
* Register the MPJWTProducer JsonWebToken producer bean
@@ -243,24 +252,12 @@ public class MPJWTCDIExtension implements Extension {
}
/**
- * A map of claim,type pairs to the injection site information
- */
- private HashMap<ClaimIPType, ClaimIP> claims = new HashMap<>();
-
- private Set<Type> providerOptionalTypes = new HashSet<>();
-
- private Set<Type> providerTypes = new HashSet<>();
-
- private Set<Type> rawTypes = new HashSet<>();
-
- private Set<Annotation> rawTypeQualifiers = new HashSet<>();
-
- private Set<Annotation> providerQualifiers = new HashSet<>();
-
- /**
* A key for a claim,injection site type pair
*/
public static class ClaimIPType implements Comparable<ClaimIPType> {
+ private String claimName;
+ private Type ipType;
+
public ClaimIPType(String claimName, Type ipType) {
this.claimName = claimName;
this.ipType = ipType;
@@ -280,10 +277,6 @@ public class MPJWTCDIExtension implements Extension {
}
return compareTo;
}
-
- private String claimName;
-
- private Type ipType;
}
/**
@@ -291,6 +284,30 @@ public class MPJWTCDIExtension implements Extension {
*/
public static class ClaimIP {
/**
+ * The injection site value type
+ */
+ private Type matchType;
+ /**
+ * The actual type of of the ParameterizedType matchType
+ */
+ private Type valueType;
+ /**
+ * Is valueType actually wrapped in an Optional
+ */
+ private boolean isOptional;
+ private boolean isProviderSite;
+ private boolean isNonStandard;
+ private boolean isJsonValue;
+ /**
+ * The injection site @Claim annotation value
+ */
+ private Claim claim;
+ /**
+ * The location that share the @Claim/type combination
+ */
+ private HashSet<InjectionPoint> injectionPoints = new HashSet<>();
+
+ /**
* Create a ClaimIP from the injection site information
*
* @param matchType - the outer type of the injection site
@@ -360,36 +377,5 @@ public class MPJWTCDIExtension implements Extension {
", ips=" + injectionPoints +
'}';
}
-
- /**
- * The injection site value type
- */
- private Type matchType;
-
- /**
- * The actual type of of the ParameterizedType matchType
- */
- private Type valueType;
-
- /**
- * Is valueType actually wrapped in an Optional
- */
- private boolean isOptional;
-
- private boolean isProviderSite;
-
- private boolean isNonStandard;
-
- private boolean isJsonValue;
-
- /**
- * The injection site @Claim annotation value
- */
- private Claim claim;
-
- /**
- * The location that share the @Claim/type combination
- */
- private HashSet<InjectionPoint> injectionPoints = new HashSet<>();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTProducer.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTProducer.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTProducer.java
index f267437..42cc8ac 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTProducer.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTProducer.java
@@ -46,8 +46,8 @@ import java.util.logging.Logger;
*/
@ApplicationScoped
public class MPJWTProducer {
- private static Logger log = Logger.getLogger(MPJWTProducer.class.getName());
private static final String TMP = "tmp";
+ private static Logger log = Logger.getLogger(MPJWTProducer.class.getName());
private static ThreadLocal<JsonWebToken> currentPrincipal = new ThreadLocal<>();
public static void setJWTPrincipal(JsonWebToken principal) {
@@ -58,30 +58,6 @@ public class MPJWTProducer {
return currentPrincipal.get();
}
- @PostConstruct
- void init() {
- log.fine("MPJWTProducer initialized");
- }
-
- void observeRequestInitialized(@Observes @Initialized(RequestScoped.class) Object event) {
- log.finest(String.format("observeRequestInitialized, event=%s", event));
- }
-
- void observeRequestDestroyed(@Observes @Destroyed(RequestScoped.class) Object event) {
- log.finest(String.format("observeRequestDestroyed, event=%s", event));
- }
-
- /**
- * The @RequestScoped producer method for the current JsonWebToken
- *
- * @return
- */
- @Produces
- @RequestScoped
- JsonWebToken currentPrincipalOrNull() {
- return currentPrincipal.get();
- }
-
/**
* A utility method for accessing a claim from the current JsonWebToken as a ClaimValue<Optional<T>> object.
*
@@ -193,4 +169,28 @@ public class MPJWTProducer {
}
return jsonValue;
}
+
+ @PostConstruct
+ void init() {
+ log.fine("MPJWTProducer initialized");
+ }
+
+ void observeRequestInitialized(@Observes @Initialized(RequestScoped.class) Object event) {
+ log.finest(String.format("observeRequestInitialized, event=%s", event));
+ }
+
+ void observeRequestDestroyed(@Observes @Destroyed(RequestScoped.class) Object event) {
+ log.finest(String.format("observeRequestDestroyed, event=%s", event));
+ }
+
+ /**
+ * The @RequestScoped producer method for the current JsonWebToken
+ *
+ * @return
+ */
+ @Produces
+ @RequestScoped
+ JsonWebToken currentPrincipalOrNull() {
+ return currentPrincipal.get();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
index ef8c0b0..dad5f4d 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
@@ -22,6 +22,7 @@ import java.security.interfaces.RSAPublicKey;
* The public key and expected issuer needed to validate a token.
*/
public class JWTAuthContextInfo {
+
private RSAPublicKey signerKey;
private String issuedBy;
private int expGracePeriodSecs = 60;
@@ -29,7 +30,7 @@ public class JWTAuthContextInfo {
public JWTAuthContextInfo() {
}
- public JWTAuthContextInfo(RSAPublicKey signerKey, String issuedBy) {
+ public JWTAuthContextInfo(final RSAPublicKey signerKey, final String issuedBy) {
this.signerKey = signerKey;
this.issuedBy = issuedBy;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipalFactory.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipalFactory.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipalFactory.java
index a420dde..5bcaeed 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipalFactory.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipalFactory.java
@@ -16,8 +16,8 @@
*/
package org.apache.tomee.microprofile.jwt.principal;
-import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import org.apache.tomee.microprofile.jwt.ParseException;
+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import org.eclipse.microprofile.jwt.Claims;
import org.jose4j.jwa.AlgorithmConstraints;
import org.jose4j.jws.AlgorithmIdentifiers;
http://git-wip-us.apache.org/repos/asf/tomee/blob/812cfed9/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
----------------------------------------------------------------------
diff --git a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
index 3aec7f0..51ca256 100644
--- a/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
+++ b/tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
@@ -16,8 +16,8 @@
*/
package org.apache.tomee.microprofile.jwt.principal;
-import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import org.apache.tomee.microprofile.jwt.ParseException;
+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import java.net.URL;
import java.security.AccessController;