Author: Joshua Wilson, Pedro Igor, Erik Jan De Wit, Daniel Bevenius
Level: Beginner
Technologies: REST, Unified Push Java Client, PicketLink
Summary: The push-contacts-mobile-picketlink-secured
quickstart shows how to develop a PicketLink secured CRUD application with push notification functionality.
Target Product: JBoss Unified Push
Versions: 1.0
Source: https://github.com/jboss-developer/jboss-mobile-quickstarts/
The push-contacts-mobile-picketlink-secured
quickstart demonstrates how to develop secured server-side applications with push functionality, centered around a CRUD contacts application. It creates a PicketLink secured Java EE 6 application using JAX-RS, CDI 1.0, EJB 3.1, JPA 2.0 and Bean Validation 1.0.
When the push-contacts-mobile-picketlink-secured
application is deployed, the push functionality enables the application to register with the running JBoss Unified Push Server OpenShift instance and send it push notification requests. The server-side application rest endpoints are secured with PicketLink and can only be accessed by client applications with authenticated users.
When contacts are created with the client contacts-mobile application, the contact information is relayed to the push-contacts-mobile-picketlink-secured
application. On receiving the contact infomation, this backend application sends a push notification request to the JBoss Unified Push Server OpenShift instance. The JBoss Unified Push Server OpenShift instance then routes a push notification containing details of the newly added contact to devices that are registered with the JBoss Unified Push Server OpenShift instance for the specific client application.
Note: This quickstart uses the following Jackson libraries that are a part of the JBoss EAP private API.
- org.codehaus.jackson.jackson-core-asl
- org.codehaus.jackson.jackson-mapper-asl
A public API will become available in a future EAP release and the private classes will be deprecated, but these classes continue to be maintained and available for the duration of the EAP 6.x release cycle.
This quickstart is designed to be built with Maven. It requires the JBoss Unified Push and JBoss EAP 6.3.0 Maven repositories.
You must have the JBoss Unified Push Maven repository available and Maven configured to use it. For more information, see the Configure Maven or the README distributed with the JBoss Unified Push Maven repository.
You must register the application with the JBoss Unified Push Server. This requires a running JBoss Unified Push Server OpenShift instance. For more information about deploying, configuring and using the JBoss Unified Push Server, see the JBoss Unified Push documentation and JBoss xPaaS Services for OpenShift.
- Log into the JBoss Unified Push Server OpenShift instance console.
- In the
Applications
view, clickCreate Application
. - In the
Name
andDescription
fields, type values for the application and clickCreate
. - When created, click the application name and make note of the
Server URL
,Application ID
, andMaster Secret
.
The project source code must be customized with the unique metadata assigned to the application by the JBoss Unified Push Server OpenShift instance.
-
Open quickstarts-config.json configuration file for editing.
-
Enter the
serverUrl
,pushApplicationId
andmasterSecret
parameters. -
Save the file.
-
Build the application
cd QUICKSTART_HOME/push-contacts-mobile/server/push-contacts-mobile-picketlink-secured mvn clean package
The JBoss Unified Push Server OpenShift instance must be running before the application is deployed to ensure that it successfully registers with the JBoss Unified Push Server on deployment.
-
Start JBoss EAP
For Linux: EAP_HOME/bin/standalone.sh For Windows: EAP_HOME\bin\standalone.bat
-
Build and deploy the packaged application
cd QUICKSTART_HOME/push-contacts-mobile/server/push-contacts-mobile-picketlink-secured mvn clean package jboss-as:deploy
This deploys QUICKSTART_HOME/push-contacts-mobile/server/push-contacts-mobile-picketlink-secured/target/jboss-push-contacts-mobile-picketlink-secured.war
to the running instance of the server.
Note: Adding "-b 0.0.0.0" to the above commands will allow external clients (phones, tablets, desktops, etc...) to connect through your local network. For example
For Linux: EAP_HOME/bin/standalone.sh -b 0.0.0.0
For Windows: EAP_HOME\bin\standalone.bat -b 0.0.0.0
You can create a new contact using any of the client applications.
Please follow the Build and Deploy the Quickstart
instructions in contacts-mobile-webapp which describe how to build, deploy, and access the web application.
For information on building and deploying any of the client application variants, see the READMEs distributed with these applications.
-
Make sure you have started the JBoss EAP server as described above.
-
When you are finished testing, type this command to undeploy the archive:
cd QUICKSTART_HOME/push-contacts-mobile/server/push-contacts-mobile-picketlink-secured mvn jboss-as:undeploy
Why cannot I enter a date in the birthdate field?
- Chrome has a bug in it.
- Use the arrow keys to change the date: up arrow key, tab to day, up arrow key, tab to year, up arrow key.
- Use the date picker: a large black down arrow between the up/down arrows and the big X on the right side.
- Firefox, IE, and Safari require strict formatting of YYYY-DD-MM, Note: It must be a dash and not a slash.
You can import this project into an IDE (JBoss Developer Studio, NetBeans or IntelliJ IDEA). If you are using JBoss Developer Studio you must import the project as a Maven project. If you are using NetBeans 6.8 or IntelliJ IDEA 9, then you can open the project as an existing project as both of these IDEs recognize Maven projects natively.
You can also start the server and deploy the quickstarts from JBoss Developer Studio. For more information , see the Get Started with JBoss Developer Studio.
If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.
mvn dependency:sources