openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1777903 - in /openwebbeans/meecrowave/trunk: meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/ meecrowave-doc/ meecrowave-doc/src/main/java/org/apache/meecrowave/doc/ meecrowave-doc/src/main/java/org/apache/meecrowave/doc/g...
Date Sun, 08 Jan 2017 19:45:38 GMT
Author: rmannibucau
Date: Sun Jan  8 19:45:37 2017
New Revision: 1777903

URL: http://svn.apache.org/viewvc?rev=1777903&view=rev
Log:
MEECROWAVE-2 adding oauth2 module

Added:
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/OAuth2Configuration.java
      - copied, changed from r1777328, openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/Configuration.java
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/index.adoc
      - copied, changed from r1777328, openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-jta/index.adoc
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/pom.xml
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/JPAAdapter.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Configurer.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Options.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/RefreshTokenEnabledProvider.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/JCacheCodeDataProvider.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2Application.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2TokenService.java
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/org.apache.meecrowave.runner.Cli$Options
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/default-oauth2.jcs
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/
    openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/OAuth2Test.java
Modified:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java
    openwebbeans/meecrowave/trunk/meecrowave-doc/pom.xml
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/JBake.java
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/jbake.properties
    openwebbeans/meecrowave/trunk/meecrowave-jpa/pom.xml

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java?rev=1777903&r1=1777902&r2=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java Sun Jan  8 19:45:37 2017
@@ -88,7 +88,7 @@ public class KnowClassesFilter implement
         excluded.add("org.apache.commons.io");
         excluded.add("org.apache.commons.jcs.access");
         excluded.add("org.apache.commons.jcs.admin");
-        excluded.add("org.apache.commons.jcs.auxilary");
+        excluded.add("org.apache.commons.jcs.auxiliary");
         excluded.add("org.apache.commons.jcs.engine");
         excluded.add("org.apache.commons.jcs.io");
         excluded.add("org.apache.commons.jcs.utils");
@@ -101,6 +101,7 @@ public class KnowClassesFilter implement
         excluded.add("org.apache.geronimo.javamail");
         excluded.add("org.apache.geronimo.mail");
         excluded.add("org.apache.geronimo.osgi");
+        excluded.add("org.apache.geronimo.specs");
         excluded.add("org.apache.http");
         excluded.add("org.apache.jcp");
         excluded.add("org.apache.johnzon");
@@ -113,6 +114,7 @@ public class KnowClassesFilter implement
         excluded.add("org.apache.naming");
         excluded.add("org.apache.neethi");
         excluded.add("org.apache.openejb");
+        excluded.add("org.apache.openjpa");
         excluded.add("org.apache.oro");
         excluded.add("org.apache.tomcat");
         excluded.add("org.apache.tomee");
@@ -131,6 +133,7 @@ public class KnowClassesFilter implement
         excluded.add("org.eclipse.jdt.core");
         excluded.add("org.eclipse.jdt.internal");
         excluded.add("org.fusesource.hawtbuf");
+        excluded.add("org.h2");
         excluded.add("org.hamcrest");
         excluded.add("org.hsqldb");
         excluded.add("org.jasypt");
@@ -158,6 +161,7 @@ public class KnowClassesFilter implement
         included.add("org.apache.myfaces.cdi");
         // included.add("org.apache.myfaces.application.cdi");
         included.add("org.apache.myfaces.flow.cdi");
+        included.add("org.apache.meecrowave.oauth2");
 
         delegateSkip = new OptimizedExclusionFilter(excluded);
         delegateAccept = new OptimizedExclusionFilter(included);

Modified: openwebbeans/meecrowave/trunk/meecrowave-doc/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/pom.xml?rev=1777903&r1=1777902&r2=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/pom.xml Sun Jan  8 19:45:37 2017
@@ -90,6 +90,11 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.meecrowave</groupId>
+      <artifactId>meecrowave-oauth2</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.jbake</groupId>
       <artifactId>jbake-core</artifactId>
       <version>2.4.0</version>

Modified: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/JBake.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/JBake.java?rev=1777903&r1=1777902&r2=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/JBake.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/JBake.java Sun Jan  8 19:45:37 2017
@@ -26,6 +26,7 @@ import org.apache.meecrowave.doc.generat
 import org.apache.meecrowave.doc.generator.CliConfiguration;
 import org.apache.meecrowave.doc.generator.Configuration;
 import org.apache.meecrowave.doc.generator.MavenConfiguration;
+import org.apache.meecrowave.doc.generator.OAuth2Configuration;
 import org.jbake.app.ConfigUtil;
 import org.jbake.app.Oven;
 
@@ -68,6 +69,7 @@ public class JBake {
         new CliConfiguration().run();
         new ArquillianConfiguration().run();
         new MavenConfiguration().run();
+        new OAuth2Configuration().run();
 
         final Runnable build = () -> {
             System.out.println("Building Meecrowave website in " + destination);

Copied: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/OAuth2Configuration.java (from r1777328, openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/Configuration.java)
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/OAuth2Configuration.java?p2=openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/OAuth2Configuration.java&p1=openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/Configuration.java&r1=1777328&r2=1777903&rev=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/Configuration.java (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/java/org/apache/meecrowave/doc/generator/OAuth2Configuration.java Sun Jan  8 19:45:37 2017
@@ -18,23 +18,23 @@
  */
 package org.apache.meecrowave.doc.generator;
 
-import org.apache.meecrowave.Meecrowave;
+import org.apache.meecrowave.oauth2.configuration.OAuth2Options;
 import org.apache.meecrowave.runner.cli.CliOption;
 
-import java.lang.reflect.Field;
 import java.util.Comparator;
 import java.util.stream.Stream;
 
 import static java.util.stream.Collectors.joining;
 
-public class Configuration extends BaseGenerator {
+public class OAuth2Configuration extends BaseGenerator {
     @Override
     protected String generate() {
         return super.tableConfig() + "|===\n|Name|Description\n" +
-                Stream.of(Meecrowave.Builder.class.getDeclaredFields())
+                Stream.of(OAuth2Options.class.getDeclaredFields())
                         .filter(f -> f.isAnnotationPresent(CliOption.class))
-                        .sorted(Comparator.comparing(Field::getName))
-                        .map(f -> "|" + f.getName() + "|" + f.getAnnotation(CliOption.class).description())
+                        .map(f -> f.getAnnotation(CliOption.class))
+                        .sorted(Comparator.comparing(CliOption::name))
+                        .map(f -> "|--" + f.name() + "|" + f.description())
                         .collect(joining("\n")) + "\n|===\n";
     }
 }

Copied: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/index.adoc (from r1777328, openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-jta/index.adoc)
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/index.adoc?p2=openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/index.adoc&p1=openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-jta/index.adoc&r1=1777328&r2=1777903&rev=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-jta/index.adoc (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-oauth2/index.adoc Sun Jan  8 19:45:37 2017
@@ -1,5 +1,5 @@
-= Meecrowave JTA
-:jbake-date: 2016-12-22
+= Meecrowave OAuth2
+:jbake-date: 2017-01-08
 :jbake-type: page
 :jbake-status: published
 :jbake-meecrowavepdf:
@@ -13,9 +13,53 @@ Coordinates:
 ----
 <dependency>
   <groupId>org.apache.meecrowave</groupId>
-  <artifactId>meecrowave-jta</artifactId>
+  <artifactId>meecrowave-oauth2</artifactId>
   <version>${meecrowave.version}</version>
 </dependency>
 ----
 
-This allows to use `@Transactional` and `@TransactionScoped` features of JTA 1.2.
+A small OAuth2 server based on CXF implementation.
+
+See http://cxf.apache.org/docs/jax-rs-oauth2.html for more details.
+
+Here is the current configuration (mainly based on CXF one):
+
+include::../../../../../target/generated-doc/OAuth2.adoc[]
+
+These options are available through the CLI or through properties as usually with Meecrowave configuration.
+
+Note that meecrowave also provides a bundle which is an executable jar to run an OAuth2 server.
+
+Here is a sample usage of that bundle:
+
+[source,bash]
+----
+java -jar meecrowave-oauth2-0.3.0-SNAPSHOT-bundle.jar --users test=test --roles test=test
+----
+
+Then just test your token endpoint:
+
+[source,bash]
+----
+curl -XPOST http://localhost:8080/oauth2/token -d username=test -d password=test -d grant_type=password
+----
+
+And you should get something like:
+
+[source,javascript]
+----
+{
+  "access_token":"5e2f211d4b4ccaa36a11d0876597f01e",
+  "token_type":"Bearer",
+  "expires_in":3600,
+  "scope":"refreshToken",
+  "refresh_token":"7ae5dc2e25925e5514b7e2e632cfa6a"
+}
+----
+
+IMPORTANT: these example use inline users but you should configure a realm for a real usage.
+
+
+NOTE: this module is interesting if you plan to base your application development
+on Meecrowave because it shows how to use CLI configuration and wire it in your application
+but also how to use a 3rd party library (CXF there) and build a fatjar.

Modified: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/jbake.properties
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/jbake.properties?rev=1777903&r1=1777902&r2=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/jbake.properties (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/jbake.properties Sun Jan  8 19:45:37 2017
@@ -1,3 +1,19 @@
+#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.
 content.rootpath = /meecrowave
 content_rootpath = /meecrowave
 

Modified: openwebbeans/meecrowave/trunk/meecrowave-jpa/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-jpa/pom.xml?rev=1777903&r1=1777902&r2=1777903&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-jpa/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-jpa/pom.xml Sun Jan  8 19:45:37 2017
@@ -32,7 +32,7 @@
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-jpa_2.1_spec</artifactId>
-      <version>1.0-alpha-1</version>
+      <version>${jpa-spec.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.meecrowave</groupId>
@@ -43,7 +43,7 @@
     <dependency>
       <groupId>org.apache.openjpa</groupId>
       <artifactId>openjpa</artifactId>
-      <version>2.4.1</version>
+      <version>${openjpa.version}</version>
     </dependency>
 
     <dependency>
@@ -55,13 +55,13 @@
     <dependency>
       <groupId>com.h2database</groupId>
       <artifactId>h2</artifactId>
-      <version>1.4.192</version>
+      <version>${h2.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-dbcp2</artifactId>
-      <version>2.1</version>
+      <version>${dbcp2.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/pom.xml?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/pom.xml (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/pom.xml Sun Jan  8 19:45:37 2017
@@ -0,0 +1,167 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>meecrowave</artifactId>
+    <groupId>org.apache.meecrowave</groupId>
+    <version>0.3.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>meecrowave-oauth2</artifactId>
+  <name>Meecrowave :: OAuth2</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.meecrowave</groupId>
+      <artifactId>meecrowave-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-rs-security-oauth2</artifactId>
+      <version>${cxf.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jcache_1.0_spec</artifactId>
+      <version>1.0-alpha-1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jpa_2.0_spec</artifactId>
+      <version>1.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>${commons-cli.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+      <version>${dbcp2.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openjpa</groupId>
+      <artifactId>openjpa</artifactId>
+      <version>${openjpa.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.h2database</groupId>
+      <artifactId>h2</artifactId>
+      <version>${h2.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-jcs-jcache</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-jcl</artifactId>
+      <version>${log4j2.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.meecrowave</groupId>
+      <artifactId>meecrowave-junit</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.4.3</version>
+        <executions>
+          <execution>
+            <id>bundle</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedClassifierName>bundle</shadedClassifierName>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
+              <dependencyReducedPomLocation>${project.build.directory}/reduced-pom-bundle.xml</dependencyReducedPomLocation>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>org.apache.meecrowave.runner.Cli</mainClass>
+                </transformer>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  <resource>META-INF/cxf/bus-extensions.txt</resource>
+                </transformer>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  <resource>log4j2.component.properties</resource>
+                </transformer>
+                <transformer implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer" />
+                <transformer implementation="org.apache.openwebbeans.maven.shade.OpenWebBeansPropertiesTransformer" />
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+              </transformers>
+              <filters>
+                <filter>
+                  <artifact>*:*</artifact>
+                  <excludes>
+                    <exclude>META-INF/*.SF</exclude>
+                    <exclude>META-INF/*.DSA</exclude>
+                    <exclude>META-INF/*.RSA</exclude>
+                    <exclude>META-INF/LICENSE.txt</exclude>
+                    <exclude>META-INF/LICENSE</exclude>
+                    <exclude>META-INF/NOTICE.txt</exclude>
+                    <exclude>META-INF/NOTICE</exclude>
+                  </excludes>
+                </filter>
+              </filters>
+            </configuration>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-maven</artifactId>
+            <version>${openwebbeans.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>com.github.edwgiz</groupId>
+            <artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
+            <version>2.1</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/JPAAdapter.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/JPAAdapter.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/JPAAdapter.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/JPAAdapter.java Sun Jan  8 19:45:37 2017
@@ -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
+ *
+ * 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.apache.meecrowave.oauth2.configuration;
+
+import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
+import org.apache.cxf.rs.security.oauth2.common.UserSubject;
+import org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant;
+import org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken;
+import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Properties;
+
+import static java.util.Optional.ofNullable;
+
+public class JPAAdapter {
+    // no persistence.xml
+    public static EntityManagerFactory createEntityManagerFactory(final OAuth2Options configuration) {
+        return Persistence.createEntityManagerFactory("oauth2", new HashMap() {{
+            put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+            put("openjpa.MetaDataFactory", "jpa(Types=" +
+                    Client.class.getName() + ',' +
+                    OAuthPermission.class.getName() + ',' +
+                    UserSubject.class.getName() + ',' +
+                    ServerAuthorizationCodeGrant.class.getName() + ',' +
+                    BearerAccessToken.class.getName() + ',' +
+                    RefreshToken.class.getName() + ")");
+
+            // plain connection but not used cause of pooling
+            /*
+            put("openjpa.ConnectionDriverName", configuration.getJpaDriver());
+            put("openjpa.ConnectionURL", configuration.getJpaDriver());
+            put("openjpa.ConnectionUsername", configuration.getJpdaDatabaseUsername());
+            put("openjpa.ConnectionPassword", configuration.getJpdaDatabasePassword());
+            */
+            /* cool...but what about pooling?
+            put("javax.persistence.jdbc.driver", configuration.getJpaDriver());
+            put("javax.persistence.jdbc.url", configuration.getJpaDatabaseUrl());
+            put("javax.persistence.jdbc.user", configuration.getJpdaDatabaseUsername());
+            put("javax.persistence.jdbc.password", configuration.getJpdaDatabasePassword());
+            */
+            // pooling support
+            put("openjpa.ConnectionDriverName", BasicDataSource.class.getName());
+            put("openjpa.ConnectionProperties",
+                    "DriverClassName=" + configuration.getJpaDriver() + ',' +
+                            "Url=" + configuration.getJpaDatabaseUrl() + ',' +
+                            "Username=" + configuration.getJpdaDatabaseUsername() + ',' +
+                            "Password=" + configuration.getJpdaDatabasePassword() + ',' +
+                            "MaxActive=" + configuration.getJpaMaxActive() + ',' +
+                            "MaxWaitMillis=" + configuration.getJpaMaxWait() + ',' +
+                            "MaxIdle=" + configuration.getJpaMaxIdle() + ',' +
+                            "TestOnBorrow=" + configuration.isJpaTestOnBorrow() + ',' +
+                            "TestOnReturn=" + configuration.isJpaTestOnReturn() + ',' +
+                            "TestWhileIdle=" + (configuration.getJpaValidationQuery() != null && !configuration.getJpaValidationQuery().isEmpty()) + ',' +
+                            ofNullable(configuration.getJpaValidationQuery()).map(v -> "ValidationQuery=" + v + ',').orElse("") +
+                            ofNullable(configuration.getJpaValidationInterval()).map(v -> "MinEvictableIdleTimeMillis=" + v).orElse(""));
+
+            ofNullable(configuration.getJpaProperties())
+                    .map(p -> new Properties() {{
+                        try {
+                            load(new StringReader(p));
+                        } catch (final IOException e) {
+                            throw new IllegalArgumentException(e);
+                        }
+                    }})
+                    .ifPresent(this::putAll);
+        }});
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Configurer.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Configurer.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Configurer.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Configurer.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,220 @@
+/*
+ * 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.apache.meecrowave.oauth2.configuration;
+
+import org.apache.catalina.realm.GenericPrincipal;
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.security.AuthenticationException;
+import org.apache.cxf.rs.security.oauth2.common.UserSubject;
+import org.apache.cxf.rs.security.oauth2.grants.AbstractGrantHandler;
+import org.apache.cxf.rs.security.oauth2.grants.clientcred.ClientCredentialsGrantHandler;
+import org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeGrantHandler;
+import org.apache.cxf.rs.security.oauth2.grants.code.DefaultEncryptingCodeDataProvider;
+import org.apache.cxf.rs.security.oauth2.grants.code.JPACodeDataProvider;
+import org.apache.cxf.rs.security.oauth2.grants.jwt.JwtBearerGrantHandler;
+import org.apache.cxf.rs.security.oauth2.grants.owner.JAASResourceOwnerLoginHandler;
+import org.apache.cxf.rs.security.oauth2.grants.owner.ResourceOwnerGrantHandler;
+import org.apache.cxf.rs.security.oauth2.grants.owner.ResourceOwnerLoginHandler;
+import org.apache.cxf.rs.security.oauth2.grants.refresh.RefreshTokenGrantHandler;
+import org.apache.cxf.rs.security.oauth2.provider.AbstractOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.AccessTokenGrantHandler;
+import org.apache.cxf.rs.security.oauth2.provider.DefaultEHCacheOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.DefaultEncryptingOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.JCacheOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.JPAOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+import org.apache.meecrowave.Meecrowave;
+import org.apache.meecrowave.oauth2.data.RefreshTokenEnabledProvider;
+import org.apache.meecrowave.oauth2.provider.JCacheCodeDataProvider;
+import org.apache.meecrowave.oauth2.resource.OAuth2TokenService;
+
+import javax.annotation.PostConstruct;
+import javax.crypto.spec.SecretKeySpec;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.function.Consumer;
+
+import static java.util.Arrays.asList;
+import static java.util.Locale.ENGLISH;
+import static java.util.Optional.ofNullable;
+import static org.apache.cxf.rs.security.oauth2.common.AuthenticationMethod.PASSWORD;
+
+@ApplicationScoped
+public class OAuth2Configurer implements Consumer<OAuth2TokenService> {
+    @Inject
+    private Meecrowave.Builder builder;
+
+    @Inject
+    private Bus bus;
+
+    @Inject
+    private HttpServletRequest request;
+
+    private Consumer<OAuth2TokenService> configurer;
+    private OAuth2Options configuration;
+
+    @PostConstruct // TODO: still some missing configuration for jwt etc to add/wire from OAuth2Options
+    private void preCompute() {
+        configuration = builder.getExtension(OAuth2Options.class);
+
+        AbstractOAuthDataProvider provider;
+        switch (configuration.getProvider().toLowerCase(ENGLISH)) {
+            case "jpa": {
+                final JPAOAuthDataProvider jpaProvider = new JPAOAuthDataProvider();
+                jpaProvider.setEntityManagerFactory(JPAAdapter.createEntityManagerFactory(configuration));
+                provider = jpaProvider;
+                break;
+            }
+            case "jpa-code": {
+                final JPACodeDataProvider jpaProvider = new JPACodeDataProvider();
+                jpaProvider.setEntityManagerFactory(JPAAdapter.createEntityManagerFactory(configuration));
+                provider = jpaProvider;
+                break;
+            }
+            case "jcache":
+                try {
+                    provider = new JCacheOAuthDataProvider(configuration.getJcacheConfigUri(), bus, configuration.isJcacheStoreJwtKeyOnly());
+                } catch (final Exception e) {
+                    throw new IllegalStateException(e);
+                }
+                break;
+            case "jcache-code":
+                try {
+                    provider = new JCacheCodeDataProvider(configuration.getJcacheConfigUri(), bus);
+                } catch (final Exception e) {
+                    throw new IllegalStateException(e);
+                }
+                break;
+            case "ehcache": // not sure it makes sense since we have jcache but this one is cheap to support
+                provider = new DefaultEHCacheOAuthDataProvider(configuration.getJcacheConfigUri(), bus);
+                break;
+            case "encrypted":
+                provider = new DefaultEncryptingOAuthDataProvider(
+                        new SecretKeySpec(configuration.getEncryptedKey().getBytes(StandardCharsets.UTF_8), configuration.getEncryptedAlgo()));
+                break;
+            case "encrypted-code":
+                provider = new DefaultEncryptingCodeDataProvider(
+                        new SecretKeySpec(configuration.getEncryptedKey().getBytes(StandardCharsets.UTF_8), configuration.getEncryptedAlgo()));
+                break;
+            default:
+                throw new IllegalArgumentException("Unsupported oauth2 provider: " + configuration.getProvider());
+        }
+
+        final RefreshTokenGrantHandler refreshTokenGrantHandler = new RefreshTokenGrantHandler();
+        refreshTokenGrantHandler.setDataProvider(provider);
+        refreshTokenGrantHandler.setUseAllClientScopes(configuration.isUseAllClientScopes());
+        refreshTokenGrantHandler.setPartialMatchScopeValidation(configuration.isPartialMatchScopeValidation());
+
+        final List<AccessTokenGrantHandler> handlers = new ArrayList<>();
+        handlers.add(refreshTokenGrantHandler);
+        handlers.add(new ClientCredentialsGrantHandler());
+        handlers.add(new ResourceOwnerGrantHandler() {{
+            setLoginHandler(configuration.isJaas() ? new JAASResourceOwnerLoginHandler() : new ResourceOwnerLoginHandler() {
+                @Override
+                public UserSubject createSubject(final String name, final String password) {
+                    try {
+                        request.login(name, password);
+                        try {
+                            final Principal pcp = request.getUserPrincipal();
+                            final UserSubject userSubject = new UserSubject(
+                                    name,
+                                    GenericPrincipal.class.isInstance(pcp) ?
+                                            new ArrayList<>(asList(GenericPrincipal.class.cast(pcp).getRoles())) : Collections.emptyList());
+                            userSubject.setAuthenticationMethod(PASSWORD);
+                            return userSubject;
+                        } finally {
+                            request.logout();
+                        }
+                    } catch (final ServletException e) {
+                        throw new AuthenticationException(e.getMessage());
+                    }
+                }
+            });
+        }});
+        handlers.add(new AuthorizationCodeGrantHandler());
+        handlers.add(new JwtBearerGrantHandler());
+
+        provider.setUseJwtFormatForAccessTokens(configuration.isUseJwtFormatForAccessTokens());
+        provider.setAccessTokenLifetime(configuration.getAccessTokenLifetime());
+        provider.setRefreshTokenLifetime(configuration.getRefreshTokenLifetime());
+        provider.setRecycleRefreshTokens(configuration.isRecycleRefreshTokens());
+        provider.setSupportPreauthorizedTokens(configuration.isSupportPreauthorizedTokens());
+        ofNullable(configuration.getRequiredScopes()).map(s -> asList(s.split(","))).ifPresent(provider::setRequiredScopes);
+        ofNullable(configuration.getDefaultScopes()).map(s -> asList(s.split(","))).ifPresent(provider::setDefaultScopes);
+        ofNullable(configuration.getInvisibleToClientScopes()).map(s -> asList(s.split(","))).ifPresent(provider::setInvisibleToClientScopes);
+        ofNullable(configuration.getJwtAccessTokenClaimMap()).map(s -> new Properties() {{
+            try {
+                load(new StringReader(s));
+            } catch (IOException e) {
+                throw new IllegalArgumentException("Bad claim map configuration, use properties syntax");
+            }
+        }}).ifPresent(m -> provider.setJwtAccessTokenClaimMap(new HashMap<>(Map.class.cast(m))));
+
+        final OAuthDataProvider dataProvider;
+        if (configuration.isRefreshToken()) {
+            dataProvider = new RefreshTokenEnabledProvider(provider);
+            if (provider.getInvisibleToClientScopes() == null) {
+                provider.setInvisibleToClientScopes(new ArrayList<>());
+            }
+            provider.getInvisibleToClientScopes().add(OAuthConstants.REFRESH_TOKEN_SCOPE);
+        } else {
+            dataProvider = provider;
+        }
+
+        handlers.stream()
+                .filter(AbstractGrantHandler.class::isInstance)
+                .forEach(h -> {
+                    final AbstractGrantHandler handler = AbstractGrantHandler.class.cast(h);
+                    handler.setDataProvider(dataProvider);
+                    handler.setCanSupportPublicClients(configuration.isCanSupportPublicClients());
+                    handler.setPartialMatchScopeValidation(configuration.isPartialMatchScopeValidation());
+                });
+
+        configurer = s -> { // this is used @RequestScoped so ensure it is not slow for no reason
+            s.setCanSupportPublicClients(configuration.isCanSupportPublicClients());
+            s.setBlockUnsecureRequests(configuration.isBlockUnsecureRequests());
+            s.setWriteCustomErrors(configuration.isWriteCustomErrors());
+            s.setWriteOptionalParameters(configuration.isWriteOptionalParameters());
+            s.setDataProvider(dataProvider);
+            s.setGrantHandlers(handlers);
+        };
+    }
+
+    @Override
+    public void accept(final OAuth2TokenService service) {
+        configurer.accept(service);
+    }
+
+    public OAuth2Options getConfiguration() {
+        return configuration;
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Options.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Options.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Options.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/configuration/OAuth2Options.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,409 @@
+/*
+ * 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.apache.meecrowave.oauth2.configuration;
+
+import org.apache.meecrowave.runner.Cli;
+import org.apache.meecrowave.runner.cli.CliOption;
+
+public class OAuth2Options implements Cli.Options {
+    @CliOption(name = "oauth2-refresh-token", description = "Is issuing of access token issuing a refreh token too")
+    private boolean refreshToken = true;
+
+    @CliOption(name = "oauth2-client-force", description = "Is a client mandatory or can a token be issued without any client")
+    private boolean forceClient;
+
+    @CliOption(name = "oauth2-support-public-client", description = "Are public clients supported")
+    private boolean canSupportPublicClients;
+
+    @CliOption(name = "oauth2-use-all-client-scopes", description = "Are all client scopes used for refresh tokens")
+    private boolean useAllClientScopes;
+
+    @CliOption(name = "oauth2-write-custom-errors", description = "Should custom errors be written")
+    private boolean writeCustomErrors;
+
+    @CliOption(name = "oauth2-block-unsecure-requests", description = "Should unsecured requests be blocked")
+    private boolean blockUnsecureRequests;
+
+    @CliOption(name = "oauth2-write-optional-parameters", description = "Should optional parameters be written")
+    private boolean writeOptionalParameters = true;
+
+    @CliOption(name = "oauth2-partial-match-scope-validation", description = "Is partial match for scope validation activated")
+    private boolean partialMatchScopeValidation;
+
+    @CliOption(name = "oauth2-use-jaas", description = "Should jaas be used - alternative (default) is to delegate to meecrowave/tomcat realms")
+    private boolean jaas;
+
+    @CliOption(name = "oauth2-access-token-lifetime", description = "How long an access token is valid, default to 3600s")
+    private int accessTokenLifetime = 3600;
+
+    @CliOption(name = "oauth2-refresh-token-lifetime", description = "How long a refresh token is valid, default to eternity (0)")
+    private long refreshTokenLifetime;
+
+    @CliOption(name = "oauth2-refresh-token-recycling", description = "Should refresh token be recycled")
+    private boolean recycleRefreshTokens = true;
+
+    @CliOption(name = "oauth2-default-scopes", description = "Comma separated list of default scopes")
+    private String defaultScopes;
+
+    @CliOption(name = "oauth2-required-scopes", description = "Comma separated list of required scopes")
+    private String requiredScopes;
+
+    @CliOption(name = "oauth2-invisible-scopes", description = "Comma separated list of invisible to client scopes")
+    private String invisibleToClientScopes;
+
+    @CliOption(name = "oauth2-support-pre-authorized-tokens", description = "Are pre-authorized token supported")
+    private boolean supportPreauthorizedTokens;
+
+    @CliOption(name = "oauth2-use-jwt-format-for-access-token", description = "Should access token be jwt?")
+    private boolean useJwtFormatForAccessTokens;
+
+    @CliOption(name = "oauth2-jwt-access-token-claim-map", description = "The jwt claims configuration")
+    private String jwtAccessTokenClaimMap;
+
+    @CliOption(name = "oauth2-provider", description = "Which provider type to use: jcache[-code], jpa[-code], encrypted[-code]")
+    private String provider = "jcache";
+
+    @CliOption(name = "oauth2-jcache-config", description = "JCache configuration uri for the cache manager (jcache or provider)")
+    private String jcacheConfigUri = "default-oauth2.jcs";
+
+    @CliOption(name = "oauth2-jcache-store-jwt-token-key-only", description = "Should JCache store jwt token key only (jcache provider)")
+    private boolean jcacheStoreJwtKeyOnly;
+
+    @CliOption(name = "oauth2-jpa-database-url", description = "JPA database url for jpa provider")
+    private String jpaDatabaseUrl = "jdbc:h2:mem:oauth2";
+
+    @CliOption(name = "oauth2-jpa-database-username", description = "JPA database username for jpa provider")
+    private String jpdaDatabaseUsername = "sa";
+
+    @CliOption(name = "oauth2-jpa-database-password", description = "JPA database password for jpa provider")
+    private String jpdaDatabasePassword = "";
+
+    @CliOption(name = "oauth2-jpa-database-driver", description = "JPA database driver for jpa provider")
+    private String jpaDriver = "org.h2.Driver";
+
+    @CliOption(name = "oauth2-jpa-properties", description = "JPA persistence unit properties for jpa provider")
+    private String jpaProperties;
+
+    @CliOption(name = "oauth2-jpa-max-active", description = "JPA max active connections for jpa provider")
+    private int jpaMaxActive = 30;
+
+    @CliOption(name = "oauth2-jpa-max-idle", description = "JPA max idle connections for jpa provider")
+    private int jpaMaxIdle = 10;
+
+    @CliOption(name = "oauth2-jpa-max-wait", description = "JPA max wait for connections for jpa provider")
+    private int jpaMaxWait = 30000;
+
+    @CliOption(name = "oauth2-jpa-validation-query", description = "validation query for jpa provider")
+    private String jpaValidationQuery;
+
+    @CliOption(name = "oauth2-jpa-validation-interval", description = "validation interval for jpa provider")
+    private int jpaValidationInterval = 5 * 1000 * 60;
+
+    @CliOption(name = "oauth2-jpa-test-on-borrow", description = "should connections be tested on borrow for jpa provider")
+    private boolean jpaTestOnBorrow;
+
+    @CliOption(name = "oauth2-jpa-test-on-return", description = "should connections be tested on return for jpa provider")
+    private boolean jpaTestOnReturn;
+
+    @CliOption(name = "oauth2-encrypted-key", description = "The key for encrypted provider")
+    private String encryptedKey;
+
+    @CliOption(name = "oauth2-encrypted-algorithm", description = "The algorithm for the key for the encrypted provider")
+    private String encryptedAlgo;
+
+    public String getEncryptedAlgo() {
+        return encryptedAlgo;
+    }
+
+    public void setEncryptedAlgo(final String encryptedAlgo) {
+        this.encryptedAlgo = encryptedAlgo;
+    }
+
+    public String getEncryptedKey() {
+        return encryptedKey;
+    }
+
+    public void setEncryptedKey(final String encryptedKey) {
+        this.encryptedKey = encryptedKey;
+    }
+
+    public int getJpaMaxActive() {
+        return jpaMaxActive;
+    }
+
+    public void setJpaMaxActive(final int jpaMaxActive) {
+        this.jpaMaxActive = jpaMaxActive;
+    }
+
+    public int getJpaMaxIdle() {
+        return jpaMaxIdle;
+    }
+
+    public void setJpaMaxIdle(final int jpaMaxIdle) {
+        this.jpaMaxIdle = jpaMaxIdle;
+    }
+
+    public int getJpaMaxWait() {
+        return jpaMaxWait;
+    }
+
+    public void setJpaMaxWait(final int jpaMaxWait) {
+        this.jpaMaxWait = jpaMaxWait;
+    }
+
+    public String getJpaValidationQuery() {
+        return jpaValidationQuery;
+    }
+
+    public void setJpaValidationQuery(final String jpaValidationQuery) {
+        this.jpaValidationQuery = jpaValidationQuery;
+    }
+
+    public int getJpaValidationInterval() {
+        return jpaValidationInterval;
+    }
+
+    public void setJpaValidationInterval(final int jpaValidationInterval) {
+        this.jpaValidationInterval = jpaValidationInterval;
+    }
+
+    public boolean isJpaTestOnBorrow() {
+        return jpaTestOnBorrow;
+    }
+
+    public void setJpaTestOnBorrow(final boolean jpaTestOnBorrow) {
+        this.jpaTestOnBorrow = jpaTestOnBorrow;
+    }
+
+    public boolean isJpaTestOnReturn() {
+        return jpaTestOnReturn;
+    }
+
+    public void setJpaTestOnReturn(final boolean jpaTestOnReturn) {
+        this.jpaTestOnReturn = jpaTestOnReturn;
+    }
+
+    public String getJpaProperties() {
+        return jpaProperties;
+    }
+
+    public void setJpaProperties(final String jpaProperties) {
+        this.jpaProperties = jpaProperties;
+    }
+
+    public String getJpaDatabaseUrl() {
+        return jpaDatabaseUrl;
+    }
+
+    public void setJpaDatabaseUrl(final String jpaDatabaseUrl) {
+        this.jpaDatabaseUrl = jpaDatabaseUrl;
+    }
+
+    public String getJpdaDatabaseUsername() {
+        return jpdaDatabaseUsername;
+    }
+
+    public void setJpdaDatabaseUsername(final String jpdaDatabaseUsername) {
+        this.jpdaDatabaseUsername = jpdaDatabaseUsername;
+    }
+
+    public String getJpdaDatabasePassword() {
+        return jpdaDatabasePassword;
+    }
+
+    public void setJpdaDatabasePassword(final String jpdaDatabasePassword) {
+        this.jpdaDatabasePassword = jpdaDatabasePassword;
+    }
+
+    public String getJpaDriver() {
+        return jpaDriver;
+    }
+
+    public void setJpaDriver(final String jpaDriver) {
+        this.jpaDriver = jpaDriver;
+    }
+
+    public String getJcacheConfigUri() {
+        return jcacheConfigUri;
+    }
+
+    public void setJcacheConfigUri(final String jcacheConfigUri) {
+        this.jcacheConfigUri = jcacheConfigUri;
+    }
+
+    public boolean isJcacheStoreJwtKeyOnly() {
+        return jcacheStoreJwtKeyOnly;
+    }
+
+    public void setJcacheStoreJwtKeyOnly(final boolean jcacheStoreJwtKeyOnly) {
+        this.jcacheStoreJwtKeyOnly = jcacheStoreJwtKeyOnly;
+    }
+
+    public String getProvider() {
+        return provider;
+    }
+
+    public void setProvider(final String provider) {
+        this.provider = provider;
+    }
+
+    public boolean isWriteCustomErrors() {
+        return writeCustomErrors;
+    }
+
+    public void setWriteCustomErrors(final boolean writeCustomErrors) {
+        this.writeCustomErrors = writeCustomErrors;
+    }
+
+    public boolean isBlockUnsecureRequests() {
+        return blockUnsecureRequests;
+    }
+
+    public void setBlockUnsecureRequests(final boolean blockUnsecureRequests) {
+        this.blockUnsecureRequests = blockUnsecureRequests;
+    }
+
+    public boolean isWriteOptionalParameters() {
+        return writeOptionalParameters;
+    }
+
+    public void setWriteOptionalParameters(final boolean writeOptionalParameters) {
+        this.writeOptionalParameters = writeOptionalParameters;
+    }
+
+    public boolean isCanSupportPublicClients() {
+        return canSupportPublicClients;
+    }
+
+    public void setCanSupportPublicClients(final boolean canSupportPublicClients) {
+        this.canSupportPublicClients = canSupportPublicClients;
+    }
+
+    public boolean isForceClient() {
+        return forceClient;
+    }
+
+    public void setForceClient(final boolean forceClient) {
+        this.forceClient = forceClient;
+    }
+
+    public boolean isPartialMatchScopeValidation() {
+        return partialMatchScopeValidation;
+    }
+
+    public void setPartialMatchScopeValidation(final boolean partialMatchScopeValidation) {
+        this.partialMatchScopeValidation = partialMatchScopeValidation;
+    }
+
+    public boolean isJaas() {
+        return jaas;
+    }
+
+    public void setJaas(final boolean jaas) {
+        this.jaas = jaas;
+    }
+
+    public boolean isRefreshToken() {
+        return refreshToken;
+    }
+
+    public void setRefreshToken(final boolean refreshToken) {
+        this.refreshToken = refreshToken;
+    }
+
+    public int getAccessTokenLifetime() {
+        return accessTokenLifetime;
+    }
+
+    public void setAccessTokenLifetime(final int accessTokenLifetime) {
+        this.accessTokenLifetime = accessTokenLifetime;
+    }
+
+    public long getRefreshTokenLifetime() {
+        return refreshTokenLifetime;
+    }
+
+    public void setRefreshTokenLifetime(final long refreshTokenLifetime) {
+        this.refreshTokenLifetime = refreshTokenLifetime;
+    }
+
+    public boolean isRecycleRefreshTokens() {
+        return recycleRefreshTokens;
+    }
+
+    public void setRecycleRefreshTokens(final boolean recycleRefreshTokens) {
+        this.recycleRefreshTokens = recycleRefreshTokens;
+    }
+
+    public String getDefaultScopes() {
+        return defaultScopes;
+    }
+
+    public void setDefaultScopes(final String defaultScopes) {
+        this.defaultScopes = defaultScopes;
+    }
+
+    public String getRequiredScopes() {
+        return requiredScopes;
+    }
+
+    public void setRequiredScopes(final String requiredScopes) {
+        this.requiredScopes = requiredScopes;
+    }
+
+    public String getInvisibleToClientScopes() {
+        return invisibleToClientScopes;
+    }
+
+    public void setInvisibleToClientScopes(final String invisibleToClientScopes) {
+        this.invisibleToClientScopes = invisibleToClientScopes;
+    }
+
+    public boolean isSupportPreauthorizedTokens() {
+        return supportPreauthorizedTokens;
+    }
+
+    public void setSupportPreauthorizedTokens(final boolean supportPreauthorizedTokens) {
+        this.supportPreauthorizedTokens = supportPreauthorizedTokens;
+    }
+
+    public boolean isUseJwtFormatForAccessTokens() {
+        return useJwtFormatForAccessTokens;
+    }
+
+    public void setUseJwtFormatForAccessTokens(final boolean useJwtFormatForAccessTokens) {
+        this.useJwtFormatForAccessTokens = useJwtFormatForAccessTokens;
+    }
+
+    public String getJwtAccessTokenClaimMap() {
+        return jwtAccessTokenClaimMap;
+    }
+
+    public void setJwtAccessTokenClaimMap(final String jwtAccessTokenClaimMap) {
+        this.jwtAccessTokenClaimMap = jwtAccessTokenClaimMap;
+    }
+
+    public boolean isUseAllClientScopes() {
+        return useAllClientScopes;
+    }
+
+    public void setUseAllClientScopes(final boolean useAllClientScopes) {
+        this.useAllClientScopes = useAllClientScopes;
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/RefreshTokenEnabledProvider.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/RefreshTokenEnabledProvider.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/RefreshTokenEnabledProvider.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/data/RefreshTokenEnabledProvider.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,109 @@
+/*
+ * 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.apache.meecrowave.oauth2.data;
+
+import org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration;
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
+import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
+import org.apache.cxf.rs.security.oauth2.common.UserSubject;
+import org.apache.cxf.rs.security.oauth2.provider.AbstractOAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider;
+import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
+import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RefreshTokenEnabledProvider implements OAuthDataProvider {
+    private final OAuthDataProvider delegate;
+
+    public RefreshTokenEnabledProvider(final OAuthDataProvider delegate) {
+        this.delegate = delegate;
+        if (AbstractOAuthDataProvider.class.isInstance(delegate)) {
+            final AbstractOAuthDataProvider provider = AbstractOAuthDataProvider.class.cast(delegate);
+            final Map<String, OAuthPermission> permissionMap = new HashMap<>(provider.getPermissionMap());
+            permissionMap.putIfAbsent(OAuthConstants.REFRESH_TOKEN_SCOPE, new OAuthPermission(OAuthConstants.REFRESH_TOKEN_SCOPE, "allow to refresh a token"));
+            provider.setPermissionMap(permissionMap);
+        }
+    }
+
+    @Override
+    public Client getClient(final String clientId) throws OAuthServiceException {
+        return delegate.getClient(clientId);
+    }
+
+    @Override
+    public ServerAccessToken createAccessToken(final AccessTokenRegistration accessToken) throws OAuthServiceException {
+        if (!accessToken.getRequestedScope().contains(OAuthConstants.REFRESH_TOKEN_SCOPE)) {
+            accessToken.setRequestedScope(new ArrayList<>(accessToken.getRequestedScope()));
+            accessToken.getRequestedScope().add(OAuthConstants.REFRESH_TOKEN_SCOPE);
+        }
+        if (!accessToken.getApprovedScope().contains(OAuthConstants.REFRESH_TOKEN_SCOPE)) {
+            accessToken.setApprovedScope(new ArrayList<>(accessToken.getApprovedScope()));
+            accessToken.getApprovedScope().add(OAuthConstants.REFRESH_TOKEN_SCOPE);
+        }
+        return delegate.createAccessToken(accessToken);
+    }
+
+    @Override
+    public ServerAccessToken getAccessToken(final String accessToken) throws OAuthServiceException {
+        return delegate.getAccessToken(accessToken);
+    }
+
+    @Override
+    public ServerAccessToken getPreauthorizedToken(final Client client, final List<String> requestedScopes, final UserSubject subject, final String grantType)
+            throws OAuthServiceException {
+        return delegate.getPreauthorizedToken(client, requestedScopes, subject, grantType);
+    }
+
+    @Override
+    public ServerAccessToken refreshAccessToken(final Client client, final String refreshToken, final List<String> requestedScopes) throws OAuthServiceException {
+        return delegate.refreshAccessToken(client, refreshToken, requestedScopes);
+    }
+
+    @Override
+    @Deprecated
+    public void removeAccessToken(final ServerAccessToken accessToken) throws OAuthServiceException {
+        delegate.removeAccessToken(accessToken);
+    }
+
+    @Override
+    public List<ServerAccessToken> getAccessTokens(final Client client, final UserSubject subject) throws OAuthServiceException {
+        return delegate.getAccessTokens(client, subject);
+    }
+
+    @Override
+    public List<RefreshToken> getRefreshTokens(final Client client, final UserSubject subject) throws OAuthServiceException {
+        return delegate.getRefreshTokens(client, subject);
+    }
+
+    @Override
+    public void revokeToken(final Client client, final String tokenId, final String tokenTypeHint) throws OAuthServiceException {
+        delegate.revokeToken(client, tokenId, tokenTypeHint);
+    }
+
+    @Override
+    public List<OAuthPermission> convertScopeToPermissions(final Client client, final List<String> requestedScopes) {
+        return delegate.convertScopeToPermissions(client, requestedScopes);
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/JCacheCodeDataProvider.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/JCacheCodeDataProvider.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/JCacheCodeDataProvider.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/provider/JCacheCodeDataProvider.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,30 @@
+/*
+ * 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.apache.meecrowave.oauth2.provider;
+
+import org.apache.cxf.Bus;
+
+import javax.enterprise.inject.Vetoed;
+
+@Vetoed
+public class JCacheCodeDataProvider extends org.apache.cxf.rs.security.oauth2.grants.code.JCacheCodeDataProvider {
+    public JCacheCodeDataProvider(final String configFileURL, final Bus bus) throws Exception {
+        super(configFileURL, bus);
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2Application.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2Application.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2Application.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2Application.java Sun Jan  8 19:45:37 2017
@@ -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
+ *
+ * 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.apache.meecrowave.oauth2.resource;
+
+import org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider;
+
+import javax.enterprise.context.Dependent;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.util.Arrays.asList;
+
+@Dependent
+@ApplicationPath("oauth2")
+public class OAuth2Application extends Application {
+    private Set<Class<?>> classes;
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        return classes != null ? classes : (classes = new HashSet<>(asList(
+                OAuth2TokenService.class, OAuthJSONProvider.class)));
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2TokenService.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2TokenService.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2TokenService.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/java/org/apache/meecrowave/oauth2/resource/OAuth2TokenService.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,69 @@
+/*
+ * 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.apache.meecrowave.oauth2.resource;
+
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.services.AccessTokenService;
+import org.apache.meecrowave.oauth2.configuration.OAuth2Configurer;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@Path("token")
+@RequestScoped
+public class OAuth2TokenService extends AccessTokenService {
+    private static final Client DEFAULT_CLIENT = new Client("__default", "", true);
+
+    @Inject
+    private OAuth2Configurer configurer;
+
+    @PostConstruct
+    private void init() {
+        configurer.accept(this);
+    }
+
+    @POST
+    @Consumes(APPLICATION_FORM_URLENCODED)
+    @Produces(APPLICATION_JSON)
+    public Response handleTokenRequest(final MultivaluedMap<String, String> params) {
+        return super.handleTokenRequest(params);
+    }
+
+    @Override // don't fail without a client
+    protected Client getClientFromBasicAuthScheme(final MultivaluedMap<String, String> params) {
+        final List<String> authorization = getMessageContext().getHttpHeaders().getRequestHeader("Authorization");
+        if (authorization == null || authorization.isEmpty()) {
+            if (!configurer.getConfiguration().isForceClient()) {
+                return DEFAULT_CLIENT;
+            }
+        }
+        return super.getClientFromBasicAuthScheme(params);
+    }
+}

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/org.apache.meecrowave.runner.Cli$Options
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/org.apache.meecrowave.runner.Cli%24Options?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/org.apache.meecrowave.runner.Cli$Options (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/META-INF/services/org.apache.meecrowave.runner.Cli$Options Sun Jan  8 19:45:37 2017
@@ -0,0 +1 @@
+org.apache.meecrowave.oauth2.configuration.OAuth2Options

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/default-oauth2.jcs
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/default-oauth2.jcs?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/default-oauth2.jcs (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/main/resources/default-oauth2.jcs Sun Jan  8 19:45:37 2017
@@ -0,0 +1,30 @@
+#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.
+jcs.default=
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200001
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLife=700
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true

Added: openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/OAuth2Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/OAuth2Test.java?rev=1777903&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/OAuth2Test.java (added)
+++ openwebbeans/meecrowave/trunk/meecrowave-oauth2/src/test/java/org/apache/meecrowave/oauth2/OAuth2Test.java Sun Jan  8 19:45:37 2017
@@ -0,0 +1,99 @@
+/*
+ * 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.apache.meecrowave.oauth2;
+
+import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken;
+import org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProvider;
+import org.apache.meecrowave.Meecrowave;
+import org.apache.meecrowave.junit.MeecrowaveRule;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Form;
+
+import static javax.ws.rs.client.Entity.entity;
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED_TYPE;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class OAuth2Test {
+    @ClassRule
+    public static final MeecrowaveRule MEECROWAVE = new MeecrowaveRule(
+            new Meecrowave.Builder().randomHttpPort().user("test", "pwd").role("test", "admin"), "");
+
+    @Test
+    public void getPasswordTokenNoClient() {
+        final Client client = ClientBuilder.newClient().register(new OAuthJSONProvider());
+        try {
+            final ClientAccessToken token = client.target("http://localhost:" + MEECROWAVE.getConfiguration().getHttpPort())
+                    .path("oauth2/token")
+                    .request(APPLICATION_JSON_TYPE)
+                    .post(entity(
+                            new Form()
+                                    .param("grant_type", "password")
+                                    .param("username", "test")
+                                    .param("password", "pwd"), APPLICATION_FORM_URLENCODED_TYPE), ClientAccessToken.class);
+            assertNotNull(token);
+            assertEquals("Bearer", token.getTokenType());
+            assertNotNull(token.getTokenKey());
+            assertEquals(3600, token.getExpiresIn());
+            assertNotEquals(0, token.getIssuedAt());
+            assertNotNull(token.getRefreshToken());
+        } finally {
+            client.close();
+        }
+    }
+
+    @Test
+    public void getRefreshTokenNoClient() {
+        final Client client = ClientBuilder.newClient().register(new OAuthJSONProvider());
+        try {
+            // password
+            final ClientAccessToken primary = client.target("http://localhost:" + MEECROWAVE.getConfiguration().getHttpPort())
+                    .path("oauth2/token")
+                    .request(APPLICATION_JSON_TYPE)
+                    .post(entity(
+                            new Form()
+                                    .param("grant_type", "password")
+                                    .param("username", "test")
+                                    .param("password", "pwd"), APPLICATION_FORM_URLENCODED_TYPE), ClientAccessToken.class);
+
+            // refresh
+            final ClientAccessToken token = client.target("http://localhost:" + MEECROWAVE.getConfiguration().getHttpPort())
+                    .path("oauth2/token")
+                    .request(APPLICATION_JSON_TYPE)
+                    .post(entity(
+                            new Form()
+                                    .param("grant_type", "refresh_token")
+                                    .param("refresh_token", primary.getRefreshToken()), APPLICATION_FORM_URLENCODED_TYPE), ClientAccessToken.class);
+            assertNotNull(token);
+            assertEquals("Bearer", token.getTokenType());
+            assertNotNull(token.getTokenKey());
+            assertEquals(3600, token.getExpiresIn());
+            assertNotEquals(0, token.getIssuedAt());
+            assertNotNull(token.getRefreshToken());
+        } finally {
+            client.close();
+        }
+    }
+}



Mime
View raw message