You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ra...@apache.org on 2019/01/04 13:30:49 UTC
[tomee] branch master updated (a011504 -> 662bf3f)
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git.
from a011504 Test Gitbox commit hook
new 89a84e4 some lambda improvements
new f53d63d use the constant
new 1dc3fb7 use lambdas
new b4ceb93 Not a good practice to instantiate a long
new 6ac5a5d collection improvements
new 91c40fb Some more lambda transformation
new 5419292 Adding logging and fixing some minor issues
new 66a4201 logging and minor fixes
new 57ca386 Improvement on message.
new 11e0a37 fixing logging class
new 5832a42 fixing claimbean logging
new 662bf3f closes apache/tomee#352 *Merged*
The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/tomee/microprofile/jwt/MPJWTFilter.java | 17 ++-------
.../tomee/microprofile/jwt/cdi/ClaimBean.java | 43 ++++++++--------------
.../microprofile/jwt/cdi/MPJWTCDIExtension.java | 11 +-----
.../jwt/config/ConfigurableJWTAuthContextInfo.java | 20 +++++-----
.../jwt/config/JWTAuthContextInfo.java | 6 ++-
...PJWTSecurityAnnotationsInterceptorsFeature.java | 8 ++--
.../jwt/principal/DefaultJWTCallerPrincipal.java | 2 +-
.../jwt/principal/JWTCallerPrincipal.java | 3 +-
.../jwt/principal/JWTCallerPrincipalFactory.java | 19 +++++-----
9 files changed, 52 insertions(+), 77 deletions(-)
[tomee] 06/12: Some more lambda transformation
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 91c40fb47e2d79d448ba581482c63491c9bb2f69
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 11:22:41 2019 -0200
Some more lambda transformation
---
.../org/apache/tomee/microprofile/jwt/MPJWTFilter.java | 15 +++++----------
.../tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java | 2 +-
.../microprofile/jwt/principal/JWTCallerPrincipal.java | 3 ++-
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
index b628bbd..8143a88 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
@@ -196,15 +196,10 @@ public class MPJWTFilter implements Filter {
final Set<Principal> principals = new LinkedHashSet<>();
final JsonWebToken namePrincipal = tokenFunction.apply(request);
principals.add(namePrincipal);
- principals.addAll(namePrincipal.getGroups().stream().map(new Function<String, Principal>() {
+ principals.addAll(namePrincipal.getGroups().stream().map(role -> (Principal) new Principal() {
@Override
- public Principal apply(final String role) {
- return (Principal) new Principal() {
- @Override
- public String getName() {
- return role;
- }
- };
+ public String getName() {
+ return role;
}
}).collect(Collectors.<Principal>toList()));
return new Subject(true, principals, Collections.emptySet(), Collections.emptySet());
@@ -230,7 +225,7 @@ public class MPJWTFilter implements Filter {
}
- private static abstract class MPJWTException extends RuntimeException {
+ private abstract static class MPJWTException extends RuntimeException {
public MPJWTException() {
super();
@@ -260,7 +255,7 @@ public class MPJWTFilter implements Filter {
private static class BadAuthorizationPrefixException extends MPJWTException {
- private String authorizationHeader;
+ private final String authorizationHeader;
public BadAuthorizationPrefixException(final String authorizationHeader) {
this.authorizationHeader = authorizationHeader;
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
index 2f7cf43..956ef94 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
@@ -95,7 +95,7 @@ public class MPJWTCDIExtension implements Extension {
types.stream()
.map(type -> new ClaimBean<>(bm, type))
- .forEach((Consumer<ClaimBean>) claimBean -> abd.addBean(claimBean));
+ .forEach((Consumer<ClaimBean>) abd::addBean);
abd.addBean()
.id(MPJWTCDIExtension.class.getName() + "#" + JsonWebToken.class.getName())
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipal.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipal.java
index e56b6d3..abcd745 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipal.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipal.java
@@ -54,8 +54,9 @@ public abstract class JWTCallerPrincipal implements JsonWebToken {
*/
public abstract String toString(final boolean showAll);
+ @Override
public <T> Optional<T> claim(final String claimName) {
- final T claim = (T) getClaim(claimName);
+ final T claim = getClaim(claimName);
return Optional.ofNullable(claim);
}
}
[tomee] 07/12: Adding logging and fixing some minor issues
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 5419292a83ffae80d5d2386262610c4f1baa89aa
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 11:53:14 2019 -0200
Adding logging and fixing some minor issues
---
.../apache/tomee/microprofile/jwt/MPJWTFilter.java | 8 ++------
.../apache/tomee/microprofile/jwt/cdi/ClaimBean.java | 2 +-
.../jwt/config/ConfigurableJWTAuthContextInfo.java | 19 ++++++++++---------
.../jwt/principal/JWTCallerPrincipalFactory.java | 11 +++++++----
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
index 8143a88..8143a8d 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTFilter.java
@@ -196,12 +196,7 @@ public class MPJWTFilter implements Filter {
final Set<Principal> principals = new LinkedHashSet<>();
final JsonWebToken namePrincipal = tokenFunction.apply(request);
principals.add(namePrincipal);
- principals.addAll(namePrincipal.getGroups().stream().map(role -> (Principal) new Principal() {
- @Override
- public String getName() {
- return role;
- }
- }).collect(Collectors.<Principal>toList()));
+ principals.addAll(namePrincipal.getGroups().stream().map(role -> (Principal) () -> role).collect(Collectors.<Principal>toList()));
return new Subject(true, principals, Collections.emptySet(), Collections.emptySet());
}
});
@@ -237,6 +232,7 @@ public class MPJWTFilter implements Filter {
public abstract int getStatus();
+ @Override
public abstract String getMessage();
}
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
index 1b895bd..2476cbc 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
@@ -50,7 +50,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.function.Supplier;
import java.util.logging.Logger;
@Vetoed
@@ -251,6 +250,7 @@ public class ClaimBean<T> implements Bean<T>, PassivationCapable {
final String claimValue = getClaimValue(key).toString();
return (T) PropertyEditors.getValue(type, claimValue);
} catch (Exception e) {
+ logger.warning(e.getMessage());
}
} else {
// handle Raw types
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
index b7c1dc1..5f2d0e0 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
@@ -67,6 +67,7 @@ public class ConfigurableJWTAuthContextInfo {
private Config config;
private JWTAuthContextInfo jwtAuthContextInfo;
+ private static final String PUBLIC_KEY_ERROR = "Could not read MicroProfile Public Key";
public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext context) {
this.config = ConfigProvider.getConfig();
@@ -123,7 +124,7 @@ public class ConfigurableJWTAuthContextInfo {
.map(Supplier::get)
.filter(keys -> !keys.isEmpty())
.findFirst()
- .orElseThrow(() -> new DeploymentException("Could not read MicroProfile Public Key: " + publicKey));
+ .orElseThrow(() -> new DeploymentException(": " + publicKey));
}
private Map<String, Key> readPublicKeysFromLocation(final String publicKeyLocation) {
@@ -139,7 +140,7 @@ public class ConfigurableJWTAuthContextInfo {
.map(Optional::get)
.findFirst()
.map(this::readPublicKeys)
- .orElseThrow(() -> new DeploymentException("Could not read MicroProfile Public Key from Location: " +
+ .orElseThrow(() -> new DeploymentException(PUBLIC_KEY_ERROR + " from Location: " +
publicKeyLocation));
}
@@ -153,7 +154,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(is));
} catch (final IOException e) {
throw new DeploymentException(
- "Could not read MicroProfile Public Key from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
}
}
@@ -168,14 +169,14 @@ public class ConfigurableJWTAuthContextInfo {
final File publicKeyFile = new File(locationURL.toURI());
if (!publicKeyFile.exists() || publicKeyFile.isDirectory()) {
throw new DeploymentException(
- "Could not read MicroProfile Public Key from Location: " +
+ PUBLIC_KEY_ERROR + " from Location: " +
publicKeyLocation +
". File does not exist or it is a directory.");
}
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException | URISyntaxException e) {
throw new DeploymentException(
- "Could not read MicroProfile Public Key from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
}
}
@@ -189,7 +190,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException e) {
throw new DeploymentException(
- "Could not read MicroProfile Public Key from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
}
}
@@ -199,7 +200,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException e) {
throw new DeploymentException(
- "Could not read MicroProfile Public Key from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
}
}
@@ -244,7 +245,7 @@ public class ConfigurableJWTAuthContextInfo {
final JsonWebKey key = JsonWebKey.Factory.newJwk(publicKey);
return Collections.singletonMap(key.getKeyId(), key.getKey());
} catch (final JoseException e) {
- throw new DeploymentException("Could not read MicroProfile Public Key JWK.", e);
+ throw new DeploymentException(PUBLIC_KEY_ERROR + " JWK.", e);
}
}
@@ -284,7 +285,7 @@ public class ConfigurableJWTAuthContextInfo {
.collect(Collectors.toMap(JsonWebKey::getKeyId, JsonWebKey::getKey));
return Collections.unmodifiableMap(keys);
} catch (final JoseException e) {
- throw new DeploymentException("Could not read MicroProfile Public Key JWK.", e);
+ throw new DeploymentException(PUBLIC_KEY_ERROR + " JWK.", e);
}
}
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
index 6ce6f8e..80c75b4 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
@@ -17,12 +17,14 @@
package org.apache.tomee.microprofile.jwt.principal;
import org.apache.tomee.microprofile.jwt.ParseException;
+import org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension;
import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ServiceLoader;
+import java.util.logging.Logger;
/**
* The factory class that provides the token string to JWTCallerPrincipal parsing for a given implementation.
@@ -30,7 +32,7 @@ import java.util.ServiceLoader;
public abstract class JWTCallerPrincipalFactory {
private static JWTCallerPrincipalFactory instance;
-
+ private static final Logger logger = Logger.getLogger(MPJWTCDIExtension.class.getName());
/**
* Obtain the JWTCallerPrincipalFactory that has been set or by using the ServiceLoader pattern.
*
@@ -85,7 +87,8 @@ public abstract class JWTCallerPrincipalFactory {
if (instance == null) {
ServiceLoader<JWTCallerPrincipalFactory> sl = ServiceLoader.load(JWTCallerPrincipalFactory.class, cl);
URL u = cl.getResource("/META-INF/services/org.apache.tomee.microprofile.jwt.JWTCallerPrincipalFactory");
- System.out.printf("JWTCallerPrincipalFactory, cl=%s, u=%s, sl=%s\n", cl, u, sl);
+ logger.info(String.format("JWTCallerPrincipalFactory, cl=%s, u=%s, sl=%s", cl, u, sl));
+
try {
for (JWTCallerPrincipalFactory spi : sl) {
if (instance != null) {
@@ -94,13 +97,13 @@ public abstract class JWTCallerPrincipalFactory {
+ spi.getClass().getName() + " and "
+ instance.getClass().getName());
} else {
- System.out.printf("sl=%s, loaded=%s\n", sl, spi);
+ logger.info(String.format("sl=%s, loaded=%s", sl, spi));
instance = spi;
}
}
} catch (final Throwable e) {
- System.err.printf("Warning: %s\n", e.getMessage());
+ logger.warning(String.format("Warning: %s", e.getMessage()));
}
}
return instance;
[tomee] 05/12: collection improvements
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 6ac5a5dcd6a32aabeaeda6d266ea83b5971f5bd7
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 11:22:27 2019 -0200
collection improvements
---
.../jwt/jaxrs/MPJWTSecurityAnnotationsInterceptorsFeature.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/jaxrs/MPJWTSecurityAnnotationsInterceptorsFeature.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/jaxrs/MPJWTSecurityAnnotationsInterceptorsFeature.java
index 58b3203..9267473 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/jaxrs/MPJWTSecurityAnnotationsInterceptorsFeature.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/jaxrs/MPJWTSecurityAnnotationsInterceptorsFeature.java
@@ -59,7 +59,7 @@ public class MPJWTSecurityAnnotationsInterceptorsFeature implements DynamicFeatu
final List<Class<? extends Annotation>[]> methodSecurityAnnotations = hasMethodLevelAnnotations(method,
RolesAllowed.class, PermitAll.class, DenyAll.class);
- if (classSecurityAnnotations.size() == 0 && methodSecurityAnnotations.size() == 0) {
+ if (classSecurityAnnotations.isEmpty() && methodSecurityAnnotations.isEmpty()) {
return false; // nothing to do
}
@@ -74,13 +74,13 @@ public class MPJWTSecurityAnnotationsInterceptorsFeature implements DynamicFeatu
throw new IllegalStateException(method.toString() + " has more than one security annotation (RolesAllowed, PermitAll, DenyAll).");
}
- if (methodSecurityAnnotations.size() == 0) { // no need to deal with class level annotations if the method has some
+ if (methodSecurityAnnotations.isEmpty()) { // no need to deal with class level annotations if the method has some
final RolesAllowed classRolesAllowed = (RolesAllowed) clazz.getAnnotation(RolesAllowed.class);
final PermitAll classPermitAll = (PermitAll) clazz.getAnnotation(PermitAll.class);
final DenyAll classDenyAll = (DenyAll) clazz.getAnnotation(DenyAll.class);
if (classRolesAllowed != null) {
- Set<String> roles = new HashSet<String>();
+ Set<String> roles = new HashSet<>();
final Set<String> previous = rolesAllowed.putIfAbsent(method, roles);
if (previous != null) {
roles = previous;
@@ -102,7 +102,7 @@ public class MPJWTSecurityAnnotationsInterceptorsFeature implements DynamicFeatu
final DenyAll mthdDenyAll = method.getAnnotation(DenyAll.class);
if (mthdRolesAllowed != null) {
- Set<String> roles = new HashSet<String>();
+ Set<String> roles = new HashSet<>();
final Set<String> previous = rolesAllowed.putIfAbsent(method, roles);
if (previous != null) {
roles = previous;
[tomee] 11/12: fixing claimbean logging
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 5832a429c49e83ec13a712d5eb2c7ee826e7563f
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Fri Jan 4 10:10:03 2019 -0200
fixing claimbean logging
---
.../src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
index 7e6a758..f2948f2 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
@@ -55,7 +55,7 @@ import java.util.logging.Logger;
@Vetoed
public class ClaimBean<T> implements Bean<T>, PassivationCapable {
- private static final Logger logger = Logger.getLogger(MPJWTCDIExtension.class.getName());
+ private static final Logger logger = Logger.getLogger(ClaimBean.class.getName());
private static final Set<Annotation> QUALIFIERS = new HashSet<>();
[tomee] 01/12: some lambda improvements
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 89a84e4abbc09b0ffed875301530331d97103cca
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Wed Jan 2 16:50:50 2019 -0200
some lambda improvements
---
.../apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java | 11 ++---------
.../microprofile/jwt/principal/JWTCallerPrincipalFactory.java | 9 +++------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
index 00fc24e..2f7cf43 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/MPJWTCDIExtension.java
@@ -24,9 +24,7 @@ import org.apache.tomee.microprofile.jwt.jaxrs.MPJWPProviderRegistration;
import org.eclipse.microprofile.jwt.Claim;
import org.eclipse.microprofile.jwt.JsonWebToken;
-import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
-import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Any;
@@ -67,7 +65,7 @@ public class MPJWTCDIExtension implements Extension {
private Set<InjectionPoint> injectionPoints = new HashSet<>();
- public void collectConfigProducer(@Observes final ProcessInjectionPoint<?, ?> pip, final BeanManager bm) {
+ public void collectConfigProducer(@Observes final ProcessInjectionPoint<?, ?> pip) {
final Claim claim = pip.getInjectionPoint().getAnnotated().getAnnotation(Claim.class);
if (claim != null) {
injectionPoints.add(pip.getInjectionPoint());
@@ -97,12 +95,7 @@ public class MPJWTCDIExtension implements Extension {
types.stream()
.map(type -> new ClaimBean<>(bm, type))
- .forEach(new Consumer<ClaimBean>() {
- @Override
- public void accept(final ClaimBean claimBean) {
- abd.addBean(claimBean);
- }
- });
+ .forEach((Consumer<ClaimBean>) claimBean -> abd.addBean(claimBean));
abd.addBean()
.id(MPJWTCDIExtension.class.getName() + "#" + JsonWebToken.class.getName())
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
index e7ebcd6..6ce6f8e 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
@@ -44,12 +44,9 @@ public abstract class JWTCallerPrincipalFactory {
return instance;
}
- ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
+ ClassLoader cl = AccessController.doPrivileged(
+ (PrivilegedAction<ClassLoader>) () -> Thread.currentThread().getContextClassLoader()
+ );
if (cl == null) {
cl = JWTCallerPrincipalFactory.class.getClassLoader();
}
[tomee] 08/12: logging and minor fixes
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 66a42016730b113dedea0a17f0427d0eab3d4e98
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 13:05:52 2019 -0200
logging and minor fixes
---
.../main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java | 2 +-
.../org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
index 2476cbc..7e6a758 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
@@ -274,7 +274,7 @@ public class ClaimBean<T> implements Bean<T>, PassivationCapable {
}
JsonWebToken jsonWebToken = null;
- if (! JsonWebToken.class.isInstance(principal)) {
+ if (!JsonWebToken.class.isInstance(principal)) {
logger.warning(String.format("Can't retrieve claim %s. Active principal is not a JWT.", name));
return null;
}
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
index 4cfa333..447cb2f 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
@@ -16,6 +16,7 @@
*/
package org.apache.tomee.microprofile.jwt.config;
+import org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension;
import org.jose4j.jwk.JsonWebKey;
import org.jose4j.lang.JoseException;
@@ -23,12 +24,14 @@ import java.security.Key;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
* The public key and expected issuer needed to validate a token.
*/
public class JWTAuthContextInfo {
+ private static final Logger logger = Logger.getLogger(MPJWTCDIExtension.class.getName());
public static final String DEFAULT_KEY = "DEFAULT";
private Map<String, Key> signerKeys;
@@ -73,7 +76,7 @@ public class JWTAuthContextInfo {
jsonWebKey.setKeyId(key.getKey());
return jsonWebKey;
} catch (final JoseException e) {
- e.printStackTrace();
+ logger.warning(e.getMessage());
return null;
}
}).collect(Collectors.toList());
[tomee] 10/12: fixing logging class
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 11e0a37935490f4c09c0eb217ad3348d1e75a1c3
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Fri Jan 4 10:02:49 2019 -0200
fixing logging class
---
.../org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java | 3 +--
.../tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
index 447cb2f..6fe507f 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
@@ -16,7 +16,6 @@
*/
package org.apache.tomee.microprofile.jwt.config;
-import org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension;
import org.jose4j.jwk.JsonWebKey;
import org.jose4j.lang.JoseException;
@@ -31,7 +30,7 @@ import java.util.stream.Collectors;
* The public key and expected issuer needed to validate a token.
*/
public class JWTAuthContextInfo {
- private static final Logger logger = Logger.getLogger(MPJWTCDIExtension.class.getName());
+ private static final Logger logger = Logger.getLogger(JWTAuthContextInfo.class.getName());
public static final String DEFAULT_KEY = "DEFAULT";
private Map<String, Key> signerKeys;
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
index 80c75b4..2d36161 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java
@@ -17,7 +17,6 @@
package org.apache.tomee.microprofile.jwt.principal;
import org.apache.tomee.microprofile.jwt.ParseException;
-import org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension;
import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
import java.net.URL;
@@ -32,7 +31,7 @@ import java.util.logging.Logger;
public abstract class JWTCallerPrincipalFactory {
private static JWTCallerPrincipalFactory instance;
- private static final Logger logger = Logger.getLogger(MPJWTCDIExtension.class.getName());
+ private static final Logger logger = Logger.getLogger(JWTCallerPrincipalFactory.class.getName());
/**
* Obtain the JWTCallerPrincipalFactory that has been set or by using the ServiceLoader pattern.
*
[tomee] 12/12: closes apache/tomee#352 *Merged*
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 662bf3f5b92699ea4498dcccd4b4aa3981eb241e
Author: Roberto Cortez <ra...@yahoo.com>
AuthorDate: Fri Jan 4 13:30:41 2019 +0000
closes apache/tomee#352 *Merged*
[tomee] 09/12: Improvement on message.
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 57ca3864531ceddffe42bf2864a117bbd7a15686
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 13:16:06 2019 -0200
Improvement on message.
---
.../jwt/config/ConfigurableJWTAuthContextInfo.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
index 5f2d0e0..e52efab 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/ConfigurableJWTAuthContextInfo.java
@@ -68,6 +68,7 @@ public class ConfigurableJWTAuthContextInfo {
private Config config;
private JWTAuthContextInfo jwtAuthContextInfo;
private static final String PUBLIC_KEY_ERROR = "Could not read MicroProfile Public Key";
+ private static final String PUBLIC_KEY_ERROR_LOCATION = PUBLIC_KEY_ERROR + " from Location: ";
public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext context) {
this.config = ConfigProvider.getConfig();
@@ -140,7 +141,7 @@ public class ConfigurableJWTAuthContextInfo {
.map(Optional::get)
.findFirst()
.map(this::readPublicKeys)
- .orElseThrow(() -> new DeploymentException(PUBLIC_KEY_ERROR + " from Location: " +
+ .orElseThrow(() -> new DeploymentException(PUBLIC_KEY_ERROR_LOCATION +
publicKeyLocation));
}
@@ -154,7 +155,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(is));
} catch (final IOException e) {
throw new DeploymentException(
- PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR_LOCATION + publicKeyLocation, e);
}
}
@@ -169,14 +170,14 @@ public class ConfigurableJWTAuthContextInfo {
final File publicKeyFile = new File(locationURL.toURI());
if (!publicKeyFile.exists() || publicKeyFile.isDirectory()) {
throw new DeploymentException(
- PUBLIC_KEY_ERROR + " from Location: " +
+ PUBLIC_KEY_ERROR_LOCATION +
publicKeyLocation +
". File does not exist or it is a directory.");
}
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException | URISyntaxException e) {
throw new DeploymentException(
- PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR_LOCATION + publicKeyLocation, e);
}
}
@@ -190,7 +191,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException e) {
throw new DeploymentException(
- PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR_LOCATION + publicKeyLocation, e);
}
}
@@ -200,7 +201,7 @@ public class ConfigurableJWTAuthContextInfo {
return Optional.of(readPublicKeyFromInputStream(locationURL.openStream()));
} catch (final IOException e) {
throw new DeploymentException(
- PUBLIC_KEY_ERROR + " from Location: " + publicKeyLocation, e);
+ PUBLIC_KEY_ERROR_LOCATION + publicKeyLocation, e);
}
}
[tomee] 03/12: use lambdas
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 1dc3fb71e8ab1582ac48439b5f5533a3143d58e4
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 11:15:47 2019 -0200
use lambdas
---
.../tomee/microprofile/jwt/cdi/ClaimBean.java | 37 +++++++---------------
1 file changed, 12 insertions(+), 25 deletions(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
index 1f5e2ed..1b895bd 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/cdi/ClaimBean.java
@@ -23,7 +23,6 @@ import org.eclipse.microprofile.jwt.Claims;
import org.eclipse.microprofile.jwt.JsonWebToken;
import javax.enterprise.context.Dependent;
-import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Vetoed;
@@ -196,39 +195,27 @@ public class ClaimBean<T> implements Bean<T>, PassivationCapable {
final ClaimValueWrapper claimValueWrapper = new ClaimValueWrapper(key);
if (ParameterizedType.class.isInstance(claimValueType) && isOptional(ParameterizedType.class.cast(claimValueType))) {
- claimValueWrapper.setValue(new Supplier() {
- @Override
- public Object get() {
- final T claimValue = ClaimBean.this.getClaimValue(key);
- return Optional.ofNullable(claimValue);
- }
+ claimValueWrapper.setValue(() -> {
+ final T claimValue = ClaimBean.this.getClaimValue(key);
+ return Optional.ofNullable(claimValue);
});
} else if (ParameterizedType.class.isInstance(claimValueType) && isSet(ParameterizedType.class.cast(claimValueType))) {
- claimValueWrapper.setValue(new Supplier() {
- @Override
- public Object get() {
- final T claimValue = ClaimBean.this.getClaimValue(key);
- return claimValue;
- }
+ claimValueWrapper.setValue(() -> {
+ final T claimValue = ClaimBean.this.getClaimValue(key);
+ return claimValue;
});
} else if (ParameterizedType.class.isInstance(claimValueType) && isList(ParameterizedType.class.cast(claimValueType))) {
- claimValueWrapper.setValue(new Supplier() {
- @Override
- public Object get() {
- final T claimValue = ClaimBean.this.getClaimValue(key);
- return claimValue;
- }
+ claimValueWrapper.setValue(() -> {
+ final T claimValue = ClaimBean.this.getClaimValue(key);
+ return claimValue;
});
} else if (Class.class.isInstance(claimValueType)) {
- claimValueWrapper.setValue(new Supplier() {
- @Override
- public Object get() {
- final T claimValue = ClaimBean.this.getClaimValue(key);
- return claimValue;
- }
+ claimValueWrapper.setValue(() -> {
+ final T claimValue = ClaimBean.this.getClaimValue(key);
+ return claimValue;
});
} else {
[tomee] 04/12: Not a good practice to instantiate a long
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit b4ceb936e7ddf509ee182b7237790705c1f481d0
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Thu Jan 3 11:16:25 2019 -0200
Not a good practice to instantiate a long
---
.../tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipal.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipal.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipal.java
index 991fd4f..12f3044 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipal.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/principal/DefaultJWTCallerPrincipal.java
@@ -126,7 +126,7 @@ public class DefaultJWTCallerPrincipal extends JWTCallerPrincipal {
try {
claim = claimsSet.getClaimValue(claimType.name(), Long.class);
if (claim == null) {
- claim = new Long(0);
+ claim = 0L;
}
} catch (final MalformedClaimException e) {
logger.log(Level.FINEST, "Can't retrieve 'updated_at' a malformed claim.", e);
[tomee] 02/12: use the constant
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit f53d63d0b55c7869833825dc168909a029ff96ea
Author: ivanjunckes <ij...@tomitribe.com>
AuthorDate: Wed Jan 2 16:51:09 2019 -0200
use the constant
---
.../org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
index 4b38878..4cfa333 100644
--- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
+++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthContextInfo.java
@@ -63,7 +63,7 @@ public class JWTAuthContextInfo {
}
public Key getSignerKey() {
- return signerKeys.get("DEFAULT");
+ return signerKeys.get(DEFAULT_KEY);
}
public List<JsonWebKey> getSignerKeys() {