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/12/12 16:02:25 UTC
[01/11] tomee git commit: TOMEE-2304 Improving MP-REST-JWT example
(WIP)
Repository: tomee
Updated Branches:
refs/heads/master a44544b6d -> 185b74a56
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
deleted file mode 100644
index 7020864..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun.rest;
-
-import org.eclipse.microprofile.jwt.Claim;
-import org.eclipse.microprofile.jwt.ClaimValue;
-import org.eclipse.microprofile.jwt.JsonWebToken;
-import org.superbiz.moviefun.Movie;
-import org.superbiz.moviefun.MoviesBean;
-
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.EJB;
-import javax.inject.Inject;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.SecurityContext;
-import java.util.List;
-
-@Path("movies")
-@Produces({"application/json"})
-public class MoviesRest {
-
- @EJB
- private MoviesBean service;
-
- @Inject
- @Claim("raw_token")
- private ClaimValue<String> rawToken;
-
- @Inject
- @Claim("iss")
- private ClaimValue<String> issuer;
-
- @Inject
- @Claim("jti")
- private ClaimValue<String> jti;
-
- @Inject
- private JsonWebToken jwtPrincipal;
-
- @Context
- private SecurityContext securityContext;
-
- @GET
- @Path("{id}")
- public Movie find(@PathParam("id") Long id) {
- return service.find(id);
- }
-
- @GET
- public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
- @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.getMovies(first, max, field, searchTerm);
- }
-
- @POST
- @Consumes("application/json")
- @RolesAllowed("create")
- public Movie addMovie(Movie movie) {
- service.addMovie(movie);
- return movie;
- }
-
- @PUT
- @Path("{id}")
- @Consumes("application/json")
- @RolesAllowed("update")
- public Movie editMovie(
- @PathParam("id") final long id,
- Movie movie
- ) {
- service.editMovie(movie);
- return movie;
- }
-
- @DELETE
- @Path("{id}")
- @RolesAllowed("delete")
- public void deleteMovie(@PathParam("id") long id) {
- service.deleteMovie(id);
- }
-
- @GET
- @Path("count")
- @Produces(MediaType.TEXT_PLAIN)
- public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.count(field, searchTerm);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/rest/GreetingService.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/rest/GreetingService.java
deleted file mode 100644
index eb4434e..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/rest/GreetingService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.rest;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import java.util.Locale;
-
-@Path("/greeting")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-public class GreetingService {
-
- @GET
- public String message() {
- return "Hi Microprofile JWT!";
- }
-
- @POST
- public String lowerCase(final String message) {
- return message.toLowerCase(Locale.ENGLISH);
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/resources/META-INF/persistence.xml b/examples/rest-mp-jwt/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index ec38aaa..0000000
--- a/examples/rest-mp-jwt/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
- <persistence-unit name="movie-unit">
- <jta-data-source>movieDatabase</jta-data-source>
- <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
- <class>org.superbiz.moviefun.Movie</class>
-
- <properties>
- <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
- </properties>
- </persistence-unit>
-</persistence>
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/tomee/tomee.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/tomee/tomee.xml b/examples/rest-mp-jwt/src/main/tomee/tomee.xml
deleted file mode 100644
index f25d5f8..0000000
--- a/examples/rest-mp-jwt/src/main/tomee/tomee.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<tomee>
- <Resource id="HSQLDB Database" type="DataSource">
- JdbcDriver org.hsqldb.jdbcDriver
- JdbcUrl jdbc:hsqldb:file:target/db/moviefun
- UserName sa
- Password
- </Resource>
-</tomee>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
deleted file mode 100644
index b18e64e..0000000
--- a/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun;
-
-import org.apache.cxf.feature.LoggingFeature;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.johnzon.jaxrs.JohnzonProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.superbiz.moviefun.rest.ApplicationConfig;
-import org.superbiz.moviefun.rest.LoadRest;
-import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
-import org.superbiz.moviefun.rest.MoviesRest;
-import org.superbiz.rest.GreetingService;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-
-import static java.util.Collections.singletonList;
-
-@RunWith(Arquillian.class)
-public class MoviesTest {
-
- @Deployment(testable = false)
- public static WebArchive createDeployment() {
- final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClasses(Movie.class, MoviesBean.class, MoviesTest.class, LoadRest.class)
- .addClasses(MoviesRest.class, GreetingService.class, ApplicationConfig.class)
- .addClass(MoviesMPJWTConfigurationProvider.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
- .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
-
- System.out.println(webArchive.toString(true));
-
- return webArchive;
- }
-
- @ArquillianResource
- private URL base;
-
- @Test
- public void sthg() throws Exception {
-
- final WebClient webClient = WebClient
- .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()), singletonList(new LoggingFeature()), null);
-
- webClient
- .reset()
- .path("/rest/greeting/")
- .get(String.class);
-
- final Collection<? extends Movie> movies = webClient
- .reset()
- .path("/rest/movies/")
- .header("Authorization", "Bearer " + token())
- .getCollection(Movie.class);
-
- System.out.println(movies);
- }
-
- private String token() throws Exception {
- HashMap<String, Long> timeClaims = new HashMap<>();
- return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java b/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
deleted file mode 100644
index 5aa34b4..0000000
--- a/examples/rest-mp-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.superbiz.moviefun;
-
-import com.nimbusds.jose.JOSEObjectType;
-import com.nimbusds.jose.JWSAlgorithm;
-import com.nimbusds.jose.JWSHeader;
-import com.nimbusds.jose.JWSSigner;
-import com.nimbusds.jose.crypto.MACSigner;
-import com.nimbusds.jose.crypto.RSASSASigner;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.SignedJWT;
-import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import org.eclipse.microprofile.jwt.Claims;
-
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.KeyFactory;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import static net.minidev.json.parser.JSONParser.DEFAULT_PERMISSIVE_MODE;
-
-/**
- * Utilities for generating a JWT for testing
- */
-public class TokenUtils {
- private TokenUtils() {
- }
-
- /**
- * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
- * test resource key.
- *
- * @param jsonResName - name of test resources file
- * @return the JWT string
- * @throws Exception on parse failure
- */
- public static String generateTokenString(String jsonResName) throws Exception {
- return generateTokenString(jsonResName, Collections.emptySet());
- }
-
- /**
- * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
- * test resource key, possibly with invalid fields.
- *
- * @param jsonResName - name of test resources file
- * @param invalidClaims - the set of claims that should be added with invalid values to test failure modes
- * @return the JWT string
- * @throws Exception on parse failure
- */
- public static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims) throws Exception {
- return generateTokenString(jsonResName, invalidClaims, null);
- }
-
- /**
- * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
- * test resource key, possibly with invalid fields.
- *
- * @param jsonResName - name of test resources file
- * @param invalidClaims - the set of claims that should be added with invalid values to test failure modes
- * @param timeClaims - used to return the exp, iat, auth_time claims
- * @return the JWT string
- * @throws Exception on parse failure
- */
- public static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims) throws Exception {
- if (invalidClaims == null) {
- invalidClaims = Collections.emptySet();
- }
- InputStream contentIS = TokenUtils.class.getResourceAsStream(jsonResName);
- byte[] tmp = new byte[4096];
- int length = contentIS.read(tmp);
- byte[] content = new byte[length];
- System.arraycopy(tmp, 0, content, 0, length);
-
- JSONParser parser = new JSONParser(DEFAULT_PERMISSIVE_MODE);
- JSONObject jwtContent = (JSONObject) parser.parse(content);
- // Change the issuer to INVALID_ISSUER for failure testing if requested
- if (invalidClaims.contains(InvalidClaims.ISSUER)) {
- jwtContent.put(Claims.iss.name(), "INVALID_ISSUER");
- }
- long currentTimeInSecs = currentTimeInSecs();
- long exp = currentTimeInSecs + 300;
- // Check for an input exp to override the default of now + 300 seconds
- if (timeClaims != null && timeClaims.containsKey(Claims.exp.name())) {
- exp = timeClaims.get(Claims.exp.name());
- }
- jwtContent.put(Claims.iat.name(), currentTimeInSecs);
- jwtContent.put(Claims.auth_time.name(), currentTimeInSecs);
- // If the exp claim is not updated, it will be an old value that should be seen as expired
- if (!invalidClaims.contains(InvalidClaims.EXP)) {
- jwtContent.put(Claims.exp.name(), exp);
- }
- if (timeClaims != null) {
- timeClaims.put(Claims.iat.name(), currentTimeInSecs);
- timeClaims.put(Claims.auth_time.name(), currentTimeInSecs);
- timeClaims.put(Claims.exp.name(), exp);
- }
-
- PrivateKey pk;
- if (invalidClaims.contains(InvalidClaims.SIGNER)) {
- // Generate a new random private key to sign with to test invalid signatures
- KeyPair keyPair = generateKeyPair(2048);
- pk = keyPair.getPrivate();
- } else {
- // Use the test private key associated with the test public key for a valid signature
- pk = readPrivateKey("/privateKey.pem");
- }
-
- // Create RSA-signer with the private key
- JWSSigner signer = new RSASSASigner(pk);
- JWTClaimsSet claimsSet = JWTClaimsSet.parse(jwtContent);
- JWSAlgorithm alg = JWSAlgorithm.RS256;
- if (invalidClaims.contains(InvalidClaims.ALG)) {
- alg = JWSAlgorithm.HS256;
- SecureRandom random = new SecureRandom();
- BigInteger secret = BigInteger.probablePrime(256, random);
- signer = new MACSigner(secret.toByteArray());
- }
- JWSHeader jwtHeader = new JWSHeader.Builder(alg)
- .keyID("/privateKey.pem")
- .type(JOSEObjectType.JWT)
- .build();
- SignedJWT signedJWT = new SignedJWT(jwtHeader, claimsSet);
- signedJWT.sign(signer);
- return signedJWT.serialize();
- }
-
- /**
- * Read a PEM encoded private key from the classpath
- *
- * @param pemResName - key file resource name
- * @return PrivateKey
- * @throws Exception on decode failure
- */
- public static PrivateKey readPrivateKey(String pemResName) throws Exception {
- InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName);
- byte[] tmp = new byte[4096];
- int length = contentIS.read(tmp);
- return decodePrivateKey(new String(tmp, 0, length));
- }
-
- /**
- * Read a PEM encoded public key from the classpath
- *
- * @param pemResName - key file resource name
- * @return PublicKey
- * @throws Exception on decode failure
- */
- public static PublicKey readPublicKey(String pemResName) throws Exception {
- InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName);
- byte[] tmp = new byte[4096];
- int length = contentIS.read(tmp);
- return decodePublicKey(new String(tmp, 0, length));
- }
-
- /**
- * Generate a new RSA keypair.
- *
- * @param keySize - the size of the key
- * @return KeyPair
- * @throws NoSuchAlgorithmException on failure to load RSA key generator
- */
- public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException {
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
- keyPairGenerator.initialize(keySize);
- return keyPairGenerator.genKeyPair();
- }
-
- /**
- * Decode a PEM encoded private key string to an RSA PrivateKey
- *
- * @param pemEncoded - PEM string for private key
- * @return PrivateKey
- * @throws Exception on decode failure
- */
- public static PrivateKey decodePrivateKey(String pemEncoded) throws Exception {
- pemEncoded = removeBeginEnd(pemEncoded);
- byte[] pkcs8EncodedBytes = Base64.getDecoder().decode(pemEncoded);
-
- // extract the private key
-
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);
- KeyFactory kf = KeyFactory.getInstance("RSA");
- return kf.generatePrivate(keySpec);
- }
-
- /**
- * Decode a PEM encoded public key string to an RSA PublicKey
- *
- * @param pemEncoded - PEM string for private key
- * @return PublicKey
- * @throws Exception on decode failure
- */
- public static PublicKey decodePublicKey(String pemEncoded) throws Exception {
- pemEncoded = removeBeginEnd(pemEncoded);
- byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
-
- X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
- KeyFactory kf = KeyFactory.getInstance("RSA");
- return kf.generatePublic(spec);
- }
-
- private static String removeBeginEnd(String pem) {
- pem = pem.replaceAll("-----BEGIN (.*)-----", "");
- pem = pem.replaceAll("-----END (.*)----", "");
- pem = pem.replaceAll("\r\n", "");
- pem = pem.replaceAll("\n", "");
- return pem.trim();
- }
-
- /**
- * @return the current time in seconds since epoch
- */
- public static int currentTimeInSecs() {
- long currentTimeMS = System.currentTimeMillis();
- return (int) (currentTimeMS / 1000);
- }
-
- /**
- * Enums to indicate which claims should be set to invalid values for testing failure modes
- */
- public enum InvalidClaims {
- ISSUER, // Set an invalid issuer
- EXP, // Set an invalid expiration
- SIGNER, // Sign the token with the incorrect private key
- ALG, // Sign the token with the correct private key, but HS
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/examples/rest-mp-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
deleted file mode 100644
index f38063f..0000000
--- a/examples/rest-mp-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.rest;
-
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.openejb.jee.WebApp;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.testing.Classes;
-import org.apache.openejb.testing.EnableServices;
-import org.apache.openejb.testing.Module;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-
-@EnableServices(value = "jaxrs", httpDebug = true)
-@RunWith(ApplicationComposer.class)
-public class GreetingServiceTest {
-
- @Module
- @Classes(GreetingService.class)
- public WebApp app() {
- return new WebApp().contextRoot("test");
- }
-
- @Test
- public void get() throws IOException {
- final String message = WebClient.create("http://localhost:4204")
- .path("/test/greeting/")
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .get(String.class);
- assertEquals("Hi Microprofile JWT!", message);
- }
-
- @Test
- public void post() throws IOException {
- final String message = WebClient.create("http://localhost:4204")
- .path("/test/greeting/")
- .type(MediaType.APPLICATION_JSON_TYPE)
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .post("Hi REST!", String.class);
- assertEquals("hi rest!", message);
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/META-INF/application-client.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/META-INF/application-client.xml b/examples/rest-mp-jwt/src/test/resources/META-INF/application-client.xml
deleted file mode 100644
index 1e91dca..0000000
--- a/examples/rest-mp-jwt/src/test/resources/META-INF/application-client.xml
+++ /dev/null
@@ -1 +0,0 @@
-<application-client/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/Token1.json
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/Token1.json b/examples/rest-mp-jwt/src/test/resources/Token1.json
deleted file mode 100644
index 32b03c8..0000000
--- a/examples/rest-mp-jwt/src/test/resources/Token1.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "iss": "https://server.example.com",
- "jti": "a-123",
- "sub": "24400320",
- "upn": "jdoe@example.com",
- "preferred_username": "jdoe",
- "aud": "s6BhdRkqt3",
- "exp": 1311281970,
- "iat": 1311280970,
- "auth_time": 1311280969,
- "roles": [
- "Echoer"
- ],
- "groups": [
- "Echoer",
- "Tester",
- "group1",
- "group2"
- ]
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/Token2.json
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/Token2.json b/examples/rest-mp-jwt/src/test/resources/Token2.json
deleted file mode 100644
index d69f61a..0000000
--- a/examples/rest-mp-jwt/src/test/resources/Token2.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "iss": "https://server.example.com",
- "jti": "a-123.2",
- "sub": "24400320#2",
- "upn": "jdoe2@example.com",
- "preferred_username": "jdoe",
- "aud": "s6BhdRkqt3.2",
- "exp": 1311281970,
- "iat": 1311280970,
- "auth_time": 1311280969,
- "groups": ["Echoer2", "Tester", "Token2Role", "group1.2", "group2.2"]
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/arquillian.xml b/examples/rest-mp-jwt/src/test/resources/arquillian.xml
deleted file mode 100644
index 4744e7a..0000000
--- a/examples/rest-mp-jwt/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<arquillian
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- >
-
- <container qualifier="tomee" default="true">
- <configuration>
- <property name="httpPort">-1</property>
- <property name="stopPort">-1</property>
- <property name="classifier">microprofile</property>
- <property name="dir">target/apache-tomee-remote</property>
- <property name="appWorkingDir">target/arquillian-test-working-dir</property>
- </configuration>
- </container>
-</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/privateKey.pem
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/privateKey.pem b/examples/rest-mp-jwt/src/test/resources/privateKey.pem
deleted file mode 100644
index e20d80b..0000000
--- a/examples/rest-mp-jwt/src/test/resources/privateKey.pem
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWK8UjyoHgPTLa
-PLQJ8SoXLLjpHSjtLxMqmzHnFscqhTVVaDpCRCb6e3Ii/WniQTWw8RA7vf4djz4H
-OzvlfBFNgvUGZHXDwnmGaNVaNzpHYFMEYBhE8VGGiveSkzqeLZI+Y02G6sQAfDtN
-qqzM/l5QX8X34oQFaTBW1r49nftvCpITiwJvWyhkWtXP9RP8sXi1im5Vi3dhupOh
-nelk5n0BfajUYIbfHA6ORzjHRbt7NtBl0L2J+0/FUdHyKs6KMlFGNw8O0Dq88qnM
-uXoLJiewhg9332W3DFMeOveel+//cvDnRsCRtPgd4sXFPHh+UShkso7+DRsChXa6
-oGGQD3GdAgMBAAECggEAAjfTSZwMHwvIXIDZB+yP+pemg4ryt84iMlbofclQV8hv
-6TsI4UGwcbKxFOM5VSYxbNOisb80qasb929gixsyBjsQ8284bhPJR7r0q8h1C+jY
-URA6S4pk8d/LmFakXwG9Tz6YPo3pJziuh48lzkFTk0xW2Dp4SLwtAptZY/+ZXyJ6
-96QXDrZKSSM99Jh9s7a0ST66WoxSS0UC51ak+Keb0KJ1jz4bIJ2C3r4rYlSu4hHB
-Y73GfkWORtQuyUDa9yDOem0/z0nr6pp+pBSXPLHADsqvZiIhxD/O0Xk5I6/zVHB3
-zuoQqLERk0WvA8FXz2o8AYwcQRY2g30eX9kU4uDQAQKBgQDmf7KGImUGitsEPepF
-KH5yLWYWqghHx6wfV+fdbBxoqn9WlwcQ7JbynIiVx8MX8/1lLCCe8v41ypu/eLtP
-iY1ev2IKdrUStvYRSsFigRkuPHUo1ajsGHQd+ucTDf58mn7kRLW1JGMeGxo/t32B
-m96Af6AiPWPEJuVfgGV0iwg+HQKBgQCmyPzL9M2rhYZn1AozRUguvlpmJHU2DpqS
-34Q+7x2Ghf7MgBUhqE0t3FAOxEC7IYBwHmeYOvFR8ZkVRKNF4gbnF9RtLdz0DMEG
-5qsMnvJUSQbNB1yVjUCnDAtElqiFRlQ/k0LgYkjKDY7LfciZl9uJRl0OSYeX/qG2
-tRW09tOpgQKBgBSGkpM3RN/MRayfBtmZvYjVWh3yjkI2GbHA1jj1g6IebLB9SnfL
-WbXJErCj1U+wvoPf5hfBc7m+jRgD3Eo86YXibQyZfY5pFIh9q7Ll5CQl5hj4zc4Y
-b16sFR+xQ1Q9Pcd+BuBWmSz5JOE/qcF869dthgkGhnfVLt/OQzqZluZRAoGAXQ09
-nT0TkmKIvlza5Af/YbTqEpq8mlBDhTYXPlWCD4+qvMWpBII1rSSBtftgcgca9XLB
-MXmRMbqtQeRtg4u7dishZVh1MeP7vbHsNLppUQT9Ol6lFPsd2xUpJDc6BkFat62d
-Xjr3iWNPC9E9nhPPdCNBv7reX7q81obpeXFMXgECgYEAmk2Qlus3OV0tfoNRqNpe
-Mb0teduf2+h3xaI1XDIzPVtZF35ELY/RkAHlmWRT4PCdR0zXDidE67L6XdJyecSt
-FdOUH8z5qUraVVebRFvJqf/oGsXc4+ex1ZKUTbY0wqY1y9E39yvB3MaTmZFuuqk8
-f3cg+fr8aou7pr9SHhJlZCU=
------END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/test/resources/publicKey.pem
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/test/resources/publicKey.pem b/examples/rest-mp-jwt/src/test/resources/publicKey.pem
deleted file mode 100644
index a1dc20c..0000000
--- a/examples/rest-mp-jwt/src/test/resources/publicKey.pem
+++ /dev/null
@@ -1,9 +0,0 @@
------BEGIN RSA PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq
-Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR
-TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e
-UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9
-AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn
-sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x
-nQIDAQAB
------END RSA PUBLIC KEY-----
[09/11] tomee git commit: TOMEE-2304 Improved README.
Posted by jl...@apache.org.
TOMEE-2304 Improved README.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/28bb6d35
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/28bb6d35
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/28bb6d35
Branch: refs/heads/master
Commit: 28bb6d35641d82003cf0f96c6dd711e15f7269ed
Parents: 59c288b
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 11 23:09:23 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 11 23:09:23 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/README.md | 48 +++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/28bb6d35/examples/mp-rest-jwt/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/README.md b/examples/mp-rest-jwt/README.md
index b4c913f..60a4e62 100644
--- a/examples/mp-rest-jwt/README.md
+++ b/examples/mp-rest-jwt/README.md
@@ -1,5 +1,5 @@
# MP REST JWT
-This is a basic example on how to use MicroProfile JWT in TomEE.
+This is a basic example on how to configure and use MicroProfile JWT in TomEE.
## Run the tests for different scenarios related with JWT validation
@@ -7,7 +7,7 @@ This is a basic example on how to use MicroProfile JWT in TomEE.
## Configuration in TomEE
-The class `MoviesMPJWTConfigurationProvider.java` provide to TomEE figuration for JWT validation.
+The class `MoviesMPJWTConfigurationProvider.java` provides to TomEE the figuration need it for JWT validation.
package org.superbiz.moviefun.rest;
@@ -136,9 +136,49 @@ The test cases from this project are builded using Arquillian. The arquillian co
`src/test/resources/arquillian.xml`
The class `TokenUtils.java` is used during the test to act as an Authorization server who generates `Access Tokens` based
-on the configuration files `privateKey.pem`,`publicKey.pem`,`Token1.json`, and `Token2.json`.
+on the configuration files `privateKey.pem`,`publicKey.pem`,`Token1.json`, and `Token2.json`.
+`nimbus-jose-jwt` is the library used for JWT generation during the tests.
+
+`Token1.json`
+
+ {
+ "iss": "https://server.example.com",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "jdoe@example.com",
+ "preferred_username": "jdoe",
+ "aud": "s6BhdRkqt3",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "groups": [
+ "group1",
+ "group2",
+ "crud",
+ "read-only"
+ ]
+ }
+
+
+`Token2.json`
+
+ {
+ "iss": "https://server.example.com",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "alice@example.com",
+ "preferred_username": "alice",
+ "aud": "s6BhdRkqt3",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "groups": [
+ "read-only"
+ ]
+ }
+
+
-`nimbus-jose-jwt` is the library used for JWT generation during the testsĀ”.
## Test Scenarios
[03/11] tomee git commit: remove unnecesary dependencies
Posted by jl...@apache.org.
remove unnecesary dependencies
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/286306a5
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/286306a5
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/286306a5
Branch: refs/heads/master
Commit: 286306a5fbc9a611f66f421a82b35d1cde0a34f4
Parents: 5f0f577
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 4 22:22:49 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 4 22:22:49 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/pom.xml | 41 ---------------------------------------
1 file changed, 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/286306a5/examples/mp-rest-jwt/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/pom.xml b/examples/mp-rest-jwt/pom.xml
index 4169178..ea8319d 100644
--- a/examples/mp-rest-jwt/pom.xml
+++ b/examples/mp-rest-jwt/pom.xml
@@ -170,47 +170,6 @@
<version>${tomee.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>backbonejs</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- <version>3.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>handlebars</artifactId>
- <version>1.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- <version>2.1.0-1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>json2</artifactId>
- <version>20110223</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>less</artifactId>
- <version>1.6.0-1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>requirejs</artifactId>
- <version>2.1.10</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>requirejs-text</artifactId>
- <version>2.0.10</version>
- </dependency>
</dependencies>
<profiles>
[02/11] tomee git commit: TOMEE-2304 Improving MP-REST-JWT example
(WIP)
Posted by jl...@apache.org.
TOMEE-2304 Improving MP-REST-JWT example (WIP)
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5f0f5770
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5f0f5770
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5f0f5770
Branch: refs/heads/master
Commit: 5f0f577096d7a6603bfdb72ed838e3b87273afc4
Parents: b4cf3cf
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Mon Dec 3 17:30:53 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Mon Dec 3 17:30:53 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/README.md | 4 +
examples/mp-rest-jwt/pom.xml | 279 +++++++++++++++++++
.../main/java/org/superbiz/moviefun/Movie.java | 102 +++++++
.../java/org/superbiz/moviefun/MoviesBean.java | 91 ++++++
.../moviefun/rest/ApplicationConfig.java | 28 ++
.../org/superbiz/moviefun/rest/LoadRest.java | 42 +++
.../rest/MoviesMPJWTConfigurationProvider.java | 63 +++++
.../org/superbiz/moviefun/rest/MoviesRest.java | 113 ++++++++
.../java/org/superbiz/rest/GreetingService.java | 41 +++
.../src/main/resources/META-INF/persistence.xml | 31 +++
examples/mp-rest-jwt/src/main/tomee/tomee.xml | 27 ++
.../java/org/superbiz/moviefun/MoviesTest.java | 88 ++++++
.../java/org/superbiz/moviefun/TokenUtils.java | 257 +++++++++++++++++
.../org/superbiz/rest/GreetingServiceTest.java | 61 ++++
.../resources/META-INF/application-client.xml | 1 +
.../mp-rest-jwt/src/test/resources/Token1.json | 20 ++
.../mp-rest-jwt/src/test/resources/Token2.json | 12 +
.../src/test/resources/arquillian.xml | 32 +++
.../src/test/resources/privateKey.pem | 28 ++
.../src/test/resources/publicKey.pem | 9 +
examples/pom.xml | 2 +-
examples/rest-mp-jwt/README.md | 4 -
examples/rest-mp-jwt/pom.xml | 279 -------------------
.../main/java/org/superbiz/moviefun/Movie.java | 102 -------
.../java/org/superbiz/moviefun/MoviesBean.java | 91 ------
.../moviefun/rest/ApplicationConfig.java | 28 --
.../org/superbiz/moviefun/rest/LoadRest.java | 42 ---
.../rest/MoviesMPJWTConfigurationProvider.java | 63 -----
.../org/superbiz/moviefun/rest/MoviesRest.java | 113 --------
.../java/org/superbiz/rest/GreetingService.java | 41 ---
.../src/main/resources/META-INF/persistence.xml | 31 ---
examples/rest-mp-jwt/src/main/tomee/tomee.xml | 27 --
.../java/org/superbiz/moviefun/MoviesTest.java | 88 ------
.../java/org/superbiz/moviefun/TokenUtils.java | 257 -----------------
.../org/superbiz/rest/GreetingServiceTest.java | 61 ----
.../resources/META-INF/application-client.xml | 1 -
.../rest-mp-jwt/src/test/resources/Token1.json | 20 --
.../rest-mp-jwt/src/test/resources/Token2.json | 12 -
.../src/test/resources/arquillian.xml | 32 ---
.../src/test/resources/privateKey.pem | 28 --
.../src/test/resources/publicKey.pem | 9 -
41 files changed, 1330 insertions(+), 1330 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/README.md b/examples/mp-rest-jwt/README.md
new file mode 100644
index 0000000..b2dc71f
--- /dev/null
+++ b/examples/mp-rest-jwt/README.md
@@ -0,0 +1,4 @@
+index-group=Unrevised
+type=page
+status=published
+~~~~~~
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/pom.xml b/examples/mp-rest-jwt/pom.xml
new file mode 100644
index 0000000..4169178
--- /dev/null
+++ b/examples/mp-rest-jwt/pom.xml
@@ -0,0 +1,279 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>mp-rest-jwt</artifactId>
+ <version>8.0.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Examples :: MP REST JWT</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.version>8.0.0-SNAPSHOT</tomee.version>
+ <version.shrinkwrap.resolver>2.0.0</version.shrinkwrap.resolver>
+ <mp-jwt.version>1.0</mp-jwt.version>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>moviefun</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.18.1</version>
+ <configuration>
+ <reuseForks>false</reuseForks>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomee.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <configuration>
+ <tomeeClassifier>microprofile</tomeeClassifier>
+ <args>-Xmx512m -XX:PermSize=256m</args>
+ <config>${project.basedir}/src/main/tomee/</config>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Override dependency resolver with test version. This must go *BEFORE*
+ the Arquillian BOM. -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>${version.shrinkwrap.resolver}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ <!-- Now pull in our server-based unit testing framework -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>1.0.3.Final</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>https://repository.apache.org/content/groups/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>8.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.microprofile.jwt</groupId>
+ <artifactId>microprofile-jwt-auth-api</artifactId>
+ <version>${mp-jwt.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.nimbusds</groupId>
+ <artifactId>nimbus-jose-jwt</artifactId>
+ <version>4.23</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>backbonejs</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>bootstrap</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>handlebars</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ <version>2.1.0-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>json2</artifactId>
+ <version>20110223</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>less</artifactId>
+ <version>1.6.0-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>requirejs</artifactId>
+ <version>2.1.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>requirejs-text</artifactId>
+ <version>2.0.10</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>arquillian-tomee-embedded</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>mp-jwt</artifactId>
+ <version>${tomee.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>arquillian-tomee-remote</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>apache-tomee</artifactId>
+ <version>${tomee.version}</version>
+ <type>zip</type>
+ <classifier>microprofile</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
new file mode 100644
index 0000000..4e067bb
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement(name = "movie")
+public class Movie {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+ private String genre;
+ private int rating;
+
+ public Movie() {
+ }
+
+ public Movie(String title, String director, String genre, int rating, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.genre = genre;
+ this.rating = rating;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public int getRating() {
+ return rating;
+ }
+
+ public void setRating(int rating) {
+ this.rating = rating;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
new file mode 100644
index 0000000..2580c9f
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.EntityType;
+import java.util.List;
+
+@Stateless
+public class MoviesBean {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ public Movie find(Long id) {
+ return entityManager.find(Movie.class, id);
+ }
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void editMovie(Movie movie) {
+ entityManager.merge(movie);
+ }
+
+ public void deleteMovie(long id) {
+ Movie movie = entityManager.find(Movie.class, id);
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ if (maxResults != null) {
+ q.setMaxResults(maxResults);
+ }
+ if (firstResult != null) {
+ q.setFirstResult(firstResult);
+ }
+ return q.getResultList();
+ }
+
+ public int count(String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> cq = qb.createQuery(Long.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ cq.select(qb.count(root));
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ return entityManager.createQuery(cq).getSingleResult().intValue();
+ }
+
+ public void clean() {
+ entityManager.createQuery("delete from Movie").executeUpdate();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
new file mode 100644
index 0000000..5a7bd4d
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.eclipse.microprofile.auth.LoginConfig;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("/rest")
+@LoginConfig(authMethod = "MP-JWT")
+public class ApplicationConfig extends Application {
+ // let the server discover the endpoints
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
new file mode 100644
index 0000000..6969221
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.ejb.EJB;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("load")
+public class LoadRest {
+ @EJB
+ private MoviesBean moviesBean;
+
+ @POST
+ public void load() {
+ moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
+ moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
+ moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
+ moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
+ moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
+ moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
+ moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
new file mode 100644
index 0000000..3bea531
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Produces;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Optional;
+
+@Dependent
+public class MoviesMPJWTConfigurationProvider {
+
+ @Produces
+ Optional<JWTAuthContextInfo> getOptionalContextInfo() throws NoSuchAlgorithmException, InvalidKeySpecException {
+ JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
+
+ // todo use MP Config to load the configuration
+ contextInfo.setIssuedBy("https://server.example.com");
+
+ final String pemEncoded = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq" +
+ "Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR" +
+ "TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e" +
+ "UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9" +
+ "AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn" +
+ "sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x" +
+ "nQIDAQAB";
+ byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
+
+ final X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
+ final KeyFactory kf = KeyFactory.getInstance("RSA");
+ final RSAPublicKey pk = (RSAPublicKey) kf.generatePublic(spec);
+
+ contextInfo.setSignerKey(pk);
+
+ return Optional.of(contextInfo);
+ }
+
+ @Produces
+ JWTAuthContextInfo getContextInfo() throws InvalidKeySpecException, NoSuchAlgorithmException {
+ return getOptionalContextInfo().get();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
new file mode 100644
index 0000000..7020864
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.eclipse.microprofile.jwt.Claim;
+import org.eclipse.microprofile.jwt.ClaimValue;
+import org.eclipse.microprofile.jwt.JsonWebToken;
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.EJB;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.SecurityContext;
+import java.util.List;
+
+@Path("movies")
+@Produces({"application/json"})
+public class MoviesRest {
+
+ @EJB
+ private MoviesBean service;
+
+ @Inject
+ @Claim("raw_token")
+ private ClaimValue<String> rawToken;
+
+ @Inject
+ @Claim("iss")
+ private ClaimValue<String> issuer;
+
+ @Inject
+ @Claim("jti")
+ private ClaimValue<String> jti;
+
+ @Inject
+ private JsonWebToken jwtPrincipal;
+
+ @Context
+ private SecurityContext securityContext;
+
+ @GET
+ @Path("{id}")
+ public Movie find(@PathParam("id") Long id) {
+ return service.find(id);
+ }
+
+ @GET
+ public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
+ @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.getMovies(first, max, field, searchTerm);
+ }
+
+ @POST
+ @Consumes("application/json")
+ @RolesAllowed("create")
+ public Movie addMovie(Movie movie) {
+ service.addMovie(movie);
+ return movie;
+ }
+
+ @PUT
+ @Path("{id}")
+ @Consumes("application/json")
+ @RolesAllowed("update")
+ public Movie editMovie(
+ @PathParam("id") final long id,
+ Movie movie
+ ) {
+ service.editMovie(movie);
+ return movie;
+ }
+
+ @DELETE
+ @Path("{id}")
+ @RolesAllowed("delete")
+ public void deleteMovie(@PathParam("id") long id) {
+ service.deleteMovie(id);
+ }
+
+ @GET
+ @Path("count")
+ @Produces(MediaType.TEXT_PLAIN)
+ public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.count(field, searchTerm);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
new file mode 100644
index 0000000..eb4434e
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.Locale;
+
+@Path("/greeting")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class GreetingService {
+
+ @GET
+ public String message() {
+ return "Hi Microprofile JWT!";
+ }
+
+ @POST
+ public String lowerCase(final String message) {
+ return message.toLowerCase(Locale.ENGLISH);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml b/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..ec38aaa
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.moviefun.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/main/tomee/tomee.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/tomee/tomee.xml b/examples/mp-rest-jwt/src/main/tomee/tomee.xml
new file mode 100644
index 0000000..f25d5f8
--- /dev/null
+++ b/examples/mp-rest-jwt/src/main/tomee/tomee.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<tomee>
+ <Resource id="HSQLDB Database" type="DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:file:target/db/moviefun
+ UserName sa
+ Password
+ </Resource>
+</tomee>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
new file mode 100644
index 0000000..b18e64e
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.johnzon.jaxrs.JohnzonProvider;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.moviefun.rest.ApplicationConfig;
+import org.superbiz.moviefun.rest.LoadRest;
+import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
+import org.superbiz.moviefun.rest.MoviesRest;
+import org.superbiz.rest.GreetingService;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+
+import static java.util.Collections.singletonList;
+
+@RunWith(Arquillian.class)
+public class MoviesTest {
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesTest.class, LoadRest.class)
+ .addClasses(MoviesRest.class, GreetingService.class, ApplicationConfig.class)
+ .addClass(MoviesMPJWTConfigurationProvider.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
+ .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+
+ System.out.println(webArchive.toString(true));
+
+ return webArchive;
+ }
+
+ @ArquillianResource
+ private URL base;
+
+ @Test
+ public void sthg() throws Exception {
+
+ final WebClient webClient = WebClient
+ .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()), singletonList(new LoggingFeature()), null);
+
+ webClient
+ .reset()
+ .path("/rest/greeting/")
+ .get(String.class);
+
+ final Collection<? extends Movie> movies = webClient
+ .reset()
+ .path("/rest/movies/")
+ .header("Authorization", "Bearer " + token())
+ .getCollection(Movie.class);
+
+ System.out.println(movies);
+ }
+
+ private String token() throws Exception {
+ HashMap<String, Long> timeClaims = new HashMap<>();
+ return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
new file mode 100644
index 0000000..5aa34b4
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/TokenUtils.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.superbiz.moviefun;
+
+import com.nimbusds.jose.JOSEObjectType;
+import com.nimbusds.jose.JWSAlgorithm;
+import com.nimbusds.jose.JWSHeader;
+import com.nimbusds.jose.JWSSigner;
+import com.nimbusds.jose.crypto.MACSigner;
+import com.nimbusds.jose.crypto.RSASSASigner;
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.SignedJWT;
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import org.eclipse.microprofile.jwt.Claims;
+
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import static net.minidev.json.parser.JSONParser.DEFAULT_PERMISSIVE_MODE;
+
+/**
+ * Utilities for generating a JWT for testing
+ */
+public class TokenUtils {
+ private TokenUtils() {
+ }
+
+ /**
+ * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
+ * test resource key.
+ *
+ * @param jsonResName - name of test resources file
+ * @return the JWT string
+ * @throws Exception on parse failure
+ */
+ public static String generateTokenString(String jsonResName) throws Exception {
+ return generateTokenString(jsonResName, Collections.emptySet());
+ }
+
+ /**
+ * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
+ * test resource key, possibly with invalid fields.
+ *
+ * @param jsonResName - name of test resources file
+ * @param invalidClaims - the set of claims that should be added with invalid values to test failure modes
+ * @return the JWT string
+ * @throws Exception on parse failure
+ */
+ public static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims) throws Exception {
+ return generateTokenString(jsonResName, invalidClaims, null);
+ }
+
+ /**
+ * Utility method to generate a JWT string from a JSON resource file that is signed by the privateKey.pem
+ * test resource key, possibly with invalid fields.
+ *
+ * @param jsonResName - name of test resources file
+ * @param invalidClaims - the set of claims that should be added with invalid values to test failure modes
+ * @param timeClaims - used to return the exp, iat, auth_time claims
+ * @return the JWT string
+ * @throws Exception on parse failure
+ */
+ public static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims) throws Exception {
+ if (invalidClaims == null) {
+ invalidClaims = Collections.emptySet();
+ }
+ InputStream contentIS = TokenUtils.class.getResourceAsStream(jsonResName);
+ byte[] tmp = new byte[4096];
+ int length = contentIS.read(tmp);
+ byte[] content = new byte[length];
+ System.arraycopy(tmp, 0, content, 0, length);
+
+ JSONParser parser = new JSONParser(DEFAULT_PERMISSIVE_MODE);
+ JSONObject jwtContent = (JSONObject) parser.parse(content);
+ // Change the issuer to INVALID_ISSUER for failure testing if requested
+ if (invalidClaims.contains(InvalidClaims.ISSUER)) {
+ jwtContent.put(Claims.iss.name(), "INVALID_ISSUER");
+ }
+ long currentTimeInSecs = currentTimeInSecs();
+ long exp = currentTimeInSecs + 300;
+ // Check for an input exp to override the default of now + 300 seconds
+ if (timeClaims != null && timeClaims.containsKey(Claims.exp.name())) {
+ exp = timeClaims.get(Claims.exp.name());
+ }
+ jwtContent.put(Claims.iat.name(), currentTimeInSecs);
+ jwtContent.put(Claims.auth_time.name(), currentTimeInSecs);
+ // If the exp claim is not updated, it will be an old value that should be seen as expired
+ if (!invalidClaims.contains(InvalidClaims.EXP)) {
+ jwtContent.put(Claims.exp.name(), exp);
+ }
+ if (timeClaims != null) {
+ timeClaims.put(Claims.iat.name(), currentTimeInSecs);
+ timeClaims.put(Claims.auth_time.name(), currentTimeInSecs);
+ timeClaims.put(Claims.exp.name(), exp);
+ }
+
+ PrivateKey pk;
+ if (invalidClaims.contains(InvalidClaims.SIGNER)) {
+ // Generate a new random private key to sign with to test invalid signatures
+ KeyPair keyPair = generateKeyPair(2048);
+ pk = keyPair.getPrivate();
+ } else {
+ // Use the test private key associated with the test public key for a valid signature
+ pk = readPrivateKey("/privateKey.pem");
+ }
+
+ // Create RSA-signer with the private key
+ JWSSigner signer = new RSASSASigner(pk);
+ JWTClaimsSet claimsSet = JWTClaimsSet.parse(jwtContent);
+ JWSAlgorithm alg = JWSAlgorithm.RS256;
+ if (invalidClaims.contains(InvalidClaims.ALG)) {
+ alg = JWSAlgorithm.HS256;
+ SecureRandom random = new SecureRandom();
+ BigInteger secret = BigInteger.probablePrime(256, random);
+ signer = new MACSigner(secret.toByteArray());
+ }
+ JWSHeader jwtHeader = new JWSHeader.Builder(alg)
+ .keyID("/privateKey.pem")
+ .type(JOSEObjectType.JWT)
+ .build();
+ SignedJWT signedJWT = new SignedJWT(jwtHeader, claimsSet);
+ signedJWT.sign(signer);
+ return signedJWT.serialize();
+ }
+
+ /**
+ * Read a PEM encoded private key from the classpath
+ *
+ * @param pemResName - key file resource name
+ * @return PrivateKey
+ * @throws Exception on decode failure
+ */
+ public static PrivateKey readPrivateKey(String pemResName) throws Exception {
+ InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName);
+ byte[] tmp = new byte[4096];
+ int length = contentIS.read(tmp);
+ return decodePrivateKey(new String(tmp, 0, length));
+ }
+
+ /**
+ * Read a PEM encoded public key from the classpath
+ *
+ * @param pemResName - key file resource name
+ * @return PublicKey
+ * @throws Exception on decode failure
+ */
+ public static PublicKey readPublicKey(String pemResName) throws Exception {
+ InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName);
+ byte[] tmp = new byte[4096];
+ int length = contentIS.read(tmp);
+ return decodePublicKey(new String(tmp, 0, length));
+ }
+
+ /**
+ * Generate a new RSA keypair.
+ *
+ * @param keySize - the size of the key
+ * @return KeyPair
+ * @throws NoSuchAlgorithmException on failure to load RSA key generator
+ */
+ public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException {
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ keyPairGenerator.initialize(keySize);
+ return keyPairGenerator.genKeyPair();
+ }
+
+ /**
+ * Decode a PEM encoded private key string to an RSA PrivateKey
+ *
+ * @param pemEncoded - PEM string for private key
+ * @return PrivateKey
+ * @throws Exception on decode failure
+ */
+ public static PrivateKey decodePrivateKey(String pemEncoded) throws Exception {
+ pemEncoded = removeBeginEnd(pemEncoded);
+ byte[] pkcs8EncodedBytes = Base64.getDecoder().decode(pemEncoded);
+
+ // extract the private key
+
+ PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);
+ KeyFactory kf = KeyFactory.getInstance("RSA");
+ return kf.generatePrivate(keySpec);
+ }
+
+ /**
+ * Decode a PEM encoded public key string to an RSA PublicKey
+ *
+ * @param pemEncoded - PEM string for private key
+ * @return PublicKey
+ * @throws Exception on decode failure
+ */
+ public static PublicKey decodePublicKey(String pemEncoded) throws Exception {
+ pemEncoded = removeBeginEnd(pemEncoded);
+ byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
+
+ X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
+ KeyFactory kf = KeyFactory.getInstance("RSA");
+ return kf.generatePublic(spec);
+ }
+
+ private static String removeBeginEnd(String pem) {
+ pem = pem.replaceAll("-----BEGIN (.*)-----", "");
+ pem = pem.replaceAll("-----END (.*)----", "");
+ pem = pem.replaceAll("\r\n", "");
+ pem = pem.replaceAll("\n", "");
+ return pem.trim();
+ }
+
+ /**
+ * @return the current time in seconds since epoch
+ */
+ public static int currentTimeInSecs() {
+ long currentTimeMS = System.currentTimeMillis();
+ return (int) (currentTimeMS / 1000);
+ }
+
+ /**
+ * Enums to indicate which claims should be set to invalid values for testing failure modes
+ */
+ public enum InvalidClaims {
+ ISSUER, // Set an invalid issuer
+ EXP, // Set an invalid expiration
+ SIGNER, // Sign the token with the incorrect private key
+ ALG, // Sign the token with the correct private key, but HS
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
new file mode 100644
index 0000000..f38063f
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ @Module
+ @Classes(GreetingService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void get() throws IOException {
+ final String message = WebClient.create("http://localhost:4204")
+ .path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(String.class);
+ assertEquals("Hi Microprofile JWT!", message);
+ }
+
+ @Test
+ public void post() throws IOException {
+ final String message = WebClient.create("http://localhost:4204")
+ .path("/test/greeting/")
+ .type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post("Hi REST!", String.class);
+ assertEquals("hi rest!", message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/META-INF/application-client.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/META-INF/application-client.xml b/examples/mp-rest-jwt/src/test/resources/META-INF/application-client.xml
new file mode 100644
index 0000000..1e91dca
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/META-INF/application-client.xml
@@ -0,0 +1 @@
+<application-client/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/Token1.json
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/Token1.json b/examples/mp-rest-jwt/src/test/resources/Token1.json
new file mode 100644
index 0000000..32b03c8
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/Token1.json
@@ -0,0 +1,20 @@
+{
+ "iss": "https://server.example.com",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "jdoe@example.com",
+ "preferred_username": "jdoe",
+ "aud": "s6BhdRkqt3",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "roles": [
+ "Echoer"
+ ],
+ "groups": [
+ "Echoer",
+ "Tester",
+ "group1",
+ "group2"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/Token2.json
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/Token2.json b/examples/mp-rest-jwt/src/test/resources/Token2.json
new file mode 100644
index 0000000..d69f61a
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/Token2.json
@@ -0,0 +1,12 @@
+{
+ "iss": "https://server.example.com",
+ "jti": "a-123.2",
+ "sub": "24400320#2",
+ "upn": "jdoe2@example.com",
+ "preferred_username": "jdoe",
+ "aud": "s6BhdRkqt3.2",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "groups": ["Echoer2", "Tester", "Token2Role", "group1.2", "group2.2"]
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/arquillian.xml b/examples/mp-rest-jwt/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..4744e7a
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/arquillian.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="classifier">microprofile</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/privateKey.pem
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/privateKey.pem b/examples/mp-rest-jwt/src/test/resources/privateKey.pem
new file mode 100644
index 0000000..e20d80b
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/privateKey.pem
@@ -0,0 +1,28 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWK8UjyoHgPTLa
+PLQJ8SoXLLjpHSjtLxMqmzHnFscqhTVVaDpCRCb6e3Ii/WniQTWw8RA7vf4djz4H
+OzvlfBFNgvUGZHXDwnmGaNVaNzpHYFMEYBhE8VGGiveSkzqeLZI+Y02G6sQAfDtN
+qqzM/l5QX8X34oQFaTBW1r49nftvCpITiwJvWyhkWtXP9RP8sXi1im5Vi3dhupOh
+nelk5n0BfajUYIbfHA6ORzjHRbt7NtBl0L2J+0/FUdHyKs6KMlFGNw8O0Dq88qnM
+uXoLJiewhg9332W3DFMeOveel+//cvDnRsCRtPgd4sXFPHh+UShkso7+DRsChXa6
+oGGQD3GdAgMBAAECggEAAjfTSZwMHwvIXIDZB+yP+pemg4ryt84iMlbofclQV8hv
+6TsI4UGwcbKxFOM5VSYxbNOisb80qasb929gixsyBjsQ8284bhPJR7r0q8h1C+jY
+URA6S4pk8d/LmFakXwG9Tz6YPo3pJziuh48lzkFTk0xW2Dp4SLwtAptZY/+ZXyJ6
+96QXDrZKSSM99Jh9s7a0ST66WoxSS0UC51ak+Keb0KJ1jz4bIJ2C3r4rYlSu4hHB
+Y73GfkWORtQuyUDa9yDOem0/z0nr6pp+pBSXPLHADsqvZiIhxD/O0Xk5I6/zVHB3
+zuoQqLERk0WvA8FXz2o8AYwcQRY2g30eX9kU4uDQAQKBgQDmf7KGImUGitsEPepF
+KH5yLWYWqghHx6wfV+fdbBxoqn9WlwcQ7JbynIiVx8MX8/1lLCCe8v41ypu/eLtP
+iY1ev2IKdrUStvYRSsFigRkuPHUo1ajsGHQd+ucTDf58mn7kRLW1JGMeGxo/t32B
+m96Af6AiPWPEJuVfgGV0iwg+HQKBgQCmyPzL9M2rhYZn1AozRUguvlpmJHU2DpqS
+34Q+7x2Ghf7MgBUhqE0t3FAOxEC7IYBwHmeYOvFR8ZkVRKNF4gbnF9RtLdz0DMEG
+5qsMnvJUSQbNB1yVjUCnDAtElqiFRlQ/k0LgYkjKDY7LfciZl9uJRl0OSYeX/qG2
+tRW09tOpgQKBgBSGkpM3RN/MRayfBtmZvYjVWh3yjkI2GbHA1jj1g6IebLB9SnfL
+WbXJErCj1U+wvoPf5hfBc7m+jRgD3Eo86YXibQyZfY5pFIh9q7Ll5CQl5hj4zc4Y
+b16sFR+xQ1Q9Pcd+BuBWmSz5JOE/qcF869dthgkGhnfVLt/OQzqZluZRAoGAXQ09
+nT0TkmKIvlza5Af/YbTqEpq8mlBDhTYXPlWCD4+qvMWpBII1rSSBtftgcgca9XLB
+MXmRMbqtQeRtg4u7dishZVh1MeP7vbHsNLppUQT9Ol6lFPsd2xUpJDc6BkFat62d
+Xjr3iWNPC9E9nhPPdCNBv7reX7q81obpeXFMXgECgYEAmk2Qlus3OV0tfoNRqNpe
+Mb0teduf2+h3xaI1XDIzPVtZF35ELY/RkAHlmWRT4PCdR0zXDidE67L6XdJyecSt
+FdOUH8z5qUraVVebRFvJqf/oGsXc4+ex1ZKUTbY0wqY1y9E39yvB3MaTmZFuuqk8
+f3cg+fr8aou7pr9SHhJlZCU=
+-----END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/mp-rest-jwt/src/test/resources/publicKey.pem
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/publicKey.pem b/examples/mp-rest-jwt/src/test/resources/publicKey.pem
new file mode 100644
index 0000000..a1dc20c
--- /dev/null
+++ b/examples/mp-rest-jwt/src/test/resources/publicKey.pem
@@ -0,0 +1,9 @@
+-----BEGIN RSA PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq
+Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR
+TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e
+UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9
+AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn
+sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x
+nQIDAQAB
+-----END RSA PUBLIC KEY-----
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index f9b3342..8174782 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -119,7 +119,7 @@ BROKEN, see TOMEE-2140
<module>rest-applicationcomposer</module>
<module>rest-cdi</module>
<module>rest-jaas</module>
- <module>rest-mp-jwt</module>
+ <module>mp-rest-jwt</module>
<module>rest-on-ejb</module>
<module>rest-example</module>
<module>rest-example-with-application</module>
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/README.md
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/README.md b/examples/rest-mp-jwt/README.md
deleted file mode 100644
index b2dc71f..0000000
--- a/examples/rest-mp-jwt/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-index-group=Unrevised
-type=page
-status=published
-~~~~~~
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/pom.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/pom.xml b/examples/rest-mp-jwt/pom.xml
deleted file mode 100644
index ca58ceb..0000000
--- a/examples/rest-mp-jwt/pom.xml
+++ /dev/null
@@ -1,279 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.superbiz</groupId>
- <artifactId>rest-mp-jwt</artifactId>
- <version>8.0.0-SNAPSHOT</version>
- <packaging>war</packaging>
- <name>OpenEJB :: Examples :: REST MP-JWT</name>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <tomee.version>8.0.0-SNAPSHOT</tomee.version>
- <version.shrinkwrap.resolver>2.0.0</version.shrinkwrap.resolver>
- <mp-jwt.version>1.0</mp-jwt.version>
- </properties>
-
- <build>
- <defaultGoal>install</defaultGoal>
- <finalName>moviefun</finalName>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.18.1</version>
- <configuration>
- <reuseForks>false</reuseForks>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>3.1.0</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.5.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.tomee.maven</groupId>
- <artifactId>tomee-maven-plugin</artifactId>
- <version>${tomee.version}</version>
- <configuration>
- <tomeeClassifier>microprofile</tomeeClassifier>
- <args>-Xmx512m -XX:PermSize=256m</args>
- <config>${project.basedir}/src/main/tomee/</config>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencyManagement>
- <dependencies>
- <!-- Override dependency resolver with test version. This must go *BEFORE*
- the Arquillian BOM. -->
- <dependency>
- <groupId>org.jboss.shrinkwrap.resolver</groupId>
- <artifactId>shrinkwrap-resolver-bom</artifactId>
- <version>${version.shrinkwrap.resolver}</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- <!-- Now pull in our server-based unit testing framework -->
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-bom</artifactId>
- <version>1.0.3.Final</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <repositories>
- <repository>
- <id>apache-m2-snapshot</id>
- <name>Apache Snapshot Repository</name>
- <url>https://repository.apache.org/content/groups/snapshots</url>
- </repository>
- </repositories>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>javaee-api</artifactId>
- <version>8.0</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.microprofile.jwt</groupId>
- <artifactId>microprofile-jwt-auth-api</artifactId>
- <version>${mp-jwt.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.nimbusds</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>4.23</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
-
- <!--
- The <scope>test</scope> guarantees that non of your runtime
- code is dependent on any OpenEJB classes.
- -->
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>openejb-cxf-rs</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>openejb-core</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.shrinkwrap.resolver</groupId>
- <artifactId>shrinkwrap-resolver-depchain</artifactId>
- <type>pom</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>ziplock</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>backbonejs</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- <version>3.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>handlebars</artifactId>
- <version>1.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- <version>2.1.0-1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>json2</artifactId>
- <version>20110223</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>less</artifactId>
- <version>1.6.0-1</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>requirejs</artifactId>
- <version>2.1.10</version>
- </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>requirejs-text</artifactId>
- <version>2.0.10</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>arquillian-tomee-embedded</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>arquillian-tomee-embedded</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>tomee-embedded</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>mp-jwt</artifactId>
- <version>${tomee.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>arquillian-tomee-remote</id>
- <dependencies>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>arquillian-tomee-remote</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>apache-tomee</artifactId>
- <version>${tomee.version}</version>
- <type>zip</type>
- <classifier>microprofile</classifier>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-
- <!--
- This section allows you to configure where to publish libraries for sharing.
- It is not required and may be deleted. For more information see:
- http://maven.apache.org/plugins/maven-deploy-plugin/
- -->
- <distributionManagement>
- <repository>
- <id>localhost</id>
- <url>file://${basedir}/target/repo/</url>
- </repository>
- <snapshotRepository>
- <id>localhost</id>
- <url>file://${basedir}/target/snapshot-repo/</url>
- </snapshotRepository>
- </distributionManagement>
-</project>
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/Movie.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/Movie.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/Movie.java
deleted file mode 100644
index 4e067bb..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/Movie.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@Entity
-@XmlRootElement(name = "movie")
-public class Movie {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private long id;
-
- private String director;
- private String title;
- private int year;
- private String genre;
- private int rating;
-
- public Movie() {
- }
-
- public Movie(String title, String director, String genre, int rating, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- this.genre = genre;
- this.rating = rating;
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
- public String getGenre() {
- return genre;
- }
-
- public void setGenre(String genre) {
- this.genre = genre;
- }
-
- public int getRating() {
- return rating;
- }
-
- public void setRating(int rating) {
- this.rating = rating;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
deleted file mode 100644
index 2580c9f..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import javax.persistence.metamodel.EntityType;
-import java.util.List;
-
-@Stateless
-public class MoviesBean {
-
- @PersistenceContext(unitName = "movie-unit")
- private EntityManager entityManager;
-
- public Movie find(Long id) {
- return entityManager.find(Movie.class, id);
- }
-
- public void addMovie(Movie movie) {
- entityManager.persist(movie);
- }
-
- public void editMovie(Movie movie) {
- entityManager.merge(movie);
- }
-
- public void deleteMovie(long id) {
- Movie movie = entityManager.find(Movie.class, id);
- entityManager.remove(movie);
- }
-
- public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- TypedQuery<Movie> q = entityManager.createQuery(cq);
- if (maxResults != null) {
- q.setMaxResults(maxResults);
- }
- if (firstResult != null) {
- q.setFirstResult(firstResult);
- }
- return q.getResultList();
- }
-
- public int count(String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Long> cq = qb.createQuery(Long.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- cq.select(qb.count(root));
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- return entityManager.createQuery(cq).getSingleResult().intValue();
- }
-
- public void clean() {
- entityManager.createQuery("delete from Movie").executeUpdate();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
deleted file mode 100644
index 5a7bd4d..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun.rest;
-
-import org.eclipse.microprofile.auth.LoginConfig;
-
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
-
-@ApplicationPath("/rest")
-@LoginConfig(authMethod = "MP-JWT")
-public class ApplicationConfig extends Application {
- // let the server discover the endpoints
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
deleted file mode 100644
index 6969221..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun.rest;
-
-import org.superbiz.moviefun.Movie;
-import org.superbiz.moviefun.MoviesBean;
-
-import javax.ejb.EJB;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-@Path("load")
-public class LoadRest {
- @EJB
- private MoviesBean moviesBean;
-
- @POST
- public void load() {
- moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
- moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
- moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
- moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
- moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
- moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
- moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f0f5770/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java b/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
deleted file mode 100644
index 3bea531..0000000
--- a/examples/rest-mp-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesMPJWTConfigurationProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun.rest;
-
-import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
-
-import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.Produces;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Base64;
-import java.util.Optional;
-
-@Dependent
-public class MoviesMPJWTConfigurationProvider {
-
- @Produces
- Optional<JWTAuthContextInfo> getOptionalContextInfo() throws NoSuchAlgorithmException, InvalidKeySpecException {
- JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
-
- // todo use MP Config to load the configuration
- contextInfo.setIssuedBy("https://server.example.com");
-
- final String pemEncoded = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq" +
- "Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR" +
- "TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e" +
- "UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9" +
- "AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn" +
- "sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x" +
- "nQIDAQAB";
- byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
-
- final X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
- final KeyFactory kf = KeyFactory.getInstance("RSA");
- final RSAPublicKey pk = (RSAPublicKey) kf.generatePublic(spec);
-
- contextInfo.setSignerKey(pk);
-
- return Optional.of(contextInfo);
- }
-
- @Produces
- JWTAuthContextInfo getContextInfo() throws InvalidKeySpecException, NoSuchAlgorithmException {
- return getOptionalContextInfo().get();
- }
-}
\ No newline at end of file
[04/11] tomee git commit: more pom.xml clean up
Posted by jl...@apache.org.
more pom.xml clean up
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/16406758
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/16406758
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/16406758
Branch: refs/heads/master
Commit: 16406758debfce2c11648076296237ae95044adf
Parents: 286306a
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 4 22:29:27 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 4 22:29:27 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/pom.xml | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/16406758/examples/mp-rest-jwt/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/pom.xml b/examples/mp-rest-jwt/pom.xml
index ea8319d..01f708b 100644
--- a/examples/mp-rest-jwt/pom.xml
+++ b/examples/mp-rest-jwt/pom.xml
@@ -95,13 +95,6 @@
</dependencies>
</dependencyManagement>
- <repositories>
- <repository>
- <id>apache-m2-snapshot</id>
- <name>Apache Snapshot Repository</name>
- <url>https://repository.apache.org/content/groups/snapshots</url>
- </repository>
- </repositories>
<dependencies>
<dependency>
@@ -164,13 +157,7 @@
<type>pom</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>ziplock</artifactId>
- <version>${tomee.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ </dependencies>q
<profiles>
<profile>
[10/11] tomee git commit: TOMEE-2304 Added reference to Bug found
during the creation of this example
Posted by jl...@apache.org.
TOMEE-2304 Added reference to Bug found during the creation of this example
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cc865ac3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cc865ac3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cc865ac3
Branch: refs/heads/master
Commit: cc865ac321f35510eb481358377267949d78233b
Parents: 28bb6d3
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 11 23:20:30 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 11 23:20:30 2018 -0600
----------------------------------------------------------------------
.../src/test/java/org/superbiz/moviefun/MoviesTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc865ac3/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
index 7ba6808..98af3bc 100644
--- a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -88,7 +88,7 @@ public class MoviesTest {
//GET movies (Using token1.json with group of claims: [read-only])
- //This test should be updated to use token2.json once TOMEE- gets resolved.
+ //This test should be updated to use token2.json once TOMEE-2357 gets resolved.
Collection<? extends Movie> movies = webClient
.reset()
.path("/rest/cinema/movies")
[07/11] tomee git commit: TOMEE-2304 - removed jpa and greeting
service and test. Added JWT rolesAllowed tests.
Posted by jl...@apache.org.
TOMEE-2304 - removed jpa and greeting service and test. Added JWT rolesAllowed tests.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2e460433
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2e460433
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2e460433
Branch: refs/heads/master
Commit: 2e460433869df496fdf904b4820092d733870f95
Parents: 7cba202
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 11 00:15:09 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 11 00:15:09 2018 -0600
----------------------------------------------------------------------
.../main/java/org/superbiz/moviefun/Movie.java | 58 ++-----
.../java/org/superbiz/moviefun/MoviesBean.java | 78 +++------
.../org/superbiz/moviefun/rest/LoadRest.java | 42 -----
.../org/superbiz/moviefun/rest/MoviesRest.java | 164 +++++++++++--------
.../java/org/superbiz/rest/GreetingService.java | 41 -----
.../src/main/resources/META-INF/persistence.xml | 31 ----
examples/mp-rest-jwt/src/main/tomee/tomee.xml | 27 ---
.../java/org/superbiz/moviefun/MoviesTest.java | 56 +++++--
.../org/superbiz/rest/GreetingServiceTest.java | 61 -------
.../mp-rest-jwt/src/test/resources/Token1.json | 9 +-
.../mp-rest-jwt/src/test/resources/Token2.json | 14 +-
11 files changed, 183 insertions(+), 398 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
index 4e067bb..1e21a1d 100644
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/Movie.java
@@ -16,47 +16,30 @@
*/
package org.superbiz.moviefun;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
import javax.xml.bind.annotation.XmlRootElement;
-@Entity
@XmlRootElement(name = "movie")
public class Movie {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private long id;
+ private int id;
private String director;
private String title;
- private int year;
- private String genre;
- private int rating;
-
public Movie() {
}
- public Movie(String title, String director, String genre, int rating, int year) {
+ public Movie(int id, String director, String title) {
+ this.id = id;
this.director = director;
this.title = title;
- this.year = year;
- this.genre = genre;
- this.rating = rating;
- }
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
}
- public long getId() {
+
+ public int getId() {
return id;
}
- public void setId(long id) {
+ public void setId(int id) {
this.id = id;
}
@@ -76,27 +59,12 @@ public class Movie {
this.title = title;
}
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
- public String getGenre() {
- return genre;
- }
-
- public void setGenre(String genre) {
- this.genre = genre;
- }
-
- public int getRating() {
- return rating;
- }
-
- public void setRating(int rating) {
- this.rating = rating;
+ @Override
+ public String toString() {
+ return "Movie{" +
+ "id=" + id +
+ ", director='" + director + '\'' +
+ ", title='" + title + '\'' +
+ '}';
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
index 2580c9f..3f28097 100644
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -16,76 +16,46 @@
*/
package org.superbiz.moviefun;
+import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import javax.persistence.metamodel.EntityType;
+import javax.enterprise.context.ApplicationScoped;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
-@Stateless
+@ApplicationScoped
public class MoviesBean {
+
+ private HashMap<Integer,Movie> MovieStore;
- @PersistenceContext(unitName = "movie-unit")
- private EntityManager entityManager;
- public Movie find(Long id) {
- return entityManager.find(Movie.class, id);
+ @PostConstruct
+ public void MovieBean() {
+ MovieStore = new HashMap();
}
- public void addMovie(Movie movie) {
- entityManager.persist(movie);
+ public void addMovie(Movie newMovie) {
+ MovieStore.put(newMovie.getId(), newMovie);
}
- public void editMovie(Movie movie) {
- entityManager.merge(movie);
+ public void deleteMovie(int id) {
+ MovieStore.remove(id);
}
- public void deleteMovie(long id) {
- Movie movie = entityManager.find(Movie.class, id);
- entityManager.remove(movie);
+ public void updateMovie(Movie updatedMovie) {
+ MovieStore.put(updatedMovie.getId(),updatedMovie);
}
- public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- TypedQuery<Movie> q = entityManager.createQuery(cq);
- if (maxResults != null) {
- q.setMaxResults(maxResults);
- }
- if (firstResult != null) {
- q.setFirstResult(firstResult);
- }
- return q.getResultList();
+ public Movie getMovie(int id) {
+ return MovieStore.get(id);
}
- public int count(String field, String searchTerm) {
- CriteriaBuilder qb = entityManager.getCriteriaBuilder();
- CriteriaQuery<Long> cq = qb.createQuery(Long.class);
- Root<Movie> root = cq.from(Movie.class);
- EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
- cq.select(qb.count(root));
- if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
- Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
- Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
- cq.where(condition);
- }
- return entityManager.createQuery(cq).getSingleResult().intValue();
- }
+ public List getMovies() {
+ Collection<Movie> Movies = MovieStore.values();
+ return new ArrayList<Movie>(Movies);
- public void clean() {
- entityManager.createQuery("delete from Movie").executeUpdate();
}
+
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
deleted file mode 100644
index 6969221..0000000
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.moviefun.rest;
-
-import org.superbiz.moviefun.Movie;
-import org.superbiz.moviefun.MoviesBean;
-
-import javax.ejb.EJB;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-@Path("load")
-public class LoadRest {
- @EJB
- private MoviesBean moviesBean;
-
- @POST
- public void load() {
- moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
- moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
- moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
- moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
- moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
- moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
- moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
index 7020864..1ded167 100644
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -16,98 +16,128 @@
*/
package org.superbiz.moviefun.rest;
-import org.eclipse.microprofile.jwt.Claim;
-import org.eclipse.microprofile.jwt.ClaimValue;
-import org.eclipse.microprofile.jwt.JsonWebToken;
import org.superbiz.moviefun.Movie;
import org.superbiz.moviefun.MoviesBean;
import javax.annotation.security.RolesAllowed;
-import javax.ejb.EJB;
import javax.inject.Inject;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
+import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.SecurityContext;
import java.util.List;
-@Path("movies")
-@Produces({"application/json"})
+@Path("cinema")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
public class MoviesRest {
- @EJB
- private MoviesBean service;
-
- @Inject
- @Claim("raw_token")
- private ClaimValue<String> rawToken;
-
- @Inject
- @Claim("iss")
- private ClaimValue<String> issuer;
-
@Inject
- @Claim("jti")
- private ClaimValue<String> jti;
-
- @Inject
- private JsonWebToken jwtPrincipal;
-
- @Context
- private SecurityContext securityContext;
+ private MoviesBean moviesBean;
@GET
- @Path("{id}")
- public Movie find(@PathParam("id") Long id) {
- return service.find(id);
+ @Produces(MediaType.TEXT_PLAIN)
+ public String status() {
+ return "ok";
}
- @GET
- public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
- @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.getMovies(first, max, field, searchTerm);
+ @POST
+ @Path("/movies")
+ @RolesAllowed("crud")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public void addMovie(Movie newMovie) {
+ moviesBean.addMovie(newMovie);
}
- @POST
- @Consumes("application/json")
- @RolesAllowed("create")
- public Movie addMovie(Movie movie) {
- service.addMovie(movie);
- return movie;
+ @DELETE
+ @Path("/movies/{id}")
+ @RolesAllowed("read-only")
+ public void deleteMovie(@PathParam("id") int id) {
+ moviesBean.deleteMovie(id);
}
@PUT
- @Path("{id}")
- @Consumes("application/json")
- @RolesAllowed("update")
- public Movie editMovie(
- @PathParam("id") final long id,
- Movie movie
- ) {
- service.editMovie(movie);
- return movie;
+ @Path("/movies")
+ public void updateMovie(Movie updatedMovie) {
+ moviesBean.updateMovie(updatedMovie);
}
- @DELETE
- @Path("{id}")
- @RolesAllowed("delete")
- public void deleteMovie(@PathParam("id") long id) {
- service.deleteMovie(id);
+ @GET
+ @Path("/movies/{id}")
+ @RolesAllowed({"read-only","crud"})
+ public Movie getMovie(@PathParam("id") int id) {
+ return moviesBean.getMovie(id);
}
@GET
- @Path("count")
- @Produces(MediaType.TEXT_PLAIN)
- public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
- return service.count(field, searchTerm);
+ @Path("/movies")
+ @RolesAllowed({"crud", "read-only"})
+ public List<Movie> getListOfMovies() {
+ return moviesBean.getMovies();
}
+
+// @Inject
+// @Claim("raw_token")
+// private ClaimValue<String> rawToken;
+//
+// @Inject
+// @Claim("iss")
+// private ClaimValue<String> issuer;
+//
+// @Inject
+// @Claim("jti")
+// private ClaimValue<String> jti;
+//
+// @Inject
+// private JsonWebToken jwtPrincipal;
+//
+// @Context
+// private SecurityContext securityContext;
+//
+// @GET
+// @Path("{id}")
+// public Movie find(@PathParam("id") Long id) {
+// return service.find(id);
+// }
+//
+// @GET
+// public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
+// @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+// return service.getMovies(first, max, field, searchTerm);
+// }
+//
+// @POST
+// @Consumes("application/json")
+// @RolesAllowed("create")
+// public Movie addMovie(Movie movie) {
+// service.addMovie(movie);
+// return movie;
+// }
+//
+// @PUT
+// @Path("{id}")
+// @Consumes("application/json")
+// @RolesAllowed("update")
+// public Movie editMovie(
+// @PathParam("id") final long id,
+// Movie movie
+// ) {
+// service.editMovie(movie);
+// return movie;
+// }
+//
+// @DELETE
+// @Path("{id}")
+// @RolesAllowed("delete")
+// public void deleteMovie(@PathParam("id") long id) {
+// service.deleteMovie(id);
+// }
+//
+// @GET
+// @Path("count")
+// @Produces(MediaType.TEXT_PLAIN)
+// public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+// return service.count(field, searchTerm);
+// }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
deleted file mode 100644
index eb4434e..0000000
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/rest/GreetingService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.rest;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import java.util.Locale;
-
-@Path("/greeting")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-public class GreetingService {
-
- @GET
- public String message() {
- return "Hi Microprofile JWT!";
- }
-
- @POST
- public String lowerCase(final String message) {
- return message.toLowerCase(Locale.ENGLISH);
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml b/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index ec38aaa..0000000
--- a/examples/mp-rest-jwt/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
- <persistence-unit name="movie-unit">
- <jta-data-source>movieDatabase</jta-data-source>
- <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
- <class>org.superbiz.moviefun.Movie</class>
-
- <properties>
- <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
- </properties>
- </persistence-unit>
-</persistence>
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/main/tomee/tomee.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/tomee/tomee.xml b/examples/mp-rest-jwt/src/main/tomee/tomee.xml
deleted file mode 100644
index f25d5f8..0000000
--- a/examples/mp-rest-jwt/src/main/tomee/tomee.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<tomee>
- <Resource id="HSQLDB Database" type="DataSource">
- JdbcDriver org.hsqldb.jdbcDriver
- JdbcUrl jdbc:hsqldb:file:target/db/moviefun
- UserName sa
- Password
- </Resource>
-</tomee>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
index b18e64e..ea622b8 100644
--- a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -23,22 +23,22 @@ import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.superbiz.moviefun.rest.ApplicationConfig;
-import org.superbiz.moviefun.rest.LoadRest;
import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
import org.superbiz.moviefun.rest.MoviesRest;
-import org.superbiz.rest.GreetingService;
+import javax.ws.rs.core.Response;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
+import java.util.logging.Logger;
import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertTrue;
@RunWith(Arquillian.class)
public class MoviesTest {
@@ -46,11 +46,10 @@ public class MoviesTest {
@Deployment(testable = false)
public static WebArchive createDeployment() {
final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClasses(Movie.class, MoviesBean.class, MoviesTest.class, LoadRest.class)
- .addClasses(MoviesRest.class, GreetingService.class, ApplicationConfig.class)
+ .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
+ .addClasses(MoviesRest.class, ApplicationConfig.class)
.addClass(MoviesMPJWTConfigurationProvider.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
- .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
System.out.println(webArchive.toString(true));
@@ -60,29 +59,50 @@ public class MoviesTest {
@ArquillianResource
private URL base;
+
+ private final static Logger LOGGER = Logger.getLogger(MoviesTest.class.getName());
+
@Test
- public void sthg() throws Exception {
+ public void movieRestTest() throws Exception {
final WebClient webClient = WebClient
.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()), singletonList(new LoggingFeature()), null);
- webClient
- .reset()
- .path("/rest/greeting/")
- .get(String.class);
+
+ //Testing rest endpoint deployment (GET without security header)
+ String responsePayload = webClient.reset().path("/rest/cinema/").get(String.class);
+ LOGGER.info("responsePayload = " + responsePayload);
+ assertTrue(responsePayload.equalsIgnoreCase("ok"));
+
+ //POST (Using token1.json with group of claims: [CRUD])
+ Movie newMovie = new Movie(1,"David Dobkin","Wedding Crashers");
+ Response response = webClient.reset().path("/rest/cinema/movies").header("Content-Type","application/json").header("Authorization", "Bearer " + token(1)).post(newMovie);
+ LOGGER.info("responseCode = " + response.getStatus());
+ assertTrue(response.getStatus() == 204);
+
+
+
+ //GET movies (Using token2.json with group of claims: [read-only])
final Collection<? extends Movie> movies = webClient
.reset()
- .path("/rest/movies/")
- .header("Authorization", "Bearer " + token())
+ .path("/rest/cinema/movies")
+ .header("Content-Type","application/json")
+ .header("Authorization", "Bearer " + token(1))
.getCollection(Movie.class);
-
- System.out.println(movies);
+ LOGGER.info(movies.toString());
+ assertTrue(movies.size() == 1);
}
- private String token() throws Exception {
+
+
+ private String token(int token_type) throws Exception {
HashMap<String, Long> timeClaims = new HashMap<>();
- return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
+ if(token_type==1){
+ return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
+ }else{
+ return TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
deleted file mode 100644
index f38063f..0000000
--- a/examples/mp-rest-jwt/src/test/java/org/superbiz/rest/GreetingServiceTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.rest;
-
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.openejb.jee.WebApp;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.testing.Classes;
-import org.apache.openejb.testing.EnableServices;
-import org.apache.openejb.testing.Module;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-
-@EnableServices(value = "jaxrs", httpDebug = true)
-@RunWith(ApplicationComposer.class)
-public class GreetingServiceTest {
-
- @Module
- @Classes(GreetingService.class)
- public WebApp app() {
- return new WebApp().contextRoot("test");
- }
-
- @Test
- public void get() throws IOException {
- final String message = WebClient.create("http://localhost:4204")
- .path("/test/greeting/")
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .get(String.class);
- assertEquals("Hi Microprofile JWT!", message);
- }
-
- @Test
- public void post() throws IOException {
- final String message = WebClient.create("http://localhost:4204")
- .path("/test/greeting/")
- .type(MediaType.APPLICATION_JSON_TYPE)
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .post("Hi REST!", String.class);
- assertEquals("hi rest!", message);
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/test/resources/Token1.json
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/Token1.json b/examples/mp-rest-jwt/src/test/resources/Token1.json
index 32b03c8..2766575 100644
--- a/examples/mp-rest-jwt/src/test/resources/Token1.json
+++ b/examples/mp-rest-jwt/src/test/resources/Token1.json
@@ -8,13 +8,10 @@
"exp": 1311281970,
"iat": 1311280970,
"auth_time": 1311280969,
- "roles": [
- "Echoer"
- ],
"groups": [
- "Echoer",
- "Tester",
"group1",
- "group2"
+ "group2",
+ "crud",
+ "read-only"
]
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/2e460433/examples/mp-rest-jwt/src/test/resources/Token2.json
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/resources/Token2.json b/examples/mp-rest-jwt/src/test/resources/Token2.json
index d69f61a..f591863 100644
--- a/examples/mp-rest-jwt/src/test/resources/Token2.json
+++ b/examples/mp-rest-jwt/src/test/resources/Token2.json
@@ -1,12 +1,14 @@
{
"iss": "https://server.example.com",
- "jti": "a-123.2",
- "sub": "24400320#2",
- "upn": "jdoe2@example.com",
- "preferred_username": "jdoe",
- "aud": "s6BhdRkqt3.2",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "alice@example.com",
+ "preferred_username": "alice",
+ "aud": "s6BhdRkqt3",
"exp": 1311281970,
"iat": 1311280970,
"auth_time": 1311280969,
- "groups": ["Echoer2", "Tester", "Token2Role", "group1.2", "group2.2"]
+ "groups": [
+ "read-only"
+ ]
}
[11/11] tomee git commit: This closes apache/tomee#233
Posted by jl...@apache.org.
This closes apache/tomee#233
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/185b74a5
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/185b74a5
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/185b74a5
Branch: refs/heads/master
Commit: 185b74a56661a47456d27424113de015d075b5d7
Parents: a44544b cc865ac
Author: Jean-Louis Monteiro <je...@gmail.com>
Authored: Wed Dec 12 17:02:14 2018 +0100
Committer: Jean-Louis Monteiro <je...@gmail.com>
Committed: Wed Dec 12 17:02:14 2018 +0100
----------------------------------------------------------------------
examples/mp-rest-jwt/README.md | 303 +++++++++++++++++++
examples/mp-rest-jwt/pom.xml | 225 ++++++++++++++
.../main/java/org/superbiz/moviefun/Movie.java | 70 +++++
.../java/org/superbiz/moviefun/MoviesBean.java | 61 ++++
.../moviefun/rest/ApplicationConfig.java | 28 ++
.../rest/MoviesMPJWTConfigurationProvider.java | 63 ++++
.../org/superbiz/moviefun/rest/MoviesRest.java | 77 +++++
.../java/org/superbiz/moviefun/MoviesTest.java | 133 ++++++++
.../java/org/superbiz/moviefun/TokenUtils.java | 257 ++++++++++++++++
.../resources/META-INF/application-client.xml | 1 +
.../mp-rest-jwt/src/test/resources/Token1.json | 17 ++
.../mp-rest-jwt/src/test/resources/Token2.json | 14 +
.../src/test/resources/arquillian.xml | 32 ++
.../src/test/resources/privateKey.pem | 28 ++
.../src/test/resources/publicKey.pem | 9 +
examples/pom.xml | 2 +-
examples/rest-mp-jwt/README.md | 4 -
examples/rest-mp-jwt/pom.xml | 279 -----------------
.../main/java/org/superbiz/moviefun/Movie.java | 102 -------
.../java/org/superbiz/moviefun/MoviesBean.java | 91 ------
.../moviefun/rest/ApplicationConfig.java | 28 --
.../org/superbiz/moviefun/rest/LoadRest.java | 42 ---
.../rest/MoviesMPJWTConfigurationProvider.java | 63 ----
.../org/superbiz/moviefun/rest/MoviesRest.java | 113 -------
.../java/org/superbiz/rest/GreetingService.java | 41 ---
.../src/main/resources/META-INF/persistence.xml | 31 --
examples/rest-mp-jwt/src/main/tomee/tomee.xml | 27 --
.../java/org/superbiz/moviefun/MoviesTest.java | 88 ------
.../java/org/superbiz/moviefun/TokenUtils.java | 257 ----------------
.../org/superbiz/rest/GreetingServiceTest.java | 61 ----
.../resources/META-INF/application-client.xml | 1 -
.../rest-mp-jwt/src/test/resources/Token1.json | 20 --
.../rest-mp-jwt/src/test/resources/Token2.json | 12 -
.../src/test/resources/arquillian.xml | 32 --
.../src/test/resources/privateKey.pem | 28 --
.../src/test/resources/publicKey.pem | 9 -
36 files changed, 1319 insertions(+), 1330 deletions(-)
----------------------------------------------------------------------
[05/11] tomee git commit: Merge branch 'master' into TOMEE-2304
Posted by jl...@apache.org.
Merge branch 'master' into TOMEE-2304
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/272de000
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/272de000
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/272de000
Branch: refs/heads/master
Commit: 272de000e672ef997b9a06bbed7d6009a7c9400a
Parents: 1640675 004ad51
Author: Cesar Hernandez <ce...@users.noreply.github.com>
Authored: Mon Dec 10 21:54:51 2018 -0600
Committer: GitHub <no...@github.com>
Committed: Mon Dec 10 21:54:51 2018 -0600
----------------------------------------------------------------------
.gitignore | 1 +
.../arquillian/common/TomEEContainer.java | 4 +
.../arquillian/remote/RemoteTomEEContainer.java | 3 +
.../arquillian-tomee-webprofile-tests/pom.xml | 2 +-
.../arquillian/tests/cmp/sample/ActorBean.java | 70 +
.../tests/cmp/sample/ActorDetails.java | 39 +
.../tests/cmp/sample/CustomOrmXmlTest.java | 76 +
.../arquillian/tests/cmp/sample/LocalActor.java | 29 +
.../tests/cmp/sample/LocalActorHome.java | 31 +
.../arquillian/tests/cmp/sample/LocalMovie.java | 39 +
.../tests/cmp/sample/LocalMovieHome.java | 33 +
.../arquillian/tests/cmp/sample/MovieBean.java | 118 +
.../tests/cmp/sample/MovieDetails.java | 45 +
.../tests/cmp/sample/MoviesBusiness.java | 25 +
.../tests/cmp/sample/MoviesBusinessBean.java | 80 +
.../tests/cmp/sample/MoviesBusinessHome.java | 27 +
.../tests/cmp/sample/MoviesServlet.java | 91 +
.../securityejb/SecurityEJBPropagationTest.java | 4 +-
.../src/test/resources/arquillian.xml | 2 +
.../arquillian/tests/cmp/sample/custom-orm.xml | 54 +
.../arquillian/tests/cmp/sample/ejb-jar.xml | 164 +
.../arquillian/tests/cmp/sample/openejb-jar.xml | 34 +
.../arquillian/tests/cmp/sample/persistence.xml | 32 +
.../openejb/arquillian/tests/cmp/sample/web.xml | 48 +
.../src/test/resources/test/context.xml | 20 +
.../java/org/apache/openejb/AppContext.java | 8 +-
.../java/org/apache/openejb/BeanContext.java | 87 +-
.../org/apache/openejb/ClassLoaderUtil.java | 9 +-
.../org/apache/openejb/DeploymentContext.java | 2 +-
.../org/apache/openejb/InjectionProcessor.java | 4 +-
.../java/org/apache/openejb/MethodContext.java | 6 +-
.../org/apache/openejb/OpenEjbContainer.java | 5 +-
.../org/apache/openejb/UndeployException.java | 2 +-
.../openejb/assembler/classic/Assembler.java | 97 +-
.../assembler/classic/ClassListInfo.java | 2 +-
.../openejb/assembler/classic/ClientInfo.java | 10 +-
.../assembler/classic/CmpJarBuilder.java | 2 +-
.../assembler/classic/ConnectorInfo.java | 12 +-
.../assembler/classic/ContainerSystemInfo.java | 6 +-
.../classic/DelegatePermissionCollection.java | 4 +-
.../assembler/classic/DeployTimeEnhancer.java | 10 +-
.../assembler/classic/EjbJarBuilder.java | 2 +-
.../openejb/assembler/classic/EjbJarInfo.java | 24 +-
.../openejb/assembler/classic/EjbResolver.java | 10 +-
.../classic/EnterpriseBeanBuilder.java | 13 +-
.../assembler/classic/EnterpriseBeanInfo.java | 28 +-
.../assembler/classic/EntityBeanInfo.java | 6 +-
.../classic/EntityManagerFactoryCallable.java | 2 +-
.../assembler/classic/FacilitiesInfo.java | 10 +-
.../assembler/classic/HandlerChainInfo.java | 4 +-
.../openejb/assembler/classic/HandlerInfo.java | 4 +-
.../assembler/classic/InjectableInfo.java | 2 +-
.../assembler/classic/InjectionBuilder.java | 2 +-
.../classic/InterceptorBindingBuilder.java | 20 +-
.../classic/InterceptorBindingInfo.java | 4 +-
.../assembler/classic/InterceptorInfo.java | 18 +-
.../classic/JaccPermissionsBuilder.java | 4 +-
.../openejb/assembler/classic/JndiBuilder.java | 20 +-
.../assembler/classic/JndiEncBuilder.java | 4 +-
.../openejb/assembler/classic/JndiEncInfo.java | 16 +-
.../assembler/classic/ManagedBeanInfo.java | 6 +-
.../classic/MessageDrivenBeanInfo.java | 2 +-
.../assembler/classic/MethodAttributeInfo.java | 2 +-
.../classic/MethodConcurrencyBuilder.java | 4 +-
.../assembler/classic/MethodInfoUtil.java | 32 +-
.../assembler/classic/MethodPermissionInfo.java | 2 +-
.../assembler/classic/MethodScheduleInfo.java | 2 +-
.../classic/MethodTransactionBuilder.java | 2 +-
.../assembler/classic/PersistenceUnitInfo.java | 8 +-
.../assembler/classic/PolicyContext.java | 2 +-
.../openejb/assembler/classic/PortInfo.java | 2 +-
.../classic/ProxyInterfaceResolver.java | 8 +-
.../openejb/assembler/classic/ServiceInfo.java | 2 +-
.../assembler/classic/ServiceReferenceInfo.java | 4 +-
.../openejb/assembler/classic/ServletInfo.java | 4 +-
.../assembler/classic/StatefulBeanInfo.java | 14 +-
.../assembler/classic/ValidatorBuilder.java | 10 +-
.../openejb/assembler/classic/WsBuilder.java | 4 +-
.../assembler/classic/util/ServiceInfos.java | 2 +-
.../apache/openejb/async/AsynchronousPool.java | 2 +-
.../org/apache/openejb/bval/ValidatorUtil.java | 2 +-
.../org/apache/openejb/cdi/CdiBeanInfo.java | 50 +-
.../java/org/apache/openejb/cdi/CdiEjbBean.java | 12 +-
.../java/org/apache/openejb/cdi/CdiPlugin.java | 16 +-
.../cdi/CdiResourceInjectionService.java | 2 +-
.../openejb/cdi/ConstructorInjectionBean.java | 2 +-
.../openejb/cdi/CurrentCreationalContext.java | 2 +-
.../openejb/cdi/ManagedSecurityService.java | 49 +
.../apache/openejb/cdi/OpenEJBBeanBuilder.java | 2 +-
.../openejb/cdi/OptimizedLoaderService.java | 2 +-
.../openejb/cdi/ThreadSingletonServiceImpl.java | 2 +
.../apache/openejb/cdi/WebappBeanManager.java | 3 +-
.../CompositeClassLoaderConfigurer.java | 2 +-
.../ProvisioningClassLoaderConfigurer.java | 4 +-
.../java/org/apache/openejb/cli/Bootstrap.java | 77 +-
.../java/org/apache/openejb/cli/MainImpl.java | 8 +-
.../openejb/component/ClassLoaderEnricher.java | 2 +-
.../openejb/config/AnnotationDeployer.java | 106 +-
.../config/AppContextConfigDeployer.java | 2 +-
.../apache/openejb/config/AppInfoBuilder.java | 10 +-
.../org/apache/openejb/config/AppModule.java | 34 +-
.../org/apache/openejb/config/AppValidator.java | 2 +-
.../org/apache/openejb/config/AutoConfig.java | 175 +-
.../org/apache/openejb/config/AutoDeployer.java | 8 +-
.../openejb/config/BaseConvertDefinitions.java | 2 +-
.../apache/openejb/config/BeanProperties.java | 2 +-
.../apache/openejb/config/CleanEnvEntries.java | 2 +-
.../openejb/config/ClearEmptyMappedName.java | 2 +-
.../org/apache/openejb/config/ClientModule.java | 6 +-
.../apache/openejb/config/CmpJpaConversion.java | 118 +-
.../config/ConfigurableClasspathArchive.java | 7 +-
.../openejb/config/ConfigurationFactory.java | 34 +-
.../apache/openejb/config/ConnectorModule.java | 4 +-
.../apache/openejb/config/ContainerUtils.java | 2 +-
.../config/ConvertDataSourceDefinitions.java | 4 +-
.../openejb/config/DebuggableVmHackery.java | 4 +-
.../apache/openejb/config/DeploymentLoader.java | 107 +-
.../apache/openejb/config/DeploymentModule.java | 2 +-
.../openejb/config/DeploymentsResolver.java | 4 +-
.../openejb/config/EjbJarInfoBuilder.java | 4 +-
.../config/EnvEntriesPropertiesDeployer.java | 2 +-
.../apache/openejb/config/FinderFactory.java | 6 +-
.../openejb/config/GeneratedClientModules.java | 2 +-
.../openejb/config/InitEjbDeployments.java | 8 +-
.../openejb/config/JndiEncInfoBuilder.java | 6 +-
.../apache/openejb/config/LinkBuiltInTypes.java | 4 +-
.../apache/openejb/config/MBeanDeployer.java | 4 +-
.../java/org/apache/openejb/config/Module.java | 4 +-
.../apache/openejb/config/NewLoaderLogic.java | 12 +-
.../config/OpenEJBDeploymentManager.java | 12 +-
.../openejb/config/OpenEjb2Conversion.java | 10 +-
.../config/PersistenceContextAnnFactory.java | 10 +-
.../openejb/config/PersistenceModule.java | 2 +-
.../config/PersistenceUnitLinkResolver.java | 2 +-
.../openejb/config/QuickServerXmlParser.java | 4 +-
.../org/apache/openejb/config/RemoteServer.java | 6 +-
.../openejb/config/RemoveWebServices.java | 2 +-
.../org/apache/openejb/config/ScanUtil.java | 4 +-
.../org/apache/openejb/config/ServiceUtils.java | 14 +-
.../apache/openejb/config/SunConversion.java | 36 +-
.../org/apache/openejb/config/TldScanner.java | 12 +-
.../openejb/config/ValidationContext.java | 6 +-
.../openejb/config/VmDeploymentManager.java | 10 +-
.../org/apache/openejb/config/WebModule.java | 20 +-
.../openejb/config/WebappAggregatedArchive.java | 2 +-
.../org/apache/openejb/config/WsDeployer.java | 6 +-
.../config/provider/ProviderManager.java | 16 +-
.../config/provider/ServiceJarXmlLoader.java | 6 +-
.../config/rules/CheckAssemblyBindings.java | 6 +-
.../openejb/config/rules/CheckAsynchronous.java | 2 +-
.../openejb/config/rules/CheckCallbacks.java | 2 +-
.../openejb/config/rules/CheckClassLoading.java | 8 +-
.../openejb/config/rules/CheckDependsOn.java | 8 +-
.../config/rules/CheckDescriptorLocation.java | 4 +-
.../config/rules/CheckInjectionTargets.java | 2 +-
.../openejb/config/rules/CheckMethods.java | 8 +-
.../config/rules/CheckRestMethodArePublic.java | 4 +-
.../apache/openejb/config/sys/JaxbOpenejb.java | 2 +-
.../apache/openejb/config/sys/ListAdapter.java | 2 +-
.../org/apache/openejb/config/sys/Openejb.java | 2 +-
.../apache/openejb/config/sys/Resources.java | 10 +-
.../openejb/config/sys/SaxAppCtxConfig.java | 15 +-
.../apache/openejb/config/sys/SaxOpenejb.java | 21 +-
.../openejb/config/sys/ServiceProvider.java | 2 +-
.../apache/openejb/config/sys/ServicesJar.java | 2 +-
.../openejb/config/sys/WikiGenerator.java | 4 +-
.../openejb/config/typed/util/ObjectMap.java | 4 +-
.../config/typed/util/ProviderGenerator.java | 4 +-
.../apache/openejb/core/BaseSessionContext.java | 11 +-
.../openejb/core/CoreContainerSystem.java | 12 +-
...impleTransactionSynchronizationRegistry.java | 4 +-
.../org/apache/openejb/core/ThreadContext.java | 2 +-
.../org/apache/openejb/core/WebContext.java | 4 +-
.../apache/openejb/core/cmp/CmpContainer.java | 12 +-
.../openejb/core/cmp/ComplexKeyGenerator.java | 2 +-
.../openejb/core/cmp/cmp2/Cmp2Generator.java | 8 +-
.../apache/openejb/core/cmp/cmp2/CmrSet.java | 2 +-
.../openejb/core/cmp/cmp2/SetValuedCmr.java | 2 +-
.../openejb/core/cmp/jpa/JpaCmpEngine.java | 2 +-
.../openejb/core/entity/EntityContainer.java | 6 +-
.../openejb/core/entity/EntityContext.java | 4 +-
.../core/entity/EntityInstanceManager.java | 2 +-
.../openejb/core/entity/EntrancyTracker.java | 4 +-
.../core/interceptor/InterceptorData.java | 20 +-
.../core/interceptor/InterceptorStack.java | 2 +-
.../ReflectionInvocationContext.java | 2 +-
.../openejb/core/ivm/BaseEjbProxyHandler.java | 10 +-
.../openejb/core/ivm/EjbHomeProxyHandler.java | 6 +-
.../openejb/core/ivm/EjbObjectProxyHandler.java | 2 +-
.../openejb/core/ivm/IntraVmArtifact.java | 2 +-
.../ivm/naming/AbstractThreadLocalProxy.java | 2 +-
.../ivm/naming/ContextualJndiReference.java | 4 +-
.../openejb/core/ivm/naming/IvmContext.java | 16 +-
.../core/ivm/naming/JaxWsServiceReference.java | 8 +-
.../apache/openejb/core/managed/Instance.java | 4 +-
.../openejb/core/managed/ManagedContainer.java | 18 +-
.../openejb/core/managed/SimpleCache.java | 8 +-
.../openejb/core/managed/SimplePassivater.java | 4 +-
.../openejb/core/mdb/EndpointFactory.java | 2 +-
.../apache/openejb/core/mdb/MdbContainer.java | 4 +-
.../openejb/core/mdb/MdbInstanceManager.java | 12 +-
.../openejb/core/mdb/MdbPoolContainer.java | 4 +-
.../core/security/AbstractSecurityService.java | 6 +-
.../core/security/jaas/SQLLoginModule.java | 14 +-
.../core/security/jaas/ScriptLoginModule.java | 4 +-
.../jaas/ServiceProviderLoginModule.java | 4 +-
.../core/security/jacc/BasicJaccProvider.java | 2 +-
.../security/jacc/BasicPolicyConfiguration.java | 2 +-
.../core/singleton/SingletonContainer.java | 10 +-
.../singleton/SingletonInstanceManager.java | 6 +-
.../apache/openejb/core/stateful/Instance.java | 4 +-
.../openejb/core/stateful/SimpleCache.java | 8 +-
.../openejb/core/stateful/SimplePassivater.java | 4 +-
.../core/stateful/StatefulContainer.java | 14 +-
.../core/stateless/StatelessContainer.java | 10 +-
.../stateless/StatelessInstanceManager.java | 4 +-
.../openejb/core/timer/EJBCronTrigger.java | 20 +-
.../openejb/core/timer/EjbTimerServiceImpl.java | 4 +-
.../openejb/core/timer/MemoryTimerStore.java | 19 +-
.../core/transaction/JtaTransactionPolicy.java | 8 +-
.../core/webservices/HandlerChainData.java | 4 +-
.../openejb/core/webservices/HandlerData.java | 8 +-
.../core/webservices/HandlerResolverImpl.java | 16 +-
.../openejb/core/webservices/JaxWsUtils.java | 6 +-
.../webservices/PortAddressRegistryImpl.java | 18 +-
.../openejb/core/webservices/PortData.java | 4 +-
.../openejb/core/webservices/PortRefData.java | 2 +-
.../core/webservices/ProviderWrapper.java | 2 +-
.../core/webservices/ServiceRefData.java | 4 +-
.../apache/openejb/dyni/DynamicSubclass.java | 2 +-
.../org/apache/openejb/log/ColorFormatter.java | 2 +-
.../apache/openejb/log/logger/Log4jLogger.java | 2 +-
.../apache/openejb/log/logger/Slf4jLogger.java | 5 +-
.../stat/descriptive/DescriptiveStatistics.java | 2 +-
.../math/stat/descriptive/moment/Kurtosis.java | 2 +-
.../math/stat/descriptive/moment/Skewness.java | 2 +-
.../openejb/monitoring/DynamicMBeanWrapper.java | 12 +-
.../apache/openejb/monitoring/ManagedMBean.java | 14 +-
.../openejb/monitoring/ObjectNameBuilder.java | 2 +-
.../openejb/monitoring/StatsInterceptor.java | 2 +-
.../remote/RemoteResourceMonitor.java | 4 +-
.../openejb/persistence/JtaEntityManager.java | 2 +-
.../persistence/JtaEntityManagerRegistry.java | 2 +-
.../apache/openejb/persistence/JtaQuery.java | 2 +-
.../persistence/PersistenceBootstrap.java | 8 +-
.../persistence/PersistenceUnitInfoImpl.java | 6 +-
.../openejb/resource/AutoConnectionTracker.java | 16 +-
.../resource/activemq/ActiveMQ5Factory.java | 4 +-
.../resource/jdbc/DataSourceFactory.java | 2 +-
.../resource/jdbc/dbcp/BasicDataSource.java | 2 +-
.../jdbc/dbcp/BasicManagedDataSource.java | 2 +-
.../resource/jdbc/driver/AlternativeDriver.java | 2 +-
.../logging/LoggingPreparedSqlStatement.java | 2 +-
.../jdbc/pool/PoolDataSourceCreator.java | 2 +-
.../jdbc/pool/XADataSourceResource.java | 2 +-
.../resource/jdbc/router/FailOverRouter.java | 4 +-
.../resource/quartz/QuartzResourceAdapter.java | 8 +-
.../rest/AbstractRestThreadLocalProxy.java | 2 +-
...MultivaluedMapWithCaseInsensitiveKeySet.java | 2 +-
.../openejb/rest/ThreadLocalHttpHeaders.java | 2 +-
.../openejb/ri/sp/PseudoTransactionService.java | 14 +-
.../java/org/apache/openejb/table/Lines.java | 2 +-
.../openejb/testing/ApplicationComposers.java | 30 +-
.../openejb/testng/PropertiesBuilder.java | 2 +-
.../impl/ManagedExecutorServiceImpl.java | 2 +-
.../ManagedScheduledExecutorServiceImpl.java | 12 +-
.../apache/openejb/util/AnnotationFinder.java | 21 +-
.../apache/openejb/util/AsynchronousRunner.java | 2 +-
.../java/org/apache/openejb/util/Classes.java | 4 +-
.../java/org/apache/openejb/util/Debug.java | 14 +-
.../apache/openejb/util/DirectoryMonitor.java | 4 +-
.../java/org/apache/openejb/util/Duration.java | 2 +-
.../apache/openejb/util/ExecutorBuilder.java | 8 +-
.../java/org/apache/openejb/util/Index.java | 20 +-
.../openejb/util/IntrospectionSupport.java | 6 +-
.../main/java/org/apache/openejb/util/Join.java | 2 +-
.../org/apache/openejb/util/LinkResolver.java | 6 +-
.../apache/openejb/util/ListConfigurator.java | 2 +-
.../openejb/util/Log4jLogStreamFactory.java | 2 +-
.../apache/openejb/util/Log4jPrintWriter.java | 4 +-
.../java/org/apache/openejb/util/Logger.java | 6 +-
.../apache/openejb/util/LoggingPrintWriter.java | 4 +-
.../java/org/apache/openejb/util/Memoizer.java | 4 +-
.../java/org/apache/openejb/util/Messages.java | 4 +-
.../apache/openejb/util/ObjectRecipeHelper.java | 2 +-
.../apache/openejb/util/OpenEJBScripter.java | 2 +-
.../apache/openejb/util/PojoSerialization.java | 2 +-
.../main/java/org/apache/openejb/util/Pool.java | 2 +-
.../apache/openejb/util/PropertiesHelper.java | 2 +-
.../org/apache/openejb/util/References.java | 20 +-
.../apache/openejb/util/SimpleJSonParser.java | 4 +-
.../java/org/apache/openejb/util/Strings.java | 2 +-
.../apache/openejb/util/SuperProperties.java | 16 +-
.../org/apache/openejb/util/URISupport.java | 16 +-
.../org/apache/openejb/util/UpdateChecker.java | 2 +-
.../java/org/apache/openejb/util/UrlCache.java | 12 +-
.../org/apache/openejb/util/UrlComparator.java | 2 +-
.../openejb/util/helper/CommandHelper.java | 6 +-
.../openejb/util/proxy/Jdk13ProxyFactory.java | 2 +-
.../util/proxy/LocalBeanProxyFactory.java | 6 +-
.../org/apache/openejb/util/proxy/ProxyEJB.java | 2 +-
.../apache/openejb/util/proxy/QueryProxy.java | 6 +-
.../openejb/web/LightweightWebAppBuilder.java | 24 +-
.../apache/openejb/config/Messages.properties | 3 +
.../src/main/resources/test-orm.xml | 32 +
.../openejb/DependenceValidationTest.java | 2 +-
.../org/apache/openejb/DependencyVisitor.java | 8 +-
.../apache/openejb/OpenEjbContainerTest.java | 4 +-
.../openejb/assembler/DeployerEjbTest.java | 2 +-
.../assembler/classic/AccessTimeoutTest.java | 4 +-
.../classic/AppNamingReadOnlyTest.java | 4 +-
.../classic/ConcurrentLockTypeTest.java | 4 +-
.../assembler/classic/ConcurrentMethodTest.java | 4 +-
.../classic/DataSourceDefinitionTest.java | 2 +-
.../DescriptorDataSourceDefinitionTest.java | 2 +-
.../InterceptorBindingInfoComparatorTest.java | 10 +-
.../assembler/classic/JdbcConfigTest.java | 4 +-
.../assembler/classic/LinkResolverTest.java | 2 +-
.../MethodTransactionInfoComparatorTest.java | 6 +-
.../OpenEjbConfigurationValidationTest.java | 2 +-
.../classic/ResourceInfoComparatorTest.java | 6 +-
.../apache/openejb/cdi/BasicObserverTest.java | 2 +-
.../apache/openejb/cdi/DependentScopedTest.java | 2 +-
.../openejb/config/AnnotationDeployerTest.java | 2 +-
.../config/ApplicationPropertiesTest.java | 14 +-
.../config/AutoConfigMdbContainerTest.java | 2 +-
.../config/AutoConfigResourceRefsTest.java | 4 +-
.../apache/openejb/config/AutoDeployerTest.java | 2 +-
.../openejb/config/BeanPropertiesTest.java | 12 +-
.../openejb/config/BusinessInterfacesTest.java | 8 +-
.../config/CheckDescriptorLocationTest.java | 6 +-
...escriptorLocationTestFileDeletionHelper.java | 2 +-
.../openejb/config/CleanEnvEntriesTest.java | 2 +-
.../openejb/config/DeploymentLoaderTest.java | 4 +-
.../openejb/config/DeploymentsElementTest.java | 16 +-
.../openejb/config/EarModuleNamesTest.java | 28 +-
.../apache/openejb/config/EarUnpackTest.java | 4 +-
.../apache/openejb/config/EjbModuleIdTest.java | 14 +-
.../openejb/config/JMXDataSourceTest.java | 2 +-
.../config/JndiEncInfoBuilderInsertTest.java | 10 +-
.../openejb/config/MBeanDeployerTest.java | 2 +-
.../openejb/config/ModulePropertiesTest.java | 10 +-
.../PersistenceContextAnnFactoryTest.java | 2 +-
.../openejb/config/ProviderManagerTest.java | 4 +-
.../openejb/config/ServiceClasspathTest.java | 6 +-
.../openejb/config/SunCmpConversionTest.java | 2 +-
.../apache/openejb/config/XmlOverridesTest.java | 2 +-
...CheckInvalidAsynchronousAnnotationsTest.java | 4 +-
.../openejb/config/rules/InvokeMethod.java | 10 +-
.../config/rules/KeysAnnotationVisitor.java | 4 +-
.../config/rules/ValidationAssertions.java | 2 +-
.../config/rules/ValidationKeysAuditorTest.java | 22 +-
.../openejb/core/InheritedAppExceptionTest.java | 2 +-
.../openejb/core/LegacyInterfaceTest.java | 73 +-
.../openejb/core/asynch/AsynchInRoleTest.java | 14 +-
.../apache/openejb/core/asynch/AsynchTest.java | 14 +-
.../apache/openejb/core/cmp/jpa/AuthorBean.java | 2 +-
.../apache/openejb/core/cmp/jpa/BookBean.java | 2 +-
.../openejb/core/ivm/naming/IvmContextTest.java | 4 +-
.../core/mdb/CustomMdbContainerTest.java | 2 +-
.../org/apache/openejb/core/mdb/JmsTest.java | 4 +-
.../org/apache/openejb/core/mdb/MdbInvoker.java | 4 +-
.../org/apache/openejb/core/mdb/MdbProxy.java | 2 +-
.../org/apache/openejb/core/mdb/MdbTest.java | 4 +-
.../openejb/core/mdb/NoMessageDeliveryTest.java | 2 +-
.../connector/impl/SampleManagedConnection.java | 2 +-
.../connector/impl/SampleResourceAdapter.java | 2 +-
.../core/security/SecurityServiceImplTest.java | 3 +-
.../core/singleton/AsyncPostContructTest.java | 6 +-
.../stateful/EntityManagerPropogationTest.java | 4 +-
.../stateful/StatefulConcurrentLookupTest.java | 2 +-
.../core/stateful/StatefulContainerTest.java | 8 +-
.../StatefulSecurityPermissionsTest.java | 2 +-
.../core/stateless/StatelessContainerTest.java | 3 +-
.../stateless/StatelessInvocationStatsTest.java | 3 +-
.../stateless/StatelessMetaAnnotationTest.java | 3 +-
.../core/stateless/StatelessPoolStatsTest.java | 13 +-
.../core/webservices/JPACMDIntegrationTest.java | 325 +
.../interceptors/FullyInterceptedBean.java | 4 +-
.../interceptors/FullyInterceptedTest.java | 4 +-
.../MethodLevelInterceptorOnlySLSBean.java | 2 +-
.../MethodLevelInterceptorOnlyTest.java | 2 +-
.../SecondStatelessInterceptedBean.java | 2 +-
.../SecondStatelessInterceptedTest.java | 2 +-
.../openejb/interceptors/ThirdSLSBean.java | 4 +-
.../openejb/interceptors/ThirdSLSBeanTest.java | 4 +-
.../org/apache/openejb/interceptors/Utils.java | 2 +-
.../openejb/ivm/naming/IvmContextTest.java | 4 +-
.../java/org/apache/openejb/meta/MetaTest.java | 4 +-
.../persistence/JtaEntityManagerTest.java | 2 +-
.../resource/AutoConnectionTrackerTest.java | 8 +-
.../resource/jdbc/DynamicDataSourceTest.java | 6 +-
.../MultiThreadedManagedDataSourceTest.java | 2 +-
.../cmr/onetomany/ExampleABean_ABean.java | 4 +-
.../entity/cmr/onetoone/ExampleABean_ABean.java | 2 +-
.../entity/cmr/onetoone/ExampleBBean_BBean.java | 2 +-
.../TransactionRollbackCauseTest.java | 2 +-
.../java/org/apache/openejb/util/Archives.java | 2 +-
.../apache/openejb/util/DynamicEJBImplTest.java | 4 +-
.../org/apache/openejb/util/OptionsTest.java | 2 +-
.../java/org/apache/openejb/util/PoolTest.java | 18 +-
.../org/apache/openejb/util/PropertiesTest.java | 2 +-
.../org/apache/openejb/util/ReferencesTest.java | 28 +-
.../openejb/util/SuperPropertiesTest.java | 2 +-
.../apache/openejb/util/UrlComparatorTest.java | 2 +-
.../org/apache/openejb/util/WebArchives.java | 2 +-
.../util/proxy/LocalBeanProxyFactoryTest.java | 6 +-
.../openejb/util/proxy/SampleLocalBean.java | 2 +-
.../org/apache/openejb/javaagent/Agent.java | 2 +-
.../openejb/jee/FacesConfigFlowDefinition.java | 2 +-
.../jee/HandlerChainsStringQNameAdapter.java | 2 +-
.../openejb/jee/oejb2/NamespaceFilter.java | 2 +-
.../org/apache/openejb/junit/OpenEjbRunner.java | 4 +-
.../junit/context/OpenEjbTestContext.java | 8 +-
.../org/apache/openejb/junit/context/Util.java | 11 +-
.../openejb/loader/BasicURLClassPath.java | 4 +-
.../java/org/apache/openejb/loader/Options.java | 12 +-
.../loader/provisining/MavenResolver.java | 2 +-
docs/Configuring-in-tomee.adoc | 49 +
docs/Configuring-in-tomee.md | 45 -
docs/activemqresourceadapter-config.adoc | 90 +
docs/activemqresourceadapter-config.md | 69 -
docs/admin/cluster/index.adoc | 23 +-
docs/admin/configuration/application.adoc | 16 +-
docs/admin/configuration/containers.adoc | 100 +-
docs/admin/configuration/index.adoc | 4 +-
docs/admin/configuration/resources.adoc | 128 +-
docs/admin/configuration/server.adoc | 4 +-
docs/admin/index.adoc | 2 +-
docs/advanced/client/jndi.adoc | 24 +-
docs/advanced/index.adoc | 2 +-
docs/advanced/jms/jms-configuration.adoc | 4 +-
docs/advanced/setup/index.adoc | 9 +-
docs/advanced/shading/index.adoc | 4 +-
docs/advanced/tomee-embedded/index.adoc | 4 +-
docs/alternate-descriptors.adoc | 124 +
docs/alternate-descriptors.md | 117 -
docs/annotations,-xml-and-defaults.adoc | 22 +
docs/annotations,-xml-and-defaults.md | 569 --
docs/app-clients-and-jndi.adoc | 74 +
docs/app-clients-and-jndi.md | 73 -
docs/application-composer/advanced.adoc | 111 +
docs/application-composer/advanced.md | 90 -
docs/application-composer/getting-started.adoc | 234 +
docs/application-composer/getting-started.md | 188 -
docs/application-composer/history.adoc | 48 +
docs/application-composer/history.md | 38 -
docs/application-composer/index.adoc | 20 +
docs/application-composer/index.md | 18 -
docs/application-deployment-solutions.adoc | 92 +
docs/application-deployment-solutions.md | 78 -
...application-discovery-via-the-classpath.adoc | 111 +
docs/application-discovery-via-the-classpath.md | 94 -
docs/application-resources.adoc | 375 +
docs/application-resources.md | 250 -
docs/arquillian-available-adapters.adoc | 319 +
docs/arquillian-available-adapters.md | 264 -
docs/arquillian-getting-started.adoc | 41 +
docs/arquillian-getting-started.md | 24 -
docs/basics---getting-things.adoc | 108 +
docs/basics---getting-things.md | 107 -
docs/basics---security.adoc | 55 +
docs/basics---security.md | 55 -
docs/basics---transactions.adoc | 67 +
docs/basics---transactions.md | 60 -
docs/bmpentitycontainer-config.adoc | 55 +
docs/bmpentitycontainer-config.md | 37 -
docs/bouncy-castle.adoc | 40 +
docs/bouncy-castle.md | 34 -
docs/built-in-type-converters.adoc | 101 +
docs/built-in-type-converters.md | 94 -
docs/callbacks.adoc | 169 +
docs/callbacks.md | 167 -
docs/changing-jms-implementations.adoc | 161 +
docs/changing-jms-implementations.md | 136 -
docs/client-server-transports.adoc | 39 +
docs/client-server-transports.md | 22 -
docs/clients.adoc | 101 +
docs/clients.md | 104 -
docs/cmpentitycontainer-config.adoc | 53 +
docs/cmpentitycontainer-config.md | 36 -
docs/collapsed-ear.adoc | 49 +
docs/collapsed-ear.md | 46 -
docs/common-datasource-configurations.adoc | 123 +
docs/common-datasource-configurations.md | 115 -
docs/common-errors.adoc | 31 +
docs/common-errors.md | 30 -
docs/common-persistenceprovider-properties.adoc | 50 +
docs/common-persistenceprovider-properties.md | 47 -
docs/comparison.adoc | 231 +
docs/comparison.md | 222 -
docs/concepts.adoc | 83 +
docs/concepts.md | 79 -
docs/configuration.adoc | 151 +
docs/configuration.md | 144 -
docs/configuring-containers-in-tests.adoc | 30 +
docs/configuring-containers-in-tests.md | 27 -
docs/configuring-datasources-in-tests.adoc | 68 +
docs/configuring-datasources-in-tests.md | 60 -
docs/configuring-datasources.adoc | 204 +
docs/configuring-datasources.md | 170 -
docs/configuring-durations.adoc | 70 +
docs/configuring-durations.md | 67 -
docs/configuring-javamail.adoc | 44 +
docs/configuring-javamail.md | 41 -
docs/configuring-logging-in-tests.adoc | 121 +
docs/configuring-logging-in-tests.md | 118 -
docs/configuring-persistenceunits-in-tests.adoc | 160 +
docs/configuring-persistenceunits-in-tests.md | 144 -
docs/constructor-injection.adoc | 103 +
docs/constructor-injection.md | 98 -
docs/containers-and-resources.adoc | 474 ++
docs/containers-and-resources.md | 483 --
docs/contrib/debug/debug-intellij.adoc | 182 +
docs/contrib/debug/debug-intellij.md | 133 -
docs/custom-injection.adoc | 209 +
docs/custom-injection.md | 193 -
docs/datasource-config.adoc | 535 ++
docs/datasource-config.md | 541 --
docs/datasource-configuration-by-creator.adoc | 160 +
docs/datasource-configuration-by-creator.md | 151 -
docs/datasource-password-encryption.adoc | 168 +
docs/datasource-password-encryption.md | 128 -
docs/deamon/lin-service.adoc | 24 +
docs/deamon/lin-service.md | 17 -
docs/deamon/win-service.adoc | 24 +
docs/deamon/win-service.md | 17 -
docs/declaring-references.adoc | 5 +
docs/declaring-references.md | 6 -
docs/deploy-tool.adoc | 167 +
docs/deploy-tool.md | 165 -
docs/deploying-in-tomee.adoc | 73 +
docs/deploying-in-tomee.md | 73 -
docs/deployment-id.adoc | 236 +
docs/deployment-id.md | 231 -
docs/deployments.adoc | 153 +
docs/deployments.md | 135 -
docs/details-on-openejb-jar.adoc | 156 +
docs/details-on-openejb-jar.md | 156 -
docs/developer/classloading/index.adoc | 1 -
docs/developer/ide/index.adoc | 8 +-
docs/developer/index.adoc | 2 +-
docs/developer/json/index.adoc | 3 +-
.../testing/applicationcomposer/index.adoc | 50 +-
docs/developer/testing/arquillian/index.adoc | 24 +-
docs/developer/testing/other/index.adoc | 10 +-
docs/developer/tools/gradle-plugins.adoc | 2 +-
.../tools/maven/applicationcomposer.adoc | 8 +-
docs/developer/tools/maven/embedded.adoc | 2 +-
docs/developer/tools/maven/tomee.adoc | 18 +-
docs/docs.adoc | 8 +-
docs/documentation.adoc | 103 +
docs/documentation.md | 106 -
docs/documentation.old.adoc | 98 +
docs/documentation.old.md | 102 -
docs/dynamic-datasource.adoc | 224 +
docs/dynamic-datasource.md | 220 -
docs/eclipse-plugin.adoc | 41 +
docs/eclipse-plugin.md | 42 -
docs/ejb-failover.adoc | 93 +
docs/ejb-failover.md | 89 -
docs/ejb-local-ref.adoc | 56 +
docs/ejb-local-ref.md | 52 -
docs/ejb-over-ssl.adoc | 137 +
docs/ejb-over-ssl.md | 100 -
docs/ejb-ref.adoc | 55 +
docs/ejb-ref.md | 50 -
docs/ejb-refs.adoc | 199 +
docs/ejb-refs.md | 178 -
docs/ejb-request-logging.adoc | 158 +
docs/ejb-request-logging.md | 98 -
docs/ejbd-transport.adoc | 212 +
docs/ejbd-transport.md | 136 -
docs/embedded-and-remotable.adoc | 177 +
docs/embedded-and-remotable.md | 181 -
docs/embedded-configuration.adoc | 138 +
docs/embedded-configuration.md | 135 -
docs/embedding.adoc | 34 +
docs/embedding.md | 30 -
docs/failover-logging.adoc | 58 +
docs/failover-logging.md | 42 -
docs/faq.adoc | 108 +
docs/faq.md | 99 -
docs/features.adoc | 5 +
docs/features.md | 6 -
docs/from-glassfish-to-tomee.adoc | 11 +
docs/from-glassfish-to-tomee.md | 7 -
...esting-with-openejb,-jetty-and-selenium.adoc | 238 +
...-testing-with-openejb,-jetty-and-selenium.md | 240 -
docs/generating-ejb-3-annotations.adoc | 65 +
docs/generating-ejb-3-annotations.md | 61 -
docs/getting-started.adoc | 178 +
docs/getting-started.md | 172 -
docs/hello-world.adoc | 263 +
docs/hello-world.md | 250 -
docs/hibernate.adoc | 103 +
docs/hibernate.md | 98 -
docs/initialcontext-config.adoc | 44 +
docs/initialcontext-config.md | 26 -
docs/installation-drop-in-war.adoc | 55 +
docs/installation-drop-in-war.md | 45 -
docs/installation.adoc | 35 +
docs/installation.md | 34 -
docs/installing-tomee.adoc | 87 +
docs/installing-tomee.md | 71 -
docs/java7.adoc | 40 +
docs/java7.md | 40 -
docs/javaagent-with-maven-surefire.adoc | 38 +
docs/javaagent-with-maven-surefire.md | 57 -
docs/javaagent.adoc | 66 +
docs/javaagent.md | 61 -
docs/javaee7-status.adoc | 218 +
docs/javaee7-status.md | 185 -
docs/javamailsession-config.adoc | 44 +
docs/javamailsession-config.md | 26 -
docs/jms-resources-and-mdb-container.adoc | 362 +
docs/jms-resources-and-mdb-container.md | 283 -
docs/jmsconnectionfactory-config.adoc | 104 +
docs/jmsconnectionfactory-config.md | 87 -
docs/jndi-names.adoc | 401 ++
docs/jndi-names.md | 372 -
docs/jpa-concepts.adoc | 227 +
docs/jpa-concepts.md | 220 -
docs/jpa-usage.adoc | 48 +
docs/jpa-usage.md | 52 -
docs/local-client-injection.adoc | 87 +
docs/local-client-injection.md | 87 -
docs/local-server.adoc | 56 +
docs/local-server.md | 61 -
docs/lookup-of-other-ejbs-example.adoc | 148 +
docs/lookup-of-other-ejbs-example.md | 149 -
docs/managedcontainer-config.adoc | 44 +
docs/managedcontainer-config.md | 26 -
docs/manual-installation.adoc | 148 +
docs/manual-installation.md | 224 -
docs/maven.adoc | 63 +
docs/maven.md | 42 -
docs/maven/build-mojo.adoc | 1169 +++
docs/maven/build-mojo.md | 1426 ----
docs/maven/configtest-mojo.adoc | 1086 +++
docs/maven/configtest-mojo.md | 1328 ----
docs/maven/debug-mojo.adoc | 1139 +++
docs/maven/debug-mojo.md | 1395 ----
docs/maven/deploy-mojo.adoc | 196 +
docs/maven/deploy-mojo.md | 255 -
docs/maven/exec-mojo.adoc | 1277 ++++
docs/maven/exec-mojo.md | 1551 ----
docs/maven/help-mojo.adoc | 115 +
docs/maven/help-mojo.md | 149 -
docs/maven/index.adoc | 178 +
docs/maven/index.md | 148 -
docs/maven/list-mojo.adoc | 132 +
docs/maven/list-mojo.md | 169 -
docs/maven/run-mojo.adoc | 1139 +++
docs/maven/run-mojo.md | 1395 ----
docs/maven/start-mojo.adoc | 1139 +++
docs/maven/start-mojo.md | 1395 ----
docs/maven/stop-mojo.adoc | 1086 +++
docs/maven/stop-mojo.md | 1328 ----
docs/maven/undeploy-mojo.adoc | 159 +
docs/maven/undeploy-mojo.md | 209 -
docs/messagedrivencontainer-config.adoc | 87 +
docs/messagedrivencontainer-config.md | 67 -
docs/multicast-discovery.adoc | 93 +
docs/multicast-discovery.md | 83 -
docs/multiple-business-interface-hazzards.adoc | 209 +
docs/multiple-business-interface-hazzards.md | 202 -
docs/multipoint-considerations.adoc | 31 +
docs/multipoint-considerations.md | 30 -
docs/multipoint-discovery.adoc | 87 +
docs/multipoint-discovery.md | 75 -
docs/multipoint-recommendations.adoc | 153 +
docs/multipoint-recommendations.md | 141 -
docs/multipulse-discovery.adoc | 112 +
docs/multipulse-discovery.md | 94 -
docs/new-in-openejb-3.0.adoc | 157 +
docs/new-in-openejb-3.0.md | 179 -
docs/openejb-3.adoc | 69 +
docs/openejb-3.md | 72 -
docs/openejb-binaries.adoc | 34 +
docs/openejb-binaries.md | 27 -
docs/openejb-eclipse-plugin.adoc | 22 +
docs/openejb-eclipse-plugin.md | 22 -
docs/openejb-jsr-107-integration.adoc | 24 +
docs/openejb-jsr-107-integration.md | 25 -
docs/openejb.xml.adoc | 100 +
docs/openejb.xml.md | 96 -
docs/openjpa.adoc | 132 +
docs/openjpa.md | 113 -
docs/orb-config.adoc | 42 +
docs/orb-config.md | 26 -
docs/persistence-context.adoc | 61 +
docs/persistence-context.md | 57 -
docs/persistence-unit-ref.adoc | 95 +
docs/persistence-unit-ref.md | 91 -
docs/properties-listing.adoc | 729 ++
docs/properties-listing.md | 94 -
docs/properties-tool.adoc | 219 +
docs/properties-tool.md | 216 -
docs/property-overriding.adoc | 64 +
docs/property-overriding.md | 65 -
docs/provisioning.adoc | 102 +
docs/provisioning.md | 78 -
docs/proxyfactory-config.adoc | 44 +
docs/proxyfactory-config.md | 26 -
docs/queue-config.adoc | 50 +
docs/queue-config.md | 36 -
docs/quickstart.adoc | 69 +
docs/quickstart.md | 71 -
docs/remote-server.adoc | 72 +
docs/remote-server.md | 64 -
docs/resource-injection.adoc | 209 +
docs/resource-injection.md | 184 -
docs/resource-ref-for-datasource.adoc | 55 +
docs/resource-ref-for-datasource.md | 46 -
docs/running-a-standalone-openejb-server.adoc | 77 +
docs/running-a-standalone-openejb-server.md | 95 -
docs/securing-a-web-service.adoc | 240 +
docs/securing-a-web-service.md | 242 -
docs/security-annotations.adoc | 301 +
docs/security-annotations.md | 296 -
docs/security.adoc | 201 +
docs/security.md | 148 -
docs/securityservice-config.adoc | 52 +
docs/securityservice-config.md | 36 -
docs/service-locator.adoc | 168 +
docs/service-locator.md | 171 -
docs/services.adoc | 28 +
docs/services.md | 20 -
docs/singleton-beans.adoc | 232 +
docs/singleton-beans.md | 226 -
docs/singleton-ejb.adoc | 7 +
docs/singleton-ejb.md | 6 -
docs/singletoncontainer-config.adoc | 71 +
docs/singletoncontainer-config.md | 56 -
docs/spring-and-openejb-3.0.adoc | 234 +
docs/spring-and-openejb-3.0.md | 190 -
docs/spring-ejb-and-jpa.adoc | 197 +
docs/spring-ejb-and-jpa.md | 173 -
docs/spring.adoc | 139 +
docs/spring.md | 124 -
docs/ssh.adoc | 63 +
docs/ssh.md | 51 -
docs/standalone-server.adoc | 24 +
docs/standalone-server.md | 27 -
docs/startup.adoc | 272 +
docs/startup.md | 296 -
docs/statefulcontainer-config.adoc | 167 +
docs/statefulcontainer-config.md | 160 -
docs/statelesscontainer-config.adoc | 445 ++
docs/statelesscontainer-config.md | 461 --
docs/system-properties-files.adoc | 25 +
docs/system-properties-files.md | 22 -
docs/system-properties.adoc | 71 +
docs/system-properties.md | 68 -
docs/telnet-console.adoc | 165 +
docs/telnet-console.md | 166 -
docs/tip-concurrency.adoc | 34 +
docs/tip-concurrency.md | 26 -
docs/tip-jersey-client.adoc | 35 +
docs/tip-jersey-client.md | 22 -
docs/tip-weblogic.adoc | 22 +
docs/tip-weblogic.md | 17 -
docs/tomcat-object-factory.adoc | 17 +
docs/tomcat-object-factory.md | 15 -
docs/tomee-and-eclipse.adoc | 140 +
docs/tomee-and-eclipse.md | 145 -
docs/tomee-and-hibernate.adoc | 173 +
docs/tomee-and-hibernate.md | 163 -
docs/tomee-and-intellij.adoc | 82 +
docs/tomee-and-intellij.md | 81 -
docs/tomee-and-netbeans.adoc | 107 +
docs/tomee-and-netbeans.md | 97 -
docs/tomee-and-security.adoc | 56 +
docs/tomee-and-security.md | 45 -
docs/tomee-and-webspheremq.adoc | 26 +
docs/tomee-and-webspheremq.md | 136 -
docs/tomee-directory-structure.adoc | 25 +
docs/tomee-directory-structure.md | 61 -
docs/tomee-embedded-maven-plugin.adoc | 787 ++
docs/tomee-embedded-maven-plugin.md | 959 ---
docs/tomee-jaas.adoc | 93 +
docs/tomee-jaas.md | 73 -
docs/tomee-logging-in-eclipse.adoc | 19 +
docs/tomee-logging-in-eclipse.md | 13 -
docs/tomee-logging.adoc | 32 +
docs/tomee-logging.md | 33 -
docs/tomee-maven-plugin.adoc | 178 +
docs/tomee-maven-plugin.md | 148 -
docs/tomee-mp-getting-started.adoc | 103 +
docs/tomee-mp-getting-started.md | 65 -
docs/tomee-version-policies.adoc | 55 +
docs/tomee-version-policies.md | 28 -
docs/tomee-webaccess.adoc | 18 +
docs/tomee-webaccess.md | 21 -
docs/tomee-webapp.adoc | 75 +
docs/tomee-webapp.md | 62 -
docs/topic-config.adoc | 50 +
docs/topic-config.md | 36 -
docs/transaction-annotations.adoc | 230 +
docs/transaction-annotations.md | 219 -
docs/transactionmanager-config.adoc | 183 +
docs/transactionmanager-config.md | 166 -
docs/understanding-callbacks.adoc | 98 +
docs/understanding-callbacks.md | 92 -
docs/understanding-the-directory-layout.adoc | 74 +
docs/understanding-the-directory-layout.md | 72 -
docs/unix-daemon.adoc | 158 +
docs/unix-daemon.md | 108 -
docs/validation-tool.adoc | 143 +
docs/validation-tool.md | 141 -
docs/version-checker.adoc | 13 +
docs/version-checker.md | 12 -
examples/README.adoc | 21 +
examples/applicationcomposer-jaxws-cdi/pom.xml | 2 +-
examples/arquillian-jpa/pom.xml | 225 +-
.../test/persistence/PersistenceTest.java | 40 +-
examples/cdi-basic/README.md | 5 +-
examples/concurrency-utils/pom.xml | 68 +
.../executor/ManagedScheduledService.java | 129 +
.../org/superbiz/executor/ManagedService.java | 95 +
.../superbiz/executor/ThreadFactoryService.java | 71 +
.../executor/ManagedScheduledServiceTest.java | 130 +
.../superbiz/executor/ManagedServiceTest.java | 105 +
.../executor/ThreadFactoryServiceTest.java | 53 +
.../connector-starter-api/pom.xml | 50 -
.../connector/starter/api/InboundListener.java | 24 -
.../connector/starter/api/SampleConnection.java | 26 -
.../starter/api/SampleConnectionFactory.java | 28 -
.../src/main/resources/META-INF/LICENSE | 202 -
.../src/main/resources/META-INF/NOTICE | 7 -
.../connector-starter-impl/pom.xml | 60 -
.../starter/adapter/SampleActivationSpec.java | 54 -
.../adapter/SampleConnectionFactoryImpl.java | 69 -
.../starter/adapter/SampleConnectionImpl.java | 44 -
.../adapter/SampleManagedConnection.java | 139 -
.../adapter/SampleManagedConnectionFactory.java | 108 -
.../SampleManagedConnectionMetaData.java | 58 -
.../starter/adapter/SampleResourceAdapter.java | 92 -
.../src/main/resources/META-INF/LICENSE | 202 -
.../src/main/resources/META-INF/NOTICE | 7 -
.../connector-starter-rar/pom.xml | 43 -
.../src/main/rar/META-INF/LICENSE | 294 -
.../src/main/rar/META-INF/NOTICE | 5 -
.../src/main/rar/META-INF/ra.xml | 58 -
.../connector-starter-sample-war/pom.xml | 150 -
.../src/main/java/org/superbiz/Receiver.java | 35 -
.../src/main/java/org/superbiz/Sender.java | 52 -
.../src/main/resources/META-INF/LICENSE | 202 -
.../src/main/resources/META-INF/NOTICE | 7 -
.../src/main/resources/META-INF/ejb-jar.xml | 23 -
.../org/tomitribe/connector/starter/Runner.java | 104 -
.../src/test/resources/arquillian.xml | 30 -
.../connector-ear-sample/moviefun-ear/pom.xml | 74 -
examples/connector-ear-sample/pom.xml | 205 -
examples/ear-testing/business-logic/pom.xml | 2 +-
examples/ear-testing/business-model/pom.xml | 2 +-
examples/ear-testing/pom.xml | 2 +-
examples/java-modules/README.md | 7 +
examples/java-modules/pom.xml | 108 +
.../javamodules/rest/HelloResource.java | 29 +
.../javamodules/rest/HelloResourceTest.java | 45 +
.../src/test/resources/arquillian.xml | 33 +
examples/javamail/pom.xml | 2 +-
examples/mp-config-example/README.md | 46 +
examples/mp-config-example/pom.xml | 92 +
.../org/superbiz/config/PropertiesRest.java | 80 +
.../src/main/resources/META-INF/beans.xml | 0
.../META-INF/microprofile-config.properties | 3 +
.../org/superbiz/config/PropertiesRestTest.java | 53 +
.../src/test/resources/arquillian.xml | 30 +
examples/mp-faulttolerance-retry/README.md | 211 +
examples/mp-faulttolerance-retry/pom.xml | 93 +
.../java/org/superbiz/rest/WeatherGateway.java | 115 +
.../WeatherGatewayBusyServiceException.java | 20 +
.../rest/WeatherGatewayTimeoutException.java | 21 +
.../java/org/superbiz/rest/WeatherService.java | 73 +
.../org/superbiz/rest/WeatherServiceTest.java | 94 +
.../src/test/resources/arquillian.xml | 30 +
.../src/test/resources/beans.xml | 7 +
examples/mp-metrics-counted/README.md | 9 +-
examples/mp-metrics-counted/pom.xml | 33 +-
.../src/main/webapp/WEB-INF/web.xml | 25 +
examples/mp-metrics-timed/README.md | 4 +-
examples/mp-metrics-timed/pom.xml | 37 +-
.../src/main/webapp/WEB-INF/web.xml | 25 +
examples/mvc-cxf/README.md | 23 +
examples/mvc-cxf/pom.xml | 143 +
.../superbiz/application/MVCApplication.java | 23 +
.../org/superbiz/controller/HomeController.java | 32 +
.../superbiz/controller/PersonController.java | 154 +
.../main/java/org/superbiz/model/Address.java | 72 +
.../main/java/org/superbiz/model/Errors.java | 50 +
.../main/java/org/superbiz/model/Messages.java | 39 +
.../main/java/org/superbiz/model/Person.java | 125 +
.../superbiz/persistence/PersonProducer.java | 43 +
.../superbiz/persistence/PersonRepository.java | 29 +
.../src/main/resources/META-INF/beans.xml | 24 +
.../src/main/resources/META-INF/persistence.xml | 40 +
.../src/main/webapp/WEB-INF/views/change.jsp | 134 +
.../src/main/webapp/WEB-INF/views/home.jsp | 37 +
.../src/main/webapp/WEB-INF/views/insert.jsp | 131 +
.../src/main/webapp/WEB-INF/views/list.jsp | 92 +
examples/mvc-cxf/src/main/webapp/index.jsp | 28 +
.../bootstrap/css/bootstrap-datepicker.css | 471 ++
.../resources/bootstrap/css/bootstrap-theme.css | 587 ++
.../bootstrap/css/bootstrap-theme.css.map | 1 +
.../bootstrap/css/bootstrap-theme.min.css | 6 +
.../bootstrap/css/bootstrap-theme.min.css.map | 1 +
.../resources/bootstrap/css/bootstrap.css | 6757 ++++++++++++++++++
.../resources/bootstrap/css/bootstrap.css.map | 1 +
.../resources/bootstrap/css/bootstrap.min.css | 6 +
.../bootstrap/css/bootstrap.min.css.map | 1 +
.../fonts/glyphicons-halflings-regular.eot | Bin 0 -> 20127 bytes
.../fonts/glyphicons-halflings-regular.svg | 288 +
.../fonts/glyphicons-halflings-regular.ttf | Bin 0 -> 45404 bytes
.../fonts/glyphicons-halflings-regular.woff | Bin 0 -> 23424 bytes
.../fonts/glyphicons-halflings-regular.woff2 | Bin 0 -> 18028 bytes
.../bootstrap/js/bootstrap-datepicker.js | 2096 ++++++
.../js/bootstrap-datepicker.pt-BR.min.js | 1 +
.../webapp/resources/bootstrap/js/bootstrap.js | 2377 ++++++
.../resources/bootstrap/js/bootstrap.min.js | 7 +
.../webapp/resources/bootstrap/js/jquery.min.js | 4 +
.../main/webapp/resources/bootstrap/js/npm.js | 13 +
.../src/main/webapp/resources/images/tomee.png | Bin 0 -> 6217 bytes
.../src/main/webapp/templates/footer.jsp | 46 +
.../mvc-cxf/src/main/webapp/templates/menu.jsp | 47 +
examples/pom.xml | 20 +-
examples/quartz-app/README.md | 6 +-
examples/realm-in-tomee/README.md | 6 +-
.../README.md | 6 +-
.../moviefun/MoviesArquillianHtmlUnitTest.java | 2 +-
.../openejb/test/SuperInterceptedBean.java | 6 +-
.../entity/bmp/BasicBmp2DataSourcesBean.java | 4 +-
.../openejb/test/entity/bmp/RmiIiopBmpBean.java | 1 -
.../test/interceptor/ClassInterceptor.java | 10 +-
.../openejb/test/interceptor/DDInterceptor.java | 10 +-
.../test/interceptor/MethodInterceptor.java | 4 +-
.../interceptor/SecondClassInterceptor.java | 10 +-
.../test/interceptor/SuperClassInterceptor.java | 10 +-
.../test/singleton/BeanTxSingletonBean.java | 1 -
.../test/stateless/BeanTxStatelessBean.java | 1 -
.../org/apache/openejb/test/RiTestServer.java | 1 -
maven/tomee-webapp-archetype/pom.xml | 4 +-
.../main/resources/archetype-resources/pom.xml | 8 +-
mp-jwt/pom.xml | 12 +
.../tomee/microprofile/jwt/MPJWTFilter.java | 52 +-
.../tomee/microprofile/jwt/cdi/ClaimBean.java | 19 +-
.../microprofile/jwt/cdi/MPJWTCDIExtension.java | 48 +-
.../config/ConfigurableJWTAuthContextInfo.java | 326 +
.../jwt/config/JWTAuthContextInfo.java | 66 +-
.../principal/DefaultJWTCallerPrincipal.java | 2 +
.../DefaultJWTCallerPrincipalFactory.java | 11 +-
.../jwt/principal/JWTCallerPrincipal.java | 2 +
.../META-INF/org.apache.openejb.extension | 2 +-
pom.xml | 13 +-
.../apache/openejb/server/axis/AxisService.java | 8 +-
.../openejb/server/axis/AxisWsContainer.java | 17 +-
.../openejb/server/axis/EjbRpcProvider.java | 22 +-
.../openejb/server/axis/PojoProvider.java | 21 +
.../server/axis/ReadOnlyServiceDesc.java | 208 +
.../assembler/CommonsSchemaInfoBuilder.java | 14 +-
.../axis/assembler/CommonsSchemaLoader.java | 11 +-
.../HeavyweightOperationInfoBuilder.java | 112 +-
.../assembler/HeavyweightTypeInfoBuilder.java | 26 +-
.../server/axis/assembler/JaxRpcFaultInfo.java | 2 +-
.../axis/assembler/JaxRpcOperationInfo.java | 4 +-
.../axis/assembler/JaxRpcServiceInfo.java | 4 +-
.../assembler/JaxRpcServiceInfoBuilder.java | 2 +-
.../server/axis/assembler/JaxRpcTypeInfo.java | 2 +-
.../assembler/LightweightTypeInfoBuilder.java | 4 +-
.../server/axis/assembler/XmlSchemaInfo.java | 4 +-
.../server/axis/assembler/XmlTypeInfo.java | 4 +-
.../server/axis/client/ArrayTypeInfo.java | 10 +
.../server/axis/client/AxisClientImpl.java | 6 +
.../axis/client/AxisServiceReference.java | 6 +
.../client/GenericServiceEndpointWrapper.java | 3 +
.../axis/client/NoOverrideCallbackFilter.java | 8 +
.../ServiceEndpointMethodInterceptor.java | 10 +
.../axis/client/ServiceMethodInterceptor.java | 10 +
.../server/cli/command/ClassLoaderCommand.java | 2 +-
.../server/cli/command/DeployedAppCommand.java | 2 +-
.../server/cxf/rs/TestCLIFromJaxRSTest.java | 70 +
.../org/apache/openejb/daemon/NTService.java | 9 +-
.../openejb/server/ejbd/AuthRequestHandler.java | 14 +-
.../apache/openejb/server/ejbd/CallContext.java | 10 +-
.../server/ejbd/ClientObjectFactory.java | 6 +-
.../apache/openejb/server/ejbd/EjbDaemon.java | 28 +-
.../openejb/server/ejbd/EjbRequestHandler.java | 38 +-
.../openejb/server/ejbd/JndiRequestHandler.java | 22 +-
.../openejb/server/ejbd/KeepAliveServer.java | 14 +-
.../server/ejbd/LogoutRequestHandler.java | 15 +-
.../openejb/server/ejbd/ServerSideResolver.java | 4 +-
.../openejb/server/discovery/EchoNet.java | 2 +-
.../discovery/MulticastDiscoveryAgent.java | 10 +-
.../server/discovery/MulticastPulseAgent.java | 46 +-
.../discovery/MultipointDiscoveryAgent.java | 12 +-
.../server/discovery/MultipointServer.java | 58 +-
.../openejb/server/discovery/Tracker.java | 10 +-
.../apache/openejb/server/DiscoveryAgent.java | 6 +-
.../openejb/server/DiscoveryListener.java | 1 -
.../openejb/server/DiscoveryRegistry.java | 14 +-
.../openejb/server/FilteredServiceManager.java | 2 +-
.../java/org/apache/openejb/server/Main.java | 1 -
.../openejb/server/ServiceAccessController.java | 4 +-
.../apache/openejb/server/ServiceDaemon.java | 18 +-
.../apache/openejb/server/ServiceManager.java | 2 +-
.../java/org/apache/openejb/server/Start.java | 2 +-
.../org/apache/openejb/server/admin/Stop.java | 6 +-
.../server/auth/ExactIPAddressPermission.java | 1 +
.../server/auth/ExactIPv6AddressPermission.java | 1 +
.../auth/FactorizedIPAddressPermission.java | 1 +
.../server/auth/IPAddressPermissionEditor.java | 2 +
.../server/auth/NetmaskIPAddressPermission.java | 1 +
.../auth/NetmaskIPv6AddressPermission.java | 1 +
.../server/auth/PermitAllPermission.java | 1 +
.../auth/StartWithIPAddressPermission.java | 1 +
.../apache/openejb/server/osgi/Activator.java | 2 +
.../server/osgi/ServiceManagerExtender.java | 6 +-
.../server/stream/CountingOutputStream.java | 2 +
.../LightWeightMappingValidator.java | 12 +-
.../openejb/server/webservices/WsService.java | 71 +-
.../openejb/server/webservices/WsServlet.java | 27 +-
.../openejb/server/webservices/WsdlVisitor.java | 4 +-
.../webservices/saaj/MessageFactoryImpl.java | 2 +
.../webservices/saaj/SaajFactoryFinder.java | 10 +-
.../webservices/saaj/SaajMetaFactoryImpl.java | 2 +
.../server/webservices/saaj/SaajUniverse.java | 18 +-
.../saaj/SoapConnectionFactoryImpl.java | 1 +
.../webservices/saaj/SoapFactoryImpl.java | 8 +
tck/cdi-embedded/dev-tests.xml | 60 +
tck/cdi-tomee/dev-tests.xml | 62 +
.../test/resources/META-INF/cdi-tck.properties | 2 +-
tck/microprofile-tck/config/pom.xml | 6 +
.../MicroProfileConfigTCKArchiveProcessor.java | 12 +-
tck/microprofile-tck/jwt/pom.xml | 14 +
.../jwt/AppDeploymentExtension.java | 77 -
.../jwt/JWTAuthContextInfoProvider.java | 63 -
.../tomee/microprofile/jwt/TCKTokenParser.java | 40 -
.../tck/jwt/JWTAuthContextInfoProvider.java | 56 +
.../jwt/MicroProfileJWTTCKArchiveProcessor.java | 123 +
.../tck/jwt/MicroProfileJWTTCKExtension.java | 29 +
.../tck/jwt/config/KeyApplication.java | 27 +
.../config/PublicKeyAsJWKLocationURLTest.java | 178 +
.../jwt/config/PublicKeyAsPEMLocationTest.java | 161 +
.../tck/jwt/jwk/PublicKeyAsJWKSTest.java | 85 +
...lipse.microprofile.jwt.tck.util.ITokenParser | 1 -
....jboss.arquillian.core.spi.LoadableExtension | 2 +-
.../jwt/src/test/resources/arquillian.xml | 41 +-
.../jwt/src/test/resources/dev.xml | 59 +-
.../jwt/src/test/resources/publicKey4k.pem | 14 +
.../jwt/src/test/resources/signer-keyset4k.jwk | 12 +
...croProfileRestClientTCKArchiveProcessor.java | 71 -
.../MicroProfileRestClientTCKExtension.java | 27 -
....jboss.arquillian.core.spi.LoadableExtension | 1 -
tomee/apache-tomee/pom.xml | 12 +
.../apache/tomee/RemoteTomEEEJBContainer.java | 6 +-
.../src/test/java/org/apache/tomee/Test.java | 24 +
.../java/org/apache/tomee/TestCommand1.java | 25 +
.../java/org/apache/tomee/TestCommand2.java | 26 +
.../test/java/org/apache/tomee/TomEECliIT.java | 283 +
.../catalina/OpenEJBNamingContextListener.java | 4 +-
.../tomee/catalina/OpenEJBNamingResource.java | 4 +-
.../tomee/catalina/TomEEWebappLoader.java | 4 +-
.../org/apache/tomee/catalina/TomcatLoader.java | 22 +-
.../tomee/catalina/TomcatSecurityService.java | 6 +-
.../tomee/catalina/TomcatWebAppBuilder.java | 10 +-
.../org/apache/tomee/common/NamingUtil.java | 12 +-
.../org/apache/tomee/installer/Installer.java | 18 +-
.../java/org/apache/tomee/embedded/Main.java | 2 +-
.../jul/formatter/SimpleTomEEFormatter.java | 6 +-
.../jul/handler/rotating/LocalFileHandler.java | 9 +-
.../jul/formatter/SimpleTomEEFormatterTest.java | 6 +-
.../org/apache/tomee/loader/LoaderServlet.java | 4 +-
.../apache/tomee/loader/OpenEJBListener.java | 9 +-
.../microprofile/config/TomEEConfigSource.java | 64 +
...eclipse.microprofile.config.spi.ConfigSource | 17 +
.../tomee-microprofile-webapp/pom.xml | 6 +
.../openejb/mockito/MockitoExtension.java | 2 +-
1079 files changed, 52199 insertions(+), 35522 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/272de000/examples/pom.xml
----------------------------------------------------------------------
[06/11] tomee git commit: TOMEE-2304 - fixed typo on pom.xml
Posted by jl...@apache.org.
TOMEE-2304 - fixed typo on pom.xml
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/7cba2023
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/7cba2023
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/7cba2023
Branch: refs/heads/master
Commit: 7cba20234dd19243b86345d2a234e8cac514416a
Parents: 272de00
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Mon Dec 10 22:01:08 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Mon Dec 10 22:01:08 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/7cba2023/examples/mp-rest-jwt/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/pom.xml b/examples/mp-rest-jwt/pom.xml
index 01f708b..275b9b3 100644
--- a/examples/mp-rest-jwt/pom.xml
+++ b/examples/mp-rest-jwt/pom.xml
@@ -157,7 +157,7 @@
<type>pom</type>
<scope>test</scope>
</dependency>
- </dependencies>q
+ </dependencies>
<profiles>
<profile>
[08/11] tomee git commit: TOMEE-2304 Added 401 and 403 test scenarios
Posted by jl...@apache.org.
TOMEE-2304 Added 401 and 403 test scenarios
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/59c288bb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/59c288bb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/59c288bb
Branch: refs/heads/master
Commit: 59c288bb3e5c7b08afe707b970a7d2cad25eed13
Parents: 2e46043
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Tue Dec 11 23:05:16 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Tue Dec 11 23:05:16 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/README.md | 267 ++++++++++++++++++-
.../org/superbiz/moviefun/rest/MoviesRest.java | 98 ++-----
.../java/org/superbiz/moviefun/MoviesTest.java | 55 ++--
3 files changed, 319 insertions(+), 101 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/59c288bb/examples/mp-rest-jwt/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/README.md b/examples/mp-rest-jwt/README.md
index b2dc71f..b4c913f 100644
--- a/examples/mp-rest-jwt/README.md
+++ b/examples/mp-rest-jwt/README.md
@@ -1,4 +1,263 @@
-index-group=Unrevised
-type=page
-status=published
-~~~~~~
+# MP REST JWT
+This is a basic example on how to use MicroProfile JWT in TomEE.
+
+## Run the tests for different scenarios related with JWT validation
+
+ mvn clean test
+
+## Configuration in TomEE
+
+The class `MoviesMPJWTConfigurationProvider.java` provide to TomEE figuration for JWT validation.
+
+ package org.superbiz.moviefun.rest;
+
+ import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
+
+ import javax.enterprise.context.Dependent;
+ import javax.enterprise.inject.Produces;
+ import java.security.KeyFactory;
+ import java.security.NoSuchAlgorithmException;
+ import java.security.interfaces.RSAPublicKey;
+ import java.security.spec.InvalidKeySpecException;
+ import java.security.spec.X509EncodedKeySpec;
+ import java.util.Base64;
+ import java.util.Optional;
+
+ @Dependent
+ public class MoviesMPJWTConfigurationProvider {
+
+ @Produces
+ Optional<JWTAuthContextInfo> getOptionalContextInfo() throws NoSuchAlgorithmException, InvalidKeySpecException {
+ JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
+
+ // todo use MP Config to load the configuration
+ contextInfo.setIssuedBy("https://server.example.com");
+
+ final String pemEncoded = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq" +
+ "Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR" +
+ "TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e" +
+ "UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9" +
+ "AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn" +
+ "sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x" +
+ "nQIDAQAB";
+ byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
+
+ final X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
+ final KeyFactory kf = KeyFactory.getInstance("RSA");
+ final RSAPublicKey pk = (RSAPublicKey) kf.generatePublic(spec);
+
+ contextInfo.setSignerKey(pk);
+
+ return Optional.of(contextInfo);
+ }
+
+ @Produces
+ JWTAuthContextInfo getContextInfo() throws InvalidKeySpecException, NoSuchAlgorithmException {
+ return getOptionalContextInfo().get();
+ }
+ }
+
+## Use MicroProfile JWT in TomEE
+
+The JAX-RS resource `MoviesRest.java` contains several endpoint that are secured using the standard
+annotation `@RolesAllowed`. MicroProfile JWT takes care of performing the validation for incoming
+requests with `Authorization` header providing a signed `Access Token`
+
+
+ package org.superbiz.moviefun.rest;
+
+ import org.superbiz.moviefun.Movie;
+ import org.superbiz.moviefun.MoviesBean;
+
+ import javax.annotation.security.RolesAllowed;
+ import javax.inject.Inject;
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.MediaType;
+ import java.util.List;
+
+ @Path("cinema")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public class MoviesRest {
+
+ @Inject
+ private MoviesBean moviesBean;
+
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String status() {
+ return "ok";
+ }
+
+ @GET
+ @Path("/movies")
+ @RolesAllowed({"crud", "read-only"})
+ public List<Movie> getListOfMovies() {
+ return moviesBean.getMovies();
+ }
+
+ @GET
+ @Path("/movies/{id}")
+ @RolesAllowed({"crud", "read-only"})
+ public Movie getMovie(@PathParam("id") int id) {
+ return moviesBean.getMovie(id);
+ }
+
+ @POST
+ @Path("/movies")
+ @RolesAllowed("crud")
+ public void addMovie(Movie newMovie) {
+ moviesBean.addMovie(newMovie);
+ }
+
+ @DELETE
+ @Path("/movies/{id}")
+ @RolesAllowed("crud")
+ public void deleteMovie(@PathParam("id") int id) {
+ moviesBean.deleteMovie(id);
+ }
+
+ @PUT
+ @Path("/movies")
+ @RolesAllowed("crud")
+ public void updateMovie(Movie updatedMovie) {
+ moviesBean.updateMovie(updatedMovie);
+ }
+
+ }
+
+ @Inject
+ @ConfigProperty(name = "java.runtime.version")
+ private String javaVersion;
+
+## About the Test architecture
+
+The test cases from this project are builded using Arquillian. The arquillian configuration can be found in
+`src/test/resources/arquillian.xml`
+
+The class `TokenUtils.java` is used during the test to act as an Authorization server who generates `Access Tokens` based
+on the configuration files `privateKey.pem`,`publicKey.pem`,`Token1.json`, and `Token2.json`.
+
+`nimbus-jose-jwt` is the library used for JWT generation during the testsĀ”.
+
+## Test Scenarios
+
+`MovieTest.java` contains 4 OAuth2 scenarios for different JWT combinations.
+
+ package org.superbiz.moviefun;
+
+ import org.apache.cxf.feature.LoggingFeature;
+ import org.apache.cxf.jaxrs.client.WebClient;
+ import org.apache.johnzon.jaxrs.JohnzonProvider;
+ import org.jboss.arquillian.container.test.api.Deployment;
+ import org.jboss.arquillian.junit.Arquillian;
+ import org.jboss.arquillian.test.api.ArquillianResource;
+ import org.jboss.shrinkwrap.api.ShrinkWrap;
+ import org.jboss.shrinkwrap.api.asset.StringAsset;
+ import org.jboss.shrinkwrap.api.spec.WebArchive;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+ import org.superbiz.moviefun.rest.ApplicationConfig;
+ import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
+ import org.superbiz.moviefun.rest.MoviesRest;
+
+ import javax.ws.rs.core.Response;
+ import java.net.URL;
+ import java.util.Collection;
+ import java.util.HashMap;
+ import java.util.logging.Logger;
+
+ import static java.util.Collections.singletonList;
+ import static org.junit.Assert.assertTrue;
+
+ @RunWith(Arquillian.class)
+ public class MoviesTest {
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
+ .addClasses(MoviesRest.class, ApplicationConfig.class)
+ .addClass(MoviesMPJWTConfigurationProvider.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
+
+ System.out.println(webArchive.toString(true));
+
+ return webArchive;
+ }
+
+ @ArquillianResource
+ private URL base;
+
+
+ private final static Logger LOGGER = Logger.getLogger(MoviesTest.class.getName());
+
+ @Test
+ public void movieRestTest() throws Exception {
+
+ final WebClient webClient = WebClient
+ .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()),
+ singletonList(new LoggingFeature()), null);
+
+
+ //Testing rest endpoint deployment (GET without security header)
+ String responsePayload = webClient.reset().path("/rest/cinema/").get(String.class);
+ LOGGER.info("responsePayload = " + responsePayload);
+ assertTrue(responsePayload.equalsIgnoreCase("ok"));
+
+
+ //POST (Using token1.json with group of claims: [CRUD])
+ Movie newMovie = new Movie(1, "David Dobkin", "Wedding Crashers");
+ Response response = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(1))
+ .post(newMovie);
+ LOGGER.info("responseCode = " + response.getStatus());
+ assertTrue(response.getStatus() == 204);
+
+
+ //GET movies (Using token1.json with group of claims: [read-only])
+ //This test should be updated to use token2.json once TOMEE- gets resolved.
+ Collection<? extends Movie> movies = webClient
+ .reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(1))
+ .getCollection(Movie.class);
+ LOGGER.info(movies.toString());
+ assertTrue(movies.size() == 1);
+
+
+ //Should return a 403 since POST require group of claims: [crud] but Token 2 has only [read-only].
+ Movie secondNewMovie = new Movie(2, "Todd Phillips", "Starsky & Hutch");
+ Response responseWithError = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(2))
+ .post(secondNewMovie);
+ LOGGER.info("responseCode = " + responseWithError.getStatus());
+ assertTrue(responseWithError.getStatus() == 403);
+
+
+ //Should return a 401 since the header Authorization is not part of the POST request.
+ Response responseWith401Error = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .post(new Movie());
+ LOGGER.info("responseCode = " + responseWith401Error.getStatus());
+ assertTrue(responseWith401Error.getStatus() == 401);
+
+ }
+
+
+ private String token(int token_type) throws Exception {
+ HashMap<String, Long> timeClaims = new HashMap<>();
+ if (token_type == 1) {
+ return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
+ } else {
+ return TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
+ }
+ }
+
+ }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/59c288bb/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
index 1ded167..9e67334 100644
--- a/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
+++ b/examples/mp-rest-jwt/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -39,105 +39,39 @@ public class MoviesRest {
return "ok";
}
+ @GET
+ @Path("/movies")
+ @RolesAllowed({"crud", "read-only"})
+ public List<Movie> getListOfMovies() {
+ return moviesBean.getMovies();
+ }
+
+ @GET
+ @Path("/movies/{id}")
+ @RolesAllowed({"crud", "read-only"})
+ public Movie getMovie(@PathParam("id") int id) {
+ return moviesBean.getMovie(id);
+ }
+
@POST
@Path("/movies")
@RolesAllowed("crud")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
public void addMovie(Movie newMovie) {
moviesBean.addMovie(newMovie);
}
@DELETE
@Path("/movies/{id}")
- @RolesAllowed("read-only")
+ @RolesAllowed("crud")
public void deleteMovie(@PathParam("id") int id) {
moviesBean.deleteMovie(id);
}
@PUT
@Path("/movies")
+ @RolesAllowed("crud")
public void updateMovie(Movie updatedMovie) {
moviesBean.updateMovie(updatedMovie);
}
- @GET
- @Path("/movies/{id}")
- @RolesAllowed({"read-only","crud"})
- public Movie getMovie(@PathParam("id") int id) {
- return moviesBean.getMovie(id);
- }
-
- @GET
- @Path("/movies")
- @RolesAllowed({"crud", "read-only"})
- public List<Movie> getListOfMovies() {
- return moviesBean.getMovies();
- }
-
-
-// @Inject
-// @Claim("raw_token")
-// private ClaimValue<String> rawToken;
-//
-// @Inject
-// @Claim("iss")
-// private ClaimValue<String> issuer;
-//
-// @Inject
-// @Claim("jti")
-// private ClaimValue<String> jti;
-//
-// @Inject
-// private JsonWebToken jwtPrincipal;
-//
-// @Context
-// private SecurityContext securityContext;
-//
-// @GET
-// @Path("{id}")
-// public Movie find(@PathParam("id") Long id) {
-// return service.find(id);
-// }
-//
-// @GET
-// public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
-// @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
-// return service.getMovies(first, max, field, searchTerm);
-// }
-//
-// @POST
-// @Consumes("application/json")
-// @RolesAllowed("create")
-// public Movie addMovie(Movie movie) {
-// service.addMovie(movie);
-// return movie;
-// }
-//
-// @PUT
-// @Path("{id}")
-// @Consumes("application/json")
-// @RolesAllowed("update")
-// public Movie editMovie(
-// @PathParam("id") final long id,
-// Movie movie
-// ) {
-// service.editMovie(movie);
-// return movie;
-// }
-//
-// @DELETE
-// @Path("{id}")
-// @RolesAllowed("delete")
-// public void deleteMovie(@PathParam("id") long id) {
-// service.deleteMovie(id);
-// }
-//
-// @GET
-// @Path("count")
-// @Produces(MediaType.TEXT_PLAIN)
-// public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
-// return service.count(field, searchTerm);
-// }
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/59c288bb/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
index ea622b8..7ba6808 100644
--- a/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
+++ b/examples/mp-rest-jwt/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -46,10 +46,10 @@ public class MoviesTest {
@Deployment(testable = false)
public static WebArchive createDeployment() {
final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
- .addClasses(MoviesRest.class, ApplicationConfig.class)
- .addClass(MoviesMPJWTConfigurationProvider.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
+ .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
+ .addClasses(MoviesRest.class, ApplicationConfig.class)
+ .addClass(MoviesMPJWTConfigurationProvider.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
System.out.println(webArchive.toString(true));
@@ -66,8 +66,8 @@ public class MoviesTest {
public void movieRestTest() throws Exception {
final WebClient webClient = WebClient
- .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()), singletonList(new LoggingFeature()), null);
-
+ .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()),
+ singletonList(new LoggingFeature()), null);
//Testing rest endpoint deployment (GET without security header)
@@ -75,32 +75,57 @@ public class MoviesTest {
LOGGER.info("responsePayload = " + responsePayload);
assertTrue(responsePayload.equalsIgnoreCase("ok"));
+
//POST (Using token1.json with group of claims: [CRUD])
- Movie newMovie = new Movie(1,"David Dobkin","Wedding Crashers");
- Response response = webClient.reset().path("/rest/cinema/movies").header("Content-Type","application/json").header("Authorization", "Bearer " + token(1)).post(newMovie);
+ Movie newMovie = new Movie(1, "David Dobkin", "Wedding Crashers");
+ Response response = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(1))
+ .post(newMovie);
LOGGER.info("responseCode = " + response.getStatus());
assertTrue(response.getStatus() == 204);
-
- //GET movies (Using token2.json with group of claims: [read-only])
- final Collection<? extends Movie> movies = webClient
+ //GET movies (Using token1.json with group of claims: [read-only])
+ //This test should be updated to use token2.json once TOMEE- gets resolved.
+ Collection<? extends Movie> movies = webClient
.reset()
.path("/rest/cinema/movies")
- .header("Content-Type","application/json")
+ .header("Content-Type", "application/json")
.header("Authorization", "Bearer " + token(1))
.getCollection(Movie.class);
LOGGER.info(movies.toString());
assertTrue(movies.size() == 1);
- }
+ //Should return a 403 since POST require group of claims: [crud] but Token 2 has only [read-only].
+ Movie secondNewMovie = new Movie(2, "Todd Phillips", "Starsky & Hutch");
+ Response responseWithError = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(2))
+ .post(secondNewMovie);
+ LOGGER.info("responseCode = " + responseWithError.getStatus());
+ assertTrue(responseWithError.getStatus() == 403);
+
+
+ //Should return a 401 since the header Authorization is not part of the POST request.
+ Response responseWith401Error = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .post(new Movie());
+ LOGGER.info("responseCode = " + responseWith401Error.getStatus());
+ assertTrue(responseWith401Error.getStatus() == 401);
+
+ }
+
private String token(int token_type) throws Exception {
HashMap<String, Long> timeClaims = new HashMap<>();
- if(token_type==1){
+ if (token_type == 1) {
return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
- }else{
+ } else {
return TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
}
}