You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by md...@apache.org on 2016/01/12 22:15:35 UTC
[1/5] usergrid git commit: POM updates to not filter .p12 files. Also
reformatted the XML files for cleanliness.
Repository: usergrid
Updated Branches:
refs/heads/master 3bb61da1a -> 2455b6a65
POM updates to not filter .p12 files. Also reformatted the XML files for cleanliness.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/868db4d6
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/868db4d6
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/868db4d6
Branch: refs/heads/master
Commit: 868db4d68819a49fd4c18ec69f9a16fcd628a75b
Parents: 95fa520
Author: Michael Russo <mi...@gmail.com>
Authored: Mon Jan 11 17:51:26 2016 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Mon Jan 11 17:51:26 2016 -0800
----------------------------------------------------------------------
stack/rest/pom.xml | 32 +-
stack/services/pom.xml | 889 ++++++++++++++++++++++----------------------
2 files changed, 481 insertions(+), 440 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/868db4d6/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index f0ce7b3..e7905c9 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -51,12 +51,23 @@
</resources>
<testResources>
+ <!-- the filtering causes corruption in the p12 files, so exclude them in filtering and copy without filtering -->
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
+ <excludes>
+ <exclude>**/*.p12</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*.p12</include>
+ </includes>
</testResource>
</testResources>
@@ -79,12 +90,16 @@
<threadCount>${usergrid.rest.threads}</threadCount>
<useSystemClassLoader>false</useSystemClassLoader>
<reuseForks>true</reuseForks>
- <argLine>-Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties ${ug.argline}
+ <argLine>-Dwebapp.directory=${basedir}/src/main/webapp
+ -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax}
+ -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
+ -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar
+ -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties ${ug.argline}
</argLine>
<includes>
<include>**/*IT.java</include>
<include>**/*Test.java</include>
- </includes>
+ </includes>
<excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest</excludedGroups>
</configuration>
@@ -422,8 +437,17 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
- <argLine>-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec -Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties ${ug.argline}</argLine>
- <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest</excludedGroups>
+ <argLine>
+ -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec
+ -Dwebapp.directory=${basedir}/src/main/webapp
+ -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true
+ -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
+ -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar
+ -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties
+ ${ug.argline}
+ </argLine>
+ <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest
+ </excludedGroups>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/868db4d6/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 9660894..7189eb4 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -17,442 +17,453 @@
-->
<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>
- <parent>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <!-- Override these properties in your settings.xml in an active profile -->
- <properties>
-
- </properties>
-
- <artifactId>usergrid-services</artifactId>
- <name>Usergrid Services</name>
- <description>Service layer for Usergrid system.</description>
- <packaging>jar</packaging>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
-
-
- <!-- PROFILES -->
-
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/python</directory>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.yaml</include>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- <include>**/*.p12</include>
- <include>**/*.json</include>
- </includes>
- </testResource>
- <testResource>
- <directory>src/main/python</directory>
- </testResource>
- </testResources>
-
- <plugins>
-
- <!--
- Need to override parent's surefire plugin here to set system properties.
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.plugin.version}</version>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
- <parallel>${usergrid.it.parallel}</parallel>
- <forkCount>${usergrid.it.forkCount}</forkCount>
- <threadCount>${usergrid.it.threads}</threadCount>
- <reuseForks>${usergrid.it.reuseForks}</reuseForks>
- <useSystemClassLoader>false</useSystemClassLoader>
- <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}
- </argLine>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid</artifactId>
+ <version>2.1.1-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <!-- Override these properties in your settings.xml in an active profile -->
+ <properties>
+
+ </properties>
+
+ <artifactId>usergrid-services</artifactId>
+ <name>Usergrid Services</name>
+ <description>Service layer for Usergrid system.</description>
+ <packaging>jar</packaging>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+
+ <!-- PROFILES -->
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
<includes>
- <include>**/*IT.java</include>
- <include>**/*Test.java</include>
+ <include>**/*.xml</include>
</includes>
- <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest</excludedGroups>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.surefire</groupId>
- <artifactId>${surefire.plugin.artifactName}</artifactId>
- <version>${surefire.plugin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.21</version>
- </dependency>
- </dependencies>
-
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
-
- <!-- Usergrid Dependencies -->
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-config</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-core</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>commons-logging</artifactId>
- <groupId>commons-logging</groupId>
- </exclusion>
-
- <exclusion>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.mindrot</groupId>
- <artifactId>jbcrypt</artifactId>
- </dependency>
-
- <!-- Apache Dependencies -->
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-spring</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.amber</groupId>
- <artifactId>amber-oauth2-common</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.amber</groupId>
- <artifactId>amber-oauth2-authzserver</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.amber</groupId>
- <artifactId>amber-oauth2-resourceserver</artifactId>
- </dependency>
-
- <!-- SUN, Javax Package and Other Com Dependencies -->
-
- <!-- Required only when you are using JAX-RS Client -->
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- <version>2.21</version>
- </dependency>
-
- <dependency>
- <groupId>org.glassfish.jersey.media</groupId>
- <artifactId>jersey-media-json-jackson</artifactId>
- <version>2.21</version>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>com.sun.jersey</groupId>-->
- <!--<artifactId>jersey-core</artifactId>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>com.sun.jersey</groupId>-->
- <!--<artifactId>jersey-client</artifactId>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>com.sun.jersey</groupId>-->
- <!--<artifactId>jersey-json</artifactId>-->
- <!--</dependency>-->
-
- <!-- Codehaus, JClouds, Spring and Other Org Dependencies -->
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.amazonaws</groupId>
- <artifactId>aws-java-sdk-s3</artifactId>
- <!--<exclusions>-->
- <!--<exclusion>-->
- <!--<artifactId>jackson-databind</artifactId>-->
- <!--<groupId>com.fasterxml.jackson.core</groupId>-->
- <!--</exclusion>-->
- <!--</exclusions>-->
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-blobstore</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>guice-assistedinject</artifactId>
- <groupId>com.google.inject.extensions</groupId>
- </exclusion>
- <exclusion>
- <artifactId>guice</artifactId>
- <groupId>com.google.inject</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-allblobstore</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-netty</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-apachehc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-log4j</artifactId>
- <exclusions>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.python</groupId>
- <artifactId>jython</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- </dependency>
-
- <!-- Testing and Logging Dependencies -->
- <dependency>
- <!--
- Do not remove this slf4j-api dependency remove even though pulled
- in transitively. If not present IntelliJ IDEA wigs out.
- -->
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-config</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
-
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jvnet.mock-javamail</groupId>
- <artifactId>mock-javamail</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4-rule-agent</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hectorclient</groupId>
- <artifactId>hector-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.relayrides</groupId>
- <artifactId>pushy</artifactId>
- <!-- The sha in the version is the git commit used in this build. Check out the pushy source, then this commit to build the library locally -->
- <version>0.4</version>
- </dependency>
-
- <dependency>
- <groupId>io.apigee.gcm</groupId>
- <artifactId>gcm-server</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.clearspring.analytics</groupId>
- <artifactId>stream</artifactId>
- <version>2.7.0</version>
- </dependency>
- <!-- fork: https://github.com/apigee/java-wns/tree/1.2-USERGRID -->
- <!-- forked to eliminate jackson dependency issues -->
- <dependency>
- <groupId>com.github.fernandospr</groupId>
- <artifactId>java-wns</artifactId>
- <version>1.2-USERGRID</version>
- </dependency>
- </dependencies>
+ </resource>
+ <resource>
+ <directory>src/main/python</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <!-- the filtering causes corruption in the p12 files, so exclude them in filtering and copy without filtering -->
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.yaml</include>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ <include>**/*.json</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.p12</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/main/python</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*.p12</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <!--
+ Need to override parent's surefire plugin here to set system properties.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.plugin.version}</version>
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+ <parallel>${usergrid.it.parallel}</parallel>
+ <forkCount>${usergrid.it.forkCount}</forkCount>
+ <threadCount>${usergrid.it.threads}</threadCount>
+ <reuseForks>${usergrid.it.reuseForks}</reuseForks>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true
+ -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
+ -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar
+ ${ug.argline}
+ </argLine>
+ <includes>
+ <include>**/*IT.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest</excludedGroups>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>${surefire.plugin.artifactName}</artifactId>
+ <version>${surefire.plugin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.21</version>
+ </dependency>
+ </dependencies>
+
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <!-- Usergrid Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-config</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-core</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mindrot</groupId>
+ <artifactId>jbcrypt</artifactId>
+ </dependency>
+
+ <!-- Apache Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>amber-oauth2-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>amber-oauth2-authzserver</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>amber-oauth2-resourceserver</artifactId>
+ </dependency>
+
+ <!-- SUN, Javax Package and Other Com Dependencies -->
+
+ <!-- Required only when you are using JAX-RS Client -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>2.21</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <version>2.21</version>
+ </dependency>
+
+ <!--<dependency>-->
+ <!--<groupId>com.sun.jersey</groupId>-->
+ <!--<artifactId>jersey-core</artifactId>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>com.sun.jersey</groupId>-->
+ <!--<artifactId>jersey-client</artifactId>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>com.sun.jersey</groupId>-->
+ <!--<artifactId>jersey-json</artifactId>-->
+ <!--</dependency>-->
+
+ <!-- Codehaus, JClouds, Spring and Other Org Dependencies -->
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk-s3</artifactId>
+ <!--<exclusions>-->
+ <!--<exclusion>-->
+ <!--<artifactId>jackson-databind</artifactId>-->
+ <!--<groupId>com.fasterxml.jackson.core</groupId>-->
+ <!--</exclusion>-->
+ <!--</exclusions>-->
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-blobstore</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>guice-assistedinject</artifactId>
+ <groupId>com.google.inject.extensions</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>guice</artifactId>
+ <groupId>com.google.inject</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-allblobstore</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-netty</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-apachehc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-log4j</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ </dependency>
+
+ <!-- Testing and Logging Dependencies -->
+ <dependency>
+ <!--
+ Do not remove this slf4j-api dependency remove even though pulled
+ in transitively. If not present IntelliJ IDEA wigs out.
+ -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-config</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jvnet.mock-javamail</groupId>
+ <artifactId>mock-javamail</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule-agent</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hectorclient</groupId>
+ <artifactId>hector-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.relayrides</groupId>
+ <artifactId>pushy</artifactId>
+ <!-- The sha in the version is the git commit used in this build. Check out the pushy source, then this commit to build the library locally -->
+ <version>0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.apigee.gcm</groupId>
+ <artifactId>gcm-server</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.clearspring.analytics</groupId>
+ <artifactId>stream</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <!-- fork: https://github.com/apigee/java-wns/tree/1.2-USERGRID -->
+ <!-- forked to eliminate jackson dependency issues -->
+ <dependency>
+ <groupId>com.github.fernandospr</groupId>
+ <artifactId>java-wns</artifactId>
+ <version>1.2-USERGRID</version>
+ </dependency>
+ </dependencies>
<!--
Need jacoco profile here because we override the parent's surefire plugin settings above.
@@ -467,8 +478,14 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
- <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline} -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec</argLine>
- <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest</excludedGroups>
+ <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true
+ -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
+ -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar
+ ${ug.argline}
+ -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec
+ </argLine>
+ <excludedGroups>org.apache.usergrid.StressTest,org.apache.usergrid.ExperimentalTest
+ </excludedGroups>
</configuration>
</plugin>
</plugins>
[4/5] usergrid git commit: Make sure the validTo and validFrom string
formats are GMT timezone. Add filename to the certInfo object.
Posted by md...@apache.org.
Make sure the validTo and validFrom string formats are GMT timezone. Add filename to the certInfo object.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/61c57c28
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/61c57c28
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/61c57c28
Branch: refs/heads/master
Commit: 61c57c286e2694b5cb50ecdf3f4e60c263ad7f75
Parents: bc68332
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Jan 12 09:15:05 2016 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Jan 12 09:15:05 2016 -0800
----------------------------------------------------------------------
.../notifiers/NotifierResource.java | 25 ++++++++++++--------
.../notifiers/NotifiersResource.java | 14 ++++++++++-
.../usergrid/rest/utils/CertificateUtils.java | 14 +++++++----
3 files changed, 37 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/61c57c28/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
index 637f0a5..21d3d73 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
@@ -69,8 +69,8 @@ public class NotifierResource extends ServiceResource {
logger.debug("NotifierResource.executeMultiPartPut");
}
- String certInfo = getValueOrNull(multiPart, "certInfo");
- if (certInfo != null){
+ String certInfoParam = getValueOrNull(multiPart, "certInfo");
+ if (certInfoParam != null){
throw new IllegalArgumentException("Cannot create or update with certInfo parameter. It is derived.");
}
@@ -80,7 +80,9 @@ public class NotifierResource extends ServiceResource {
InputStream is = null;
Map<String, Object> certAttributes = null;
+ String filename = null;
if (multiPart.getField("p12Certificate") != null) {
+ filename = multiPart.getField("p12Certificate").getContentDisposition().getFileName();
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
}else{
@@ -92,26 +94,29 @@ public class NotifierResource extends ServiceResource {
throw new IllegalArgumentException("p12Certificate is expired");
}
- HashMap<String, Object> properties = new LinkedHashMap<String, Object>();
- properties.put("name", name);
- properties.put("provider", provider);
- properties.put("environment", "production");
- properties.put("certificatePassword", certPassword);
+ HashMap<String, Object> certProps = new LinkedHashMap<String, Object>();
+ certProps.put("name", name);
+ certProps.put("provider", provider);
+ certProps.put("environment", "production");
+ certProps.put("certificatePassword", certPassword);
if (is != null) {
byte[] certBytes = IOUtils.toByteArray(is);
- properties.put("p12Certificate", certBytes);
+ certProps.put("p12Certificate", certBytes);
is.close();
}
+ HashMap<String, Object> certInfo = new LinkedHashMap<String, Object>();
if (certAttributes != null){
- properties.put("certInfo", certAttributes);
+ certInfo.put("filename", filename);
+ certInfo.put("details", certAttributes);
}
+ certProps.put("certInfo", certInfo);
ApiResponse response = createApiResponse();
response.setAction("put");
response.setApplication(services.getApplication());
response.setParams(ui.getQueryParameters());
- ServicePayload payload = getPayload(properties);
+ ServicePayload payload = getPayload(certProps);
executeServiceRequest(ui, response, ServiceAction.PUT, payload);
return response;
http://git-wip-us.apache.org/repos/asf/usergrid/blob/61c57c28/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
index 77dab9b..bd02c35 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
@@ -114,6 +114,11 @@ public class NotifiersResource extends ServiceResource {
logger.debug("Notifiers.executeMultiPartPost");
}
+ String certInfoParam = getValueOrNull(multiPart, "certInfo");
+ if (certInfoParam != null){
+ throw new IllegalArgumentException("Cannot create or update with certInfo parameter. It is derived.");
+ }
+
String name = getValueOrNull(multiPart, "name");
String provider = getValueOrNull(multiPart, "provider");
String environment = getValueOrNull(multiPart, "environment");
@@ -121,7 +126,9 @@ public class NotifiersResource extends ServiceResource {
InputStream is = null;
Map<String, Object> certAttributes = null;
+ String filename = null;
if (multiPart.getField("p12Certificate") != null) {
+ filename = multiPart.getField("p12Certificate").getContentDisposition().getFileName();
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
}else{
@@ -133,7 +140,9 @@ public class NotifiersResource extends ServiceResource {
throw new IllegalArgumentException("p12Certificate is expired.");
}
+
HashMap<String, Object> certProps = new LinkedHashMap<String, Object>();
+
certProps.put("name", name);
certProps.put("provider", provider);
certProps.put("environment", environment);
@@ -142,9 +151,12 @@ public class NotifiersResource extends ServiceResource {
byte[] certBytes = IOUtils.toByteArray(is);
certProps.put("p12Certificate", certBytes);
}
+ HashMap<String, Object> certInfo = new LinkedHashMap<String, Object>();
if (certAttributes != null){
- certProps.put("certInfo", certAttributes);
+ certInfo.put("filename", filename);
+ certInfo.put("details", certAttributes);
}
+ certProps.put("certInfo", certInfo);
ApiResponse response = createApiResponse();
response.setAction("post");
http://git-wip-us.apache.org/repos/asf/usergrid/blob/61c57c28/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
index 3ee786b..6f4be92 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
@@ -22,13 +22,13 @@ import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
+import java.text.SimpleDateFormat;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import java.util.SimpleTimeZone;
+
-/**
- * Created by michaelarusso on 1/11/16.
- */
public class CertificateUtils {
private static final Logger logger = LoggerFactory.getLogger(CertificateUtils.class);
@@ -41,6 +41,10 @@ public class CertificateUtils {
certPassword = ""; // if there is no password, pass in empty string
}
+ SimpleDateFormat dateFormat = new SimpleDateFormat();
+ dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
+ dateFormat.applyPattern("EEE dd MMM yyyy HH:mm:ss z"); // GMT String format
+
Map<String,Object> attributes = new HashMap<>(1);
try{
KeyStore p12 = KeyStore.getInstance("pkcs12");
@@ -50,9 +54,9 @@ public class CertificateUtils {
String alias = (String) aliases.nextElement();
X509Certificate cert = (X509Certificate) p12.getCertificate(alias);
attributes.put("subject", cert.getSubjectDN().toString());
- attributes.put("validFrom", cert.getNotBefore());
+ attributes.put("validFrom", dateFormat.format(cert.getNotBefore()));
attributes.put("validFromTimestamp", cert.getNotBefore().getTime());
- attributes.put("validTo", cert.getNotAfter());
+ attributes.put("validTo", dateFormat.format(cert.getNotAfter()));
attributes.put("validToTimestamp", cert.getNotAfter().getTime());
attributes.put("issuer", cert.getIssuerDN().toString());
attributes.put("subjectAlternativeNames", cert.getSubjectAlternativeNames());
[3/5] usergrid git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1203
Posted by md...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1203
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/bc683322
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/bc683322
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/bc683322
Branch: refs/heads/master
Commit: bc683322c625736f5d1c15ae3a756d16071a6d1f
Parents: 858c750 3bb61da
Author: Michael Russo <mi...@gmail.com>
Authored: Mon Jan 11 17:53:56 2016 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Mon Jan 11 17:53:56 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/usergrid/rest/management/RegistrationIT.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
[2/5] usergrid git commit: Verify certificates when uploaded and
update the certInfo object in the notifier with details about the
certificate. Fix APNS service tests. Fix scheduled notifications where a
missing column family was not being created.
Posted by md...@apache.org.
Verify certificates when uploaded and update the certInfo object in the notifier with details about the certificate. Fix APNS service tests. Fix scheduled notifications where a missing column family was not being created.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/858c750c
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/858c750c
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/858c750c
Branch: refs/heads/master
Commit: 858c750c0b91769c64e90bfa50c7390bcf3cab01
Parents: 868db4d
Author: Michael Russo <mi...@gmail.com>
Authored: Mon Jan 11 17:53:33 2016 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Mon Jan 11 17:53:33 2016 -0800
----------------------------------------------------------------------
.../apache/usergrid/mq/cassandra/QueuesCF.java | 2 +-
.../notifiers/NotifierResource.java | 23 +-
.../notifiers/NotifiersResource.java | 18 +-
.../usergrid/rest/utils/CertificateUtils.java | 102 ++++++++
.../applications/notifiers/NotifiersIT.java | 99 ++++++++
.../src/test/resources/pushtest_dev_recent.p12 | Bin 0 -> 3227 bytes
.../services/notifications/QueueListener.java | 3 +-
.../usergrid/services/queues/QueueListener.java | 3 +-
.../notifications/NotifiersServiceIT.java | 3 +-
.../apns/MockSuccessfulProviderAdapter.java | 101 --------
.../apns/NotificationsServiceIT.java | 251 +++++++------------
.../gcm/MockSuccessfulProviderAdapter.java | 85 -------
.../src/test/resources/pushtest_dev.p12 | Bin 3203 -> 0 bytes
.../src/test/resources/pushtest_prod.p12 | Bin 3205 -> 0 bytes
14 files changed, 326 insertions(+), 364 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/QueuesCF.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/QueuesCF.java b/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/QueuesCF.java
index b0f6906..58023d7 100644
--- a/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/QueuesCF.java
+++ b/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/QueuesCF.java
@@ -31,7 +31,7 @@ import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtil
public enum QueuesCF implements CFEnum {
- MESSAGE_PROPERTIES( "Entity_Properties", "BytesType", false ),
+ MESSAGE_PROPERTIES( "Entity_Properties", "BytesType" ),
QUEUE_PROPERTIES( "Queue_Properties", "BytesType" ),
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
index 284c067..637f0a5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
@@ -22,6 +22,7 @@ import org.apache.usergrid.persistence.index.query.Identifier;
import org.apache.usergrid.rest.ApiResponse;
import org.apache.usergrid.rest.applications.ServiceResource;
import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
+import org.apache.usergrid.rest.utils.CertificateUtils;
import org.apache.usergrid.services.ServiceAction;
import org.apache.usergrid.services.ServicePayload;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -37,6 +38,7 @@ import javax.ws.rs.core.UriInfo;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.Map;
@Component("org.apache.usergrid.rest.applications.notifiers.NotifierResource")
@Scope("prototype")
@@ -64,7 +66,12 @@ public class NotifierResource extends ServiceResource {
FormDataMultiPart multiPart) throws Exception {
if (logger.isDebugEnabled()) {
- logger.debug("NotifierResource.executePut");
+ logger.debug("NotifierResource.executeMultiPartPut");
+ }
+
+ String certInfo = getValueOrNull(multiPart, "certInfo");
+ if (certInfo != null){
+ throw new IllegalArgumentException("Cannot create or update with certInfo parameter. It is derived.");
}
String name = getValueOrNull(multiPart, "name");
@@ -72,8 +79,17 @@ public class NotifierResource extends ServiceResource {
String certPassword = getValueOrNull(multiPart, "certificatePassword");
InputStream is = null;
+ Map<String, Object> certAttributes = null;
if (multiPart.getField("p12Certificate") != null) {
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
+ certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
+ }else{
+ throw new IllegalArgumentException("p12Certificate data cannot be empty");
+ }
+
+ // check to see if the certificate is valid
+ if(!CertificateUtils.isValid(certAttributes)){
+ throw new IllegalArgumentException("p12Certificate is expired");
}
HashMap<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -84,8 +100,13 @@ public class NotifierResource extends ServiceResource {
if (is != null) {
byte[] certBytes = IOUtils.toByteArray(is);
properties.put("p12Certificate", certBytes);
+ is.close();
+ }
+ if (certAttributes != null){
+ properties.put("certInfo", certAttributes);
}
+
ApiResponse response = createApiResponse();
response.setAction("put");
response.setApplication(services.getApplication());
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
index c8ae99f..77dab9b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.rest.AbstractContextResource;
import org.apache.usergrid.rest.ApiResponse;
import org.apache.usergrid.rest.applications.ServiceResource;
import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
+import org.apache.usergrid.rest.utils.CertificateUtils;
import org.apache.usergrid.services.ServiceAction;
import org.apache.usergrid.services.ServicePayload;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@@ -38,9 +39,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.UriInfo;
import java.io.InputStream;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.UUID;
+import java.util.*;
import static org.apache.usergrid.services.ServiceParameter.addParameter;
@@ -112,7 +111,7 @@ public class NotifiersResource extends ServiceResource {
throws Exception {
if (logger.isDebugEnabled()) {
- logger.debug("ServiceResource.uploadData");
+ logger.debug("Notifiers.executeMultiPartPost");
}
String name = getValueOrNull(multiPart, "name");
@@ -121,10 +120,18 @@ public class NotifiersResource extends ServiceResource {
String certPassword = getValueOrNull(multiPart, "certificatePassword");
InputStream is = null;
+ Map<String, Object> certAttributes = null;
if (multiPart.getField("p12Certificate") != null) {
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
+ certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
+ }else{
+ throw new IllegalArgumentException("p12Certificate password cannot be empty or null.");
}
+ // check to see if the certificate is valid
+ if(!CertificateUtils.isValid(certAttributes)){
+ throw new IllegalArgumentException("p12Certificate is expired.");
+ }
HashMap<String, Object> certProps = new LinkedHashMap<String, Object>();
certProps.put("name", name);
@@ -135,6 +142,9 @@ public class NotifiersResource extends ServiceResource {
byte[] certBytes = IOUtils.toByteArray(is);
certProps.put("p12Certificate", certBytes);
}
+ if (certAttributes != null){
+ certProps.put("certInfo", certAttributes);
+ }
ApiResponse response = createApiResponse();
response.setAction("post");
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
new file mode 100644
index 0000000..3ee786b
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.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
+ *
+ * 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.usergrid.rest.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by michaelarusso on 1/11/16.
+ */
+public class CertificateUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(CertificateUtils.class);
+
+ private static final String APPLE_TOPIC_OID = "1.2.840.113635.100.6.3.6";
+
+ public static Map<String, Object> getCertAtrributes(InputStream stream, String certPassword){
+
+ if(certPassword == null){
+ certPassword = ""; // if there is no password, pass in empty string
+ }
+
+ Map<String,Object> attributes = new HashMap<>(1);
+ try{
+ KeyStore p12 = KeyStore.getInstance("pkcs12");
+ p12.load(stream, certPassword.toCharArray());
+ Enumeration aliases = p12.aliases();
+ while(aliases.hasMoreElements()){
+ String alias = (String) aliases.nextElement();
+ X509Certificate cert = (X509Certificate) p12.getCertificate(alias);
+ attributes.put("subject", cert.getSubjectDN().toString());
+ attributes.put("validFrom", cert.getNotBefore());
+ attributes.put("validFromTimestamp", cert.getNotBefore().getTime());
+ attributes.put("validTo", cert.getNotAfter());
+ attributes.put("validToTimestamp", cert.getNotAfter().getTime());
+ attributes.put("issuer", cert.getIssuerDN().toString());
+ attributes.put("subjectAlternativeNames", cert.getSubjectAlternativeNames());
+
+ // Apple uses a specific extension OID for their universal cert structure and push topics
+ Map<String,Object> extensions = new HashMap<>(1);
+ if(cert.getExtensionValue(APPLE_TOPIC_OID) != null){
+ extensions.put(APPLE_TOPIC_OID, cert.getExtensionValue(APPLE_TOPIC_OID));
+ }
+ attributes.put("extensions", extensions);
+
+ attributes.put("extendedKeyUsages", cert.getExtendedKeyUsage());
+ attributes.put("version", cert.getVersion());
+ attributes.put("signatureAlgorithm", cert.getSigAlgName());
+ attributes.put("serialNumber", cert.getSerialNumber());
+ attributes.put("basicConstraints", cert.getBasicConstraints());
+
+ }
+ }catch (Exception e){
+ String message = "Unable load certificate details. Possible invalid p12 file.";
+ throw new RuntimeException(message, e);
+ }
+
+ return attributes;
+ }
+
+
+ public static boolean isValid(Map<String, Object> certAttributes) {
+
+ if(certAttributes == null || certAttributes.isEmpty()){
+ return false;
+ }
+
+ // check to make sure the certificate is not expired
+ final long currentTime = System.currentTimeMillis();
+ final long validToTimestamp = (long) certAttributes.get("validToTimestamp");
+
+ // if the current time doesn't fall into the certs
+ if(currentTime > validToTimestamp){
+ logger.error("Certificate is not valid due to time. Cert Valid To: {}", validToTimestamp);
+ return false;
+ }
+
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
new file mode 100644
index 0000000..a866e23
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
@@ -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.usergrid.rest.applications.notifiers;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.usergrid.rest.test.resource.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+public class NotifiersIT extends AbstractRestIT {
+
+ private static final Logger logger = LoggerFactory.getLogger( NotifiersIT.class );
+
+ //private static final String VALID_CERT_FILE = "apple_push_valid_nocommit.p12";
+ private static final String INVALID_CERT_FILE = "pushtest_dev_recent.p12";
+
+ private static byte[] validCertBytes;
+ private static byte[] invalidCertBytes;
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ //InputStream validCertStream = NotifiersIT.class.getClassLoader().getResourceAsStream(VALID_CERT_FILE);
+ InputStream invalidCertStream = NotifiersIT.class.getClassLoader().getResourceAsStream(INVALID_CERT_FILE);
+
+ //validCertBytes = IOUtils.toByteArray(validCertStream);
+ invalidCertBytes = IOUtils.toByteArray(invalidCertStream);
+
+ //validCertStream.close();
+ invalidCertStream.close();
+ }
+
+ @Ignore("Pending valid certificate being committed to the source code.")
+ @Test
+ public void createAppleNotifierValidCertificate() {
+
+
+ FormDataMultiPart form = new FormDataMultiPart()
+ .field("name", "validAppleNotifier")
+ .field("environment", "development")
+ .field("provider", "apple")
+ .field( "p12Certificate", validCertBytes, MediaType.MULTIPART_FORM_DATA_TYPE );
+
+
+ ApiResponse postResponse = pathResource( getOrgAppPath( "notifiers" )).post( form );
+
+ assertNotNull("certInfo should not be null", postResponse.getEntities().get(0).get("certInfo"));
+
+ }
+
+ @Test
+ public void createAppleNotifierInvalidCertificate() {
+
+
+ FormDataMultiPart form = new FormDataMultiPart()
+ .field("name", "validAppleNotifier")
+ .field("environment", "development")
+ .field("provider", "apple")
+ .field( "p12Certificate", invalidCertBytes, MediaType.MULTIPART_FORM_DATA_TYPE );
+
+ // this is expected to throw an exception that we can catch and verify 400 status code
+ try {
+ ApiResponse postResponse = pathResource( getOrgAppPath( "notifiers" )).post( form );
+ } catch (BadRequestException e){
+ assertEquals(400, e.getResponse().getStatus());
+ }
+
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/rest/src/test/resources/pushtest_dev_recent.p12
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/pushtest_dev_recent.p12 b/stack/rest/src/test/resources/pushtest_dev_recent.p12
new file mode 100644
index 0000000..80941c5
Binary files /dev/null and b/stack/rest/src/test/resources/pushtest_dev_recent.p12 differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 1ab1db1..6d6123c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -74,7 +74,6 @@ public class QueueListener {
public final int MAX_THREADS = 2;
private Integer batchSize = 10;
private String queueName;
- public QueueManager TEST_QUEUE_MANAGER;
private int consecutiveCallsToRemoveDevices;
public QueueListener(ServiceManagerFactory smf, EntityManagerFactory emf, Properties props){
@@ -151,7 +150,7 @@ public class QueueListener {
svcMgr = smf.getServiceManager(smf.getManagementAppId());
logger.info("getting from queue {} ", queueName);
QueueScope queueScope = new QueueScopeImpl( queueName, QueueScope.RegionImplementation.LOCAL);
- QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
+ QueueManager queueManager = queueManagerFactory.getQueueManager(queueScope);
// run until there are no more active jobs
final AtomicLong runCount = new AtomicLong(0);
//cache to retrieve push manager, cached per notifier, so many notifications will get same push manager
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java
index b1c90d1..bafa3a2 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/queues/QueueListener.java
@@ -71,7 +71,6 @@ public abstract class QueueListener {
public final int MAX_THREADS = 2;
private Integer batchSize = 10;
private String queueName;
- public QueueManager TEST_QUEUE_MANAGER;
private int consecutiveCallsToRemoveDevices;
private Meter meter;
private Timer timer;
@@ -161,7 +160,7 @@ public abstract class QueueListener {
svcMgr = smf.getServiceManager(smf.getManagementAppId());
logger.info("getting from queue {} ", queueName);
QueueScope queueScope = new QueueScopeImpl( queueName, QueueScope.RegionImplementation.LOCAL);
- QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
+ QueueManager queueManager = queueManagerFactory.getQueueManager(queueScope);
// run until there are no more active jobs
long runCount = 0;
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
index 58172dd..bab1316 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
@@ -123,6 +123,7 @@ public class NotifiersServiceIT extends AbstractServiceIT {
}
}
+ @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1113. Mock doesn't work")
@Test
public void goodAPNsCreation() throws Exception {
@@ -157,7 +158,7 @@ public class NotifiersServiceIT extends AbstractServiceIT {
app.put("environment", "development");
InputStream fis = getClass().getClassLoader().getResourceAsStream(
- "pushtest_prod.p12");
+ "pushtest_dev_recent.p12");
byte[] certBytes = IOUtils.toByteArray(fis);
app.put("p12Certificate", certBytes);
fis.close();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
deleted file mode 100644
index 6be4375..0000000
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
+++ /dev/null
@@ -1,101 +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.apache.usergrid.services.notifications.apns;
-
-import org.apache.usergrid.persistence.entities.Notification;
-import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.services.notifications.ProviderAdapter;
-import org.apache.usergrid.services.notifications.TaskTracker;
-
-import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.apache.usergrid.services.ServicePayload;
-
-public class MockSuccessfulProviderAdapter implements ProviderAdapter {
-
- private static ProviderAdapter realProviderAdapter;
-
-
- private ExecutorService pool;
-
- public MockSuccessfulProviderAdapter() {
- }
-
- public MockSuccessfulProviderAdapter(boolean async) {
- if (async) {
- pool = Executors
- .newFixedThreadPool(APNsAdapter.MAX_CONNECTION_POOL_SIZE);
- }
- }
-
- @Override
- public void testConnection() throws Exception {
- }
-
- @Override
- public String translatePayload(Object payload) throws Exception {
- return payload.toString();
- }
-
- @Override
- public void removeInactiveDevices() {
- }
-
- @Override
- public void validateCreateNotifier(ServicePayload payload) throws Exception {
- }
-
- @Override
- public void stop() {
-
- }
-
- @Override
- public Notifier getNotifier() {
- return null;
- }
-
- @Override
- public void doneSendingNotifications() throws Exception {
- }
-
- @Override
- public void sendNotification(final String providerId, final Object payload,
- final Notification notification, final TaskTracker tracker)
- throws Exception {
-
- final APNsNotification apnsNotification = APNsNotification.create(
- providerId, payload.toString(), notification, tracker);
-
- if (pool == null) {
- apnsNotification.messageSent();
- } else {
- pool.submit(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(new Random().nextInt(100));
- apnsNotification.messageSent();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index e18cdb2..dea4e49 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -17,11 +17,11 @@
package org.apache.usergrid.services.notifications.apns;
import com.relayrides.pushy.apns.util.*;
+import net.jcip.annotations.NotThreadSafe;
import org.apache.commons.io.IOUtils;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.queue.LocalQueueManager;
import org.apache.usergrid.services.exceptions.ForbiddenServiceOperationException;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
@@ -40,12 +40,11 @@ import static org.junit.Assert.fail;
import static org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl.NOTIFIER_ID_POSTFIX;
-// todo: test reschedule on delivery time change
-// todo: test restart of queuing
-@Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1113. ")
+
+@NotThreadSafe
public class NotificationsServiceIT extends AbstractServiceNotificationIT {
- private static final Logger LOG = LoggerFactory.getLogger(NotificationsServiceIT.class);
+ private static final Logger logger = LoggerFactory.getLogger(NotificationsServiceIT.class);
/**
* set to true to run tests against actual Apple servers - but they may not
@@ -58,12 +57,10 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
private Notifier notifier;
private Device device1, device2;
- private Group group1;
- private User user1;
+ private User user1, user2;
private NotificationsService ns;
- QueueListener listener;
+ private QueueListener listener;
private String notifierName = "apNs";
- private User user2;
@BeforeClass
public static void setup(){
@@ -78,7 +75,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
app.put("name", notifierName);
app.put("provider",PROVIDER);
app.put("environment", USE_REAL_CONNECTIONS ? "development" : "mock");
- // app.put("certificatePassword","pushy-test");
InputStream fis = getClass().getClassLoader().getResourceAsStream( "pushtest_dev_recent.p12");
byte[] certBytes = IOUtils.toByteArray(fis);
app.put("p12Certificate", certBytes);
@@ -121,12 +117,10 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ns = getNotificationService();
- LocalQueueManager qm = new LocalQueueManager();
setup.getEntityIndex().refresh(app.getId());
listener = new QueueListener(ns.getServiceManagerFactory(),ns.getEntityManagerFactory(), new Properties());
- listener.TEST_QUEUE_MANAGER = qm;
listener.DEFAULT_SLEEP = 200;
listener.start();
}
@@ -142,16 +136,11 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
@Test
public void singlePushNotification() throws Exception {
- // create push notification //
-
- setup.getEntityIndex().refresh(app.getId());
- // give queue manager a query for loading 100 devices from an application (why?)
app.clear();
- // create a "hellow world" notification
String payload = getPayload();
Map<String, String> payloads = new HashMap<String, String>(1);
- payloads.put(notifier.getName().toString(), payload);
+ payloads.put(notifier.getName(), payload);
app.put("payloads", payloads);
app.put("queued", System.currentTimeMillis());
app.put("debug",true);
@@ -159,8 +148,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// post notification to service manager
Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications").getEntity();
-
- // ensure notification it was created
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
// ensure notification has expected name
@@ -169,28 +156,11 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification.getPayloads().get(notifier.getName().toString()),
payload);
- // verify Query for CREATED state
- Query query = Query.fromEquals( "state", Notification.State.STARTED.toString() );
- Results results = app.getEntityManager().searchCollection(
- app.getEntityManager().getApplicationRef(), "notifications", query);
- Entity entity = results.getEntitiesMap().get(notification.getUuid());
- //assertNotNull(entity);
// perform push //
-
notification = notificationWaitForComplete(notification);
+ checkReceipts(notification, 1);
- setup.getEntityIndex().refresh(app.getId());
-
- // verify Query for FINISHED state
- query = Query.fromEquals("state", Notification.State.FINISHED.toString());
- results = app.getEntityManager().searchCollection(app.getEntityManager().getApplicationRef(),
- "notifications", query);
- entity = results.getEntitiesMap().get(notification.getUuid());
- assertNotNull(entity);
-
- checkReceipts(notification, 2);
- checkStatistics(notification, 2, 0);
}
@Test
@@ -265,7 +235,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification = (Notification) entity.toTypedEntity();
checkReceipts(notification, 0);
- checkStatistics(notification, 0, 0);
+
+ // Statistics are not accurate -- see https://issues.apache.org/jira/browse/USERGRID-1207
+ //checkStatistics(notification, 0, 0);
}
@Test
@@ -278,14 +250,12 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
payloads.put(notifier.getUuid().toString(), payload);
app.put("payloads", payloads);
app.put("deliver", System.currentTimeMillis() + 240000);
- app.put("queued", System.currentTimeMillis());
app.put("debug",true);
Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications")
.getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
- setup.getEntityIndex().refresh(app.getId());
Notification notification = app.getEntityManager().get(e.getUuid(),
Notification.class);
@@ -297,23 +267,17 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// delay until the scheduler has time to run
Thread.sleep(500);
- // verify Query for SCHEDULED state
- Query query = Query.fromEquals("state",
- Notification.State.SCHEDULED.toString());
- Results results = app.getEntityManager().searchCollection(
- app.getEntityManager().getApplicationRef(), "notifications", query);
- Entity entity = results.getEntitiesMap().get(notification.getUuid());
- assertNotNull(entity);
+ notification = app.getEntityManager().get(e.getUuid(), Notification.class);
+ assertEquals(Notification.State.SCHEDULED, notification.getState());
- setup.getEntityIndex().refresh(app.getId());
- try {
- e = app.testRequest(ServiceAction.DELETE, 1, "notifications",
- e.getUuid()).getEntity();
- }catch (Exception deleteException){
- LOG.error("Couldn't delete",deleteException);
- }
- app.getEntityManager().get(e.getUuid(), Notification.class);
+// try {
+// e = app.testRequest(ServiceAction.DELETE, 1, "notifications",
+// e.getUuid()).getEntity();
+// }catch (Exception deleteException){
+// LOG.error("Couldn't delete",deleteException);
+// }
+// app.getEntityManager().get(e.getUuid(), Notification.class);
}
@Test
@@ -384,21 +348,22 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
}
}
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1113. todo: how can I mock this?")
@Test
public void badToken() throws Exception {
- // mock action (based on verified actual behavior) //
+ // test adapter doesn't currently support this behavior
+ if(!USE_REAL_CONNECTIONS){
+ return;
+ }
// create push notification //
-
- HashMap<String, Object> properties = new LinkedHashMap<String, Object>();
+ app.clear();
String payload = getPayload();
Map<String, String> payloads = new HashMap<String, String>(1);
payloads.put(notifier.getUuid().toString(), payload);
- properties.put("payloads", payloads);
- properties.put("queued", System.currentTimeMillis());
- properties.put("debug",true);
+ app.put("payloads", payloads);
+ app.put("queued", System.currentTimeMillis());
+ app.put("debug",true);
Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications")
.getEntity();
@@ -414,7 +379,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// perform push //
notification = notificationWaitForComplete(notification);
- checkStatistics(notification, 0, 1);
+
+ // Statistics are not accurate -- see https://issues.apache.org/jira/browse/USERGRID-1207
+ //checkStatistics(notification, 0, 1);
notification = (Notification) app.getEntityManager().get(notification)
.toTypedEntity();
@@ -513,14 +480,16 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
@Test
public void oneDeviceTwoNotifiers() throws Exception {
+ // This test should configure 2 notifiers on a device and ensure that we can send to one of them
+
// create a 2nd notifier //
- Object nameValue = "apNs2";
- Object environValue = "development";
+ Object notifierName1 = "apNs2";
+ Object environment1 = "development";
app.clear();
- app.put("name", nameValue);
+ app.put("name", notifierName1);
app.put("provider", PROVIDER);
- app.put("environment", environValue);
+ app.put("environment", environment1);
InputStream fis = getClass().getClassLoader().getResourceAsStream(
"pushtest_dev_recent.p12");
byte[] certBytes = IOUtils.toByteArray(fis);
@@ -528,68 +497,59 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
fis.close();
Entity e = app.testRequest(ServiceAction.POST, 1, "notifiers").getEntity();
- app.testRequest(ServiceAction.GET, 1, "notifiers", nameValue);
-
- setup.getEntityIndex().refresh(app.getId());
+ app.testRequest(ServiceAction.GET, 1, "notifiers", notifierName1);
Notifier notifier2 = app.getEntityManager().get(e.getUuid(), Notifier.class);
- assertEquals(notifier2.getName(), nameValue);
+ assertEquals(notifier2.getName(), notifierName1);
assertEquals(notifier2.getProvider(), PROVIDER);
- assertEquals(notifier2.getEnvironment(), environValue);
+ assertEquals(notifier2.getEnvironment(), environment1);
String key2 = notifier2.getName() + NOTIFIER_ID_POSTFIX;
device1.setProperty(key2, PUSH_TOKEN);
app.getEntityManager().update(device1);
+ setup.getEntityIndex().refresh(app.getId()); // need to refresh the index after an update
- setup.getEntityIndex().refresh(app.getId());
// create push notification //
-
app.clear();
String payload = getPayload();
Map<String, String> payloads = new HashMap<String, String>(1);
payloads.put(notifier.getUuid().toString(), payload);
- payloads.put(notifier2.getUuid().toString(), payload);
app.put("payloads", payloads);
- app.put("queued", System.currentTimeMillis());
app.put("debug",true);
- e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications").getEntity();
- app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
-
- setup.getEntityIndex().refresh(app.getId());
+ Entity notificationEntity = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(),
+ "notifications").getEntity();
+ app.testRequest(ServiceAction.GET, 1, "notifications", notificationEntity.getUuid());
- Notification notification = app.getEntityManager().get(e.getUuid(),
+ Notification notification = app.getEntityManager().get(notificationEntity.getUuid(),
Notification.class);
assertEquals(
notification.getPayloads().get(notifier.getUuid().toString()),
payload);
- ns.addDevice(notification, device1);
-
- setup.getEntityIndex().refresh(app.getId());
-
// perform push //
notification = notificationWaitForComplete(notification);
-
- setup.getEntityIndex().refresh(app.getId());
-
- checkReceipts(notification, 2);
+ checkReceipts(notification, 1);
}
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1113. todo: how can I mock this?")
@Test
public void badCertificate() throws Exception {
- // create an apns notifier with the wrong certificate //
+ // if we're not using real connections, then adding a notifier with bad cert is noop as certs don't exist
+ // for the test adapter
+ if(!USE_REAL_CONNECTIONS){
+ return;
+ }
+
+ // create an apns notifier with the wrong certificate //
app.clear();
app.put("name", "prod_apns");
app.put("provider", PROVIDER);
app.put("environment", "development");
- InputStream fis = getClass().getClassLoader().getResourceAsStream(
- "empty.p12");
+ InputStream fis = getClass().getClassLoader().getResourceAsStream("pushtest_dev_recent.p12");
byte[] certBytes = IOUtils.toByteArray(fis);
app.put("p12Certificate", certBytes);
fis.close();
@@ -598,19 +558,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
.getEntity();
notifier = app.getEntityManager().get(e.getUuid(), Notifier.class);
- // mock error (based on verified actual behavior) //
- if (!USE_REAL_CONNECTIONS) {
-// ns.providerAdapters.put("apple",
-// new MockSuccessfulProviderAdapter() {
-// @Override
-// public void testConnection(Notifier notifier)
-// throws ConnectionException {
-// Exception e = new SocketException(
-// "Connection closed by remote host");
-// throw new ConnectionException(e.getMessage(), e);
-// }
-// });
- }
// create push notification //
@@ -631,10 +578,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification.getPayloads().get(notifier.getUuid().toString()),
payload);
-// ns.addDevice(notification, device1);
-
// perform push //
-
try {
notificationWaitForComplete(notification);
fail("testConnection() should have failed");
@@ -650,13 +594,12 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
assertNotNull(entity);
}
- @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1113. todo: how can I mock this?")
@Test
public void inactiveDeviceUpdate() throws Exception {
- // mock action (based on verified actual behavior) //
+ // test adapter doesn't currently support this
if (!USE_REAL_CONNECTIONS) {
-
+ return;
}
// create push notification //
@@ -696,70 +639,42 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
}
@Test
- public void deviceTest() throws Exception{
- app.clear();
- Entity e = app.testRequest(ServiceAction.POST, 1, "users",user2.getUuid(),"devices",device1.getUuid()).getEntity();
- app.clear();
- e = app.testRequest(ServiceAction.POST, 1, "users",user1.getUuid(),"devices",device1.getUuid()).getEntity();
- app.clear();
- e = app.testRequest(ServiceAction.POST, 1, "users",user1.getUuid(),"devices",device2.getUuid()).getEntity();
+ public void singleUserMultipleDevices() throws Exception{
+
+ app.testRequest(ServiceAction.POST, 1, "users",user1.getUuid(),"devices",device1.getUuid()).getEntity();
+ app.testRequest(ServiceAction.POST, 1, "users",user1.getUuid(),"devices",device2.getUuid()).getEntity();
List device1Users = app.getEntityManager().getCollection(device1,"users",null,100, Query.Level.REFS,false).getEntities();
assertEquals(device1Users.size(),1);
List user1Devices = app.getEntityManager().getCollection(user1,"devices",null,100, Query.Level.REFS,false).getEntities();
assertEquals(user1Devices.size(),2);
- app.clear();
- e = app.testRequest(ServiceAction.POST, 1, "users",user1.getUuid(),"devices",device2.getUuid()).getEntity();
- user1Devices = app.getEntityManager().getCollection(user1,"devices",null,100, Query.Level.REFS,false).getEntities();
- assertEquals(user1Devices.size(),2);
- // create push notification //
- setup.getEntityIndex().refresh(app.getId());
- // give queue manager a query for loading 100 devices from an application (why?)
app.clear();
// create a "hello world" notification
String payload = getPayload();
Map<String, String> payloads = new HashMap<String, String>(1);
- payloads.put(notifier.getName().toString(), payload);
+ payloads.put(notifier.getName(), payload);
app.put("payloads", payloads);
- app.put("queued", System.currentTimeMillis());
app.put("debug",true);
// post notification to service manager
- e = app.testRequest(ServiceAction.POST, 1,"users",user1.getUuid(), "notifications").getEntity();
-
+ Entity e = app.testRequest(ServiceAction.POST, 1,"users",user1.getUuid(), "notifications").getEntity();
// ensure notification it was created
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
// ensure notification has expected name
Notification notification = app.getEntityManager().get(e.getUuid(), Notification.class);
assertEquals(
- notification.getPayloads().get(notifier.getName().toString()),
+ notification.getPayloads().get(notifier.getName()),
payload);
- // verify Query for CREATED state
- Query query = Query.fromEquals("state", Notification.State.STARTED.toString());
- Results results = app.getEntityManager().searchCollection(
- app.getEntityManager().getApplicationRef(), "notifications", query);
- Entity entity = results.getEntitiesMap().get(notification.getUuid());
- //assertNotNull(entity);
-
// perform push //
-
notification = notificationWaitForComplete(notification);
-
- setup.getEntityIndex().refresh(app.getId());
-
- // verify Query for FINISHED state
- query = Query.fromEquals("state", Notification.State.FINISHED.toString());
- results = app.getEntityManager().searchCollection(app.getEntityManager().getApplicationRef(),
- "notifications", query);
- entity = results.getEntitiesMap().get(notification.getUuid());
- assertNotNull(entity);
-
checkReceipts(notification, 2);
- checkStatistics(notification, 2, 0);
+
+ // Statistics are not accurate. See - https://issues.apache.org/jira/browse/USERGRID-1207
+ //checkStatistics(notification, 2, 0);
}
@@ -814,46 +729,49 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// check receipts //
checkReceipts(notification, NUM_DEVICES);
-// checkStatistics(notification, NUM_DEVICES, 0);
+
+ // Statistics are not accurate. See - https://issues.apache.org/jira/browse/USERGRID-1207
+ // checkStatistics(notification, NUM_DEVICES, 0);
}
@Test
public void testDeleteNotification() throws Exception {
// create push notification //
- setup.getEntityIndex().refresh(app.getId());
app.clear();
-
String payload = getPayload();
-
Map<String, String> payloads = new HashMap<String, String>(1);
- payloads.put(notifier.getName().toString(), payload);
+ payloads.put(notifier.getName(), payload);
app.put("payloads", payloads);
- app.put("queued", System.currentTimeMillis());
app.put("debug", true);
- app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time
- Entity sentNotification = app.testRequest(ServiceAction.POST, 1, "notifications")
+ // stop the queue listener to it can't process the notification
+ listener.stop();
+ Entity sentNotification = app.testRequest(ServiceAction.POST, 1, "devices",device1.getUuid(), "notifications")
.getEntity();
- Entity fetchedNotification = app.testRequest(ServiceAction.GET, 1, "notifications",
- sentNotification.getUuid()).getEntity();
-
-
// can't delete before it's finished
try {
- app.testRequest(ServiceAction.DELETE, 1, "notifications", fetchedNotification.getUuid());
+ app.testRequest(ServiceAction.DELETE, 1, "notifications", sentNotification.getUuid());
} catch (Exception e) {
assertEquals(e.getClass(), ForbiddenServiceOperationException.class);
}
+ // start the queue listener and send another notification that should complete properly
+ listener.start();
+ app.clear();
+ app.put("payloads", payloads);
+ app.put("debug", true);
+ Entity sentNotification1 = app.testRequest(ServiceAction.POST, 1, "devices",device1.getUuid(), "notifications")
+ .getEntity();
+ Entity fetchedNotification = app.testRequest(ServiceAction.GET, 1, "notifications",
+ sentNotification1.getUuid()).getEntity();
Notification notification = app.getEntityManager().get(fetchedNotification.getUuid(),
Notification.class);
// perform push //
notification = notificationWaitForComplete(notification);
- setup.getEntityIndex().refresh(app.getId());
try {
notification = app.getEntityManager().get(notification.getUuid(), Notification.class);
@@ -870,8 +788,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ApnsPayloadBuilder builder = new ApnsPayloadBuilder();
builder.setAlertBody("Hello, World!");
builder.setSoundFileName("chime");
- String payload = builder.buildWithDefaultMaximumLength();
- return payload;
+ return builder.buildWithDefaultMaximumLength();
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
deleted file mode 100644
index 67c1ed0..0000000
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
+++ /dev/null
@@ -1,85 +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.apache.usergrid.services.notifications.gcm;
-
-import org.apache.usergrid.persistence.entities.Notification;
-import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.services.notifications.ProviderAdapter;
-import org.apache.usergrid.services.notifications.TaskTracker;
-
-import org.apache.usergrid.services.ServicePayload;
-
-public class MockSuccessfulProviderAdapter implements ProviderAdapter {
-
- private static ProviderAdapter realProviderAdapter;
-
-
-
- public MockSuccessfulProviderAdapter() {
- }
-
- @Override
- public void testConnection() throws Exception {
- }
-
- @Override
- public String translatePayload(Object payload) throws Exception {
- return payload.toString();
- }
-
-
-
- @Override
- public void validateCreateNotifier(ServicePayload payload) throws Exception {
- }
-
- @Override
- public void stop() {
-
- }
-
- @Override
- public Notifier getNotifier() {
- return null;
- }
-
- @Override
- public void doneSendingNotifications() throws Exception {
- }
-
- @Override
- public void removeInactiveDevices() throws Exception {
-
- }
-
- @Override
- public void sendNotification(String providerId,
- Object payload, Notification notification, final TaskTracker tracker)
- throws Exception {
- new Thread() {
- @Override
- public void run() {
- try {
- tracker.completed();
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
- }.start();
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/resources/pushtest_dev.p12
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/pushtest_dev.p12 b/stack/services/src/test/resources/pushtest_dev.p12
deleted file mode 100644
index b4373a2..0000000
Binary files a/stack/services/src/test/resources/pushtest_dev.p12 and /dev/null differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/858c750c/stack/services/src/test/resources/pushtest_prod.p12
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/pushtest_prod.p12 b/stack/services/src/test/resources/pushtest_prod.p12
deleted file mode 100644
index e6d4690..0000000
Binary files a/stack/services/src/test/resources/pushtest_prod.p12 and /dev/null differ
[5/5] usergrid git commit: Fix issues where cert stream was being
used incorrectly. Add non-apple valid cert for testing notifier creation
(which tests the certificate utils).
Posted by md...@apache.org.
Fix issues where cert stream was being used incorrectly. Add non-apple valid cert for testing notifier creation (which tests the certificate utils).
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2455b6a6
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2455b6a6
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2455b6a6
Branch: refs/heads/master
Commit: 2455b6a652520a32b1d520c6efd2611a97394749
Parents: 61c57c2
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Jan 12 13:13:41 2016 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Jan 12 13:13:41 2016 -0800
----------------------------------------------------------------------
.../notifiers/NotifierResource.java | 13 ++++---
.../notifiers/NotifiersResource.java | 12 ++++--
.../usergrid/rest/utils/CertificateUtils.java | 4 +-
.../applications/notifiers/NotifiersIT.java | 37 ++++++++++++++-----
.../resources/valid_non_apple_2036_01_07.p12 | Bin 0 -> 2661 bytes
5 files changed, 46 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2455b6a6/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
index 21d3d73..4e4a3b1 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
@@ -81,12 +81,16 @@ public class NotifierResource extends ServiceResource {
InputStream is = null;
Map<String, Object> certAttributes = null;
String filename = null;
+ byte[] certBytes = null;
if (multiPart.getField("p12Certificate") != null) {
filename = multiPart.getField("p12Certificate").getContentDisposition().getFileName();
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
- certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
+ if (is != null) {
+ certBytes = IOUtils.toByteArray(is);
+ certAttributes = CertificateUtils.getCertAtrributes(certBytes, certPassword);
+ }
}else{
- throw new IllegalArgumentException("p12Certificate data cannot be empty");
+ throw new IllegalArgumentException("Certificate is invalid .p12 file or incorrect certificatePassword");
}
// check to see if the certificate is valid
@@ -99,10 +103,9 @@ public class NotifierResource extends ServiceResource {
certProps.put("provider", provider);
certProps.put("environment", "production");
certProps.put("certificatePassword", certPassword);
- if (is != null) {
- byte[] certBytes = IOUtils.toByteArray(is);
+
+ if(certBytes != null && certBytes.length > 0 ){
certProps.put("p12Certificate", certBytes);
- is.close();
}
HashMap<String, Object> certInfo = new LinkedHashMap<String, Object>();
if (certAttributes != null){
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2455b6a6/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
index bd02c35..d7ce1e5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
@@ -127,12 +127,16 @@ public class NotifiersResource extends ServiceResource {
InputStream is = null;
Map<String, Object> certAttributes = null;
String filename = null;
+ byte[] certBytes = null;
if (multiPart.getField("p12Certificate") != null) {
filename = multiPart.getField("p12Certificate").getContentDisposition().getFileName();
is = multiPart.getField("p12Certificate").getEntityAs(InputStream.class);
- certAttributes = CertificateUtils.getCertAtrributes(is, certPassword);
+ if (is != null) {
+ certBytes = IOUtils.toByteArray(is);
+ certAttributes = CertificateUtils.getCertAtrributes(certBytes, certPassword);
+ }
}else{
- throw new IllegalArgumentException("p12Certificate password cannot be empty or null.");
+ throw new IllegalArgumentException("Certificate is invalid .p12 file or incorrect certificatePassword");
}
// check to see if the certificate is valid
@@ -147,8 +151,8 @@ public class NotifiersResource extends ServiceResource {
certProps.put("provider", provider);
certProps.put("environment", environment);
certProps.put("certificatePassword", certPassword);
- if (is != null) {
- byte[] certBytes = IOUtils.toByteArray(is);
+
+ if(certBytes != null && certBytes.length > 0 ){
certProps.put("p12Certificate", certBytes);
}
HashMap<String, Object> certInfo = new LinkedHashMap<String, Object>();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2455b6a6/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
index 6f4be92..5d2e43b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CertificateUtils.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.rest.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
@@ -35,7 +36,7 @@ public class CertificateUtils {
private static final String APPLE_TOPIC_OID = "1.2.840.113635.100.6.3.6";
- public static Map<String, Object> getCertAtrributes(InputStream stream, String certPassword){
+ public static Map<String, Object> getCertAtrributes(byte[] certBytes, String certPassword){
if(certPassword == null){
certPassword = ""; // if there is no password, pass in empty string
@@ -48,6 +49,7 @@ public class CertificateUtils {
Map<String,Object> attributes = new HashMap<>(1);
try{
KeyStore p12 = KeyStore.getInstance("pkcs12");
+ InputStream stream = new ByteArrayInputStream(certBytes);
p12.load(stream, certPassword.toCharArray());
Enumeration aliases = p12.aliases();
while(aliases.hasMoreElements()){
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2455b6a6/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
index a866e23..acbbb25 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/notifiers/NotifiersIT.java
@@ -39,38 +39,56 @@ public class NotifiersIT extends AbstractRestIT {
private static final Logger logger = LoggerFactory.getLogger( NotifiersIT.class );
- //private static final String VALID_CERT_FILE = "apple_push_valid_nocommit.p12";
+ private static final String VALID_CERT_NON_APPLE = "valid_non_apple_2036_01_07.p12";
+ private static final String VALID_CERT_APPLE = "valid_apple_2017_01_12.p12";
private static final String INVALID_CERT_FILE = "pushtest_dev_recent.p12";
- private static byte[] validCertBytes;
+ private static byte[] validCertBytesApple;
+ private static byte[] validCertBytesNonApple;
private static byte[] invalidCertBytes;
@BeforeClass
public static void setup() throws IOException {
- //InputStream validCertStream = NotifiersIT.class.getClassLoader().getResourceAsStream(VALID_CERT_FILE);
+ //InputStream validCertStreamApple = NotifiersIT.class.getClassLoader().getResourceAsStream(VALID_CERT_APPLE);
+ InputStream validCertStreamNonApple = NotifiersIT.class.getClassLoader().getResourceAsStream(VALID_CERT_NON_APPLE);
InputStream invalidCertStream = NotifiersIT.class.getClassLoader().getResourceAsStream(INVALID_CERT_FILE);
- //validCertBytes = IOUtils.toByteArray(validCertStream);
+ //validCertBytesApple = IOUtils.toByteArray(validCertStreamApple);
+ validCertBytesNonApple = IOUtils.toByteArray(validCertStreamNonApple);
invalidCertBytes = IOUtils.toByteArray(invalidCertStream);
- //validCertStream.close();
+ //validCertStreamApple.close();
+ validCertStreamNonApple.close();
invalidCertStream.close();
}
- @Ignore("Pending valid certificate being committed to the source code.")
@Test
- public void createAppleNotifierValidCertificate() {
+ public void createNotifierValidCertificateNonApple() {
+
+ FormDataMultiPart form = new FormDataMultiPart()
+ .field("name", "validNotifierNonAppleCert")
+ .field("environment", "development")
+ .field("provider", "apple")
+ .field( "p12Certificate", validCertBytesNonApple, MediaType.MULTIPART_FORM_DATA_TYPE );
+
+ ApiResponse postResponse = pathResource( getOrgAppPath( "notifiers" )).post( form );
+ assertNotNull("certInfo should not be null", postResponse.getEntities().get(0).get("certInfo"));
+
+ }
+
+ @Ignore("Pending valid certificate from Apple committed to the source code or alternate way of specifying.")
+ @Test
+ public void createAppleNotifierValidCertificate() {
FormDataMultiPart form = new FormDataMultiPart()
.field("name", "validAppleNotifier")
.field("environment", "development")
.field("provider", "apple")
- .field( "p12Certificate", validCertBytes, MediaType.MULTIPART_FORM_DATA_TYPE );
+ .field( "p12Certificate", validCertBytesApple, MediaType.MULTIPART_FORM_DATA_TYPE );
ApiResponse postResponse = pathResource( getOrgAppPath( "notifiers" )).post( form );
-
assertNotNull("certInfo should not be null", postResponse.getEntities().get(0).get("certInfo"));
}
@@ -78,7 +96,6 @@ public class NotifiersIT extends AbstractRestIT {
@Test
public void createAppleNotifierInvalidCertificate() {
-
FormDataMultiPart form = new FormDataMultiPart()
.field("name", "validAppleNotifier")
.field("environment", "development")
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2455b6a6/stack/rest/src/test/resources/valid_non_apple_2036_01_07.p12
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/valid_non_apple_2036_01_07.p12 b/stack/rest/src/test/resources/valid_non_apple_2036_01_07.p12
new file mode 100644
index 0000000..8fc41a5
Binary files /dev/null and b/stack/rest/src/test/resources/valid_non_apple_2036_01_07.p12 differ