You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2018. It is now read-only.
This tutorial will take you from zero to a Stormpath enabled application featuring Spring Boot WebMVC and Spring Security integration.
6
+
This tutorial will take you from zero to a Stormpath enabled application featuring Spring #if($springboot)Boot#end WebMVC and Spring Security integration.
7
7
8
-
It should take about 30 minutes from start to finish. If you are looking for a bare bones intro to using Stormpath and
9
-
Spring Boot, check out the :doc:`quickstart`.
8
+
It should take about 30 minutes from start to finish. If you are looking for a bare bones intro to using |project|, check out the :doc:`quickstart`.
9
+
10
+
#if( $springboot )
10
11
11
12
If you've already gone through the quickstart, jump over to the :ref:`spring-boot-meet-stormpath` section.
12
13
@@ -15,6 +16,17 @@ Spring Boot, Spring Web MVC, Spring Security and the Thymeleaf templating engine
15
16
such as Spring Security, can easily be disabled through the use of properties or via annotations. (You'll see an example of disabling
16
17
Spring Security with properties in the :ref:`spring-boot-meet-stormpath` section).
17
18
19
+
#elseif( $spring )
20
+
21
+
If you've already gone through the quickstart, jump over to the :ref:`spring-meet-stormpath` section.
22
+
23
+
All of the code in the tutorial makes use of the ``stormpath-spring-security-webmvc`` integration. This integration has it all:
24
+
Spring, Spring Web MVC, Spring Security and the JSP templating engine - all integrated with Stormpath. Component features,
25
+
such as Spring Security, can easily be disabled through the use of properties or via annotations. (You'll see an example of disabling
26
+
Spring Security with properties in the :ref:`spring-meet-stormpath` section).
27
+
28
+
#end
29
+
18
30
Topics:
19
31
20
32
.. contents::
@@ -23,27 +35,32 @@ Topics:
23
35
24
36
.. include:: stormpath-setup.txt
25
37
26
-
For the rest of the tutorial, we will be referring to the tutorial code found in `tutorials/spring-boot <https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot>`_.
38
+
For the rest of the tutorial, we will be referring to the tutorial code found in #if($springboot)`tutorials/spring-boot`_ #elseif($spring)`tutorials/spring`_ #end.
39
+
27
40
28
41
Each of the tutorial sections is completely standalone and can be used as a starting point for your own applications.
29
42
30
-
For instance, if you wanted to build a Spring Boot WebMVC project, including Spring Security integrated with Stormpath, you
43
+
For instance, if you wanted to build a |project| project, including Spring Security integrated with Stormpath, you
cp -r <path to Stormpath sdk>/tutorials/spring-boot/03-spring-security-refined/*.
38
55
mvn clean package
39
-
java -jar target/*.jar
56
+
mvn spring-boot:run
40
57
41
58
.. _spring-boot-meet-stormpath:
42
59
43
60
Spring Boot: Meet Stormpath
44
61
---------------------------
45
62
46
-
Let's fire up a basic Spring Boot Web application. The code for this section can be found in `tutorials/spring-boot/00-the-basics<https://github.com/stormpath/stormpath-sdk-java/tree/master/tutorials/spring-boot/00-the-basics>`_.
63
+
Let's fire up a basic Spring Boot WebMVC application. The code for this section can be found in `tutorials/spring-boot/00-the-basics`_.
47
64
48
65
Note: This assumes you have your ``apiKey.properties`` file in the standard location: ``~/.stormpath/apiKey.properties``.
49
66
@@ -59,20 +76,19 @@ You should now be able to browse to `<http://localhost:${port}>`_ and see a welc
59
76
This application has just two code files and a properties file in it. Here's the structure:
60
77
61
78
.. code-block:: bash
62
-
:emphasize-lines: 9, 10
63
-
64
-
.
65
-
`-- src
66
-
`-- main
67
-
|-- java
68
-
|`-- com
69
-
|`-- stormpath
70
-
|`-- tutorial
71
-
||-- controller
72
-
||`-- HelloController.java
73
-
|`-- Application.java
74
-
`-- resources
75
-
`-- application.properties
79
+
:emphasize-lines: 7, 9
80
+
81
+
src
82
+
└── main
83
+
├── java
84
+
│ └── com
85
+
│ └── stormpath
86
+
│ └── tutorial
87
+
│ ├── Application.java
88
+
│ └── controller
89
+
│ └── HelloController.java
90
+
└── resources
91
+
└── application.properties
76
92
77
93
``Application.java`` is a most basic Spring Boot application file with a ``main`` method and the ``@SpringBootApplication``
78
94
annotation:
@@ -88,23 +104,134 @@ annotation:
88
104
}
89
105
}
90
106
91
-
``HelloController.java`` is a little more interesting:
cp -r <path to Stormpath sdk>/tutorials/spring/03-spring-security-refined/*.
116
+
mvn clean package
117
+
mvn tomcat7:run
118
+
119
+
.. _spring-meet-stormpath:
120
+
121
+
Spring: Meet Stormpath
122
+
----------------------
123
+
124
+
Let's fire up a basic Spring WebMVC application. The code for this section can be found in `tutorials/spring/00-the-basics`_.
125
+
126
+
Note: This assumes you have your ``apiKey.properties`` file in the standard location: ``~/.stormpath/apiKey.properties``.
127
+
128
+
To build and run, do this:
129
+
130
+
.. code-block:: bash
131
+
132
+
mvn clean package
133
+
mvn tomcat7:run
134
+
135
+
You should now be able to browse to `<http://localhost:${port}>`_ and see a welcome message with your Stormpath application's name.
136
+
137
+
This application has just three code files, a properties file, and a web descriptor in it. Here's the structure:
138
+
139
+
.. code-block:: bash
140
+
:emphasize-lines: 7, 9, 11
141
+
142
+
src
143
+
└── main
144
+
├── java
145
+
│ └── com
146
+
│ └── stormpath
147
+
│ └── tutorial
148
+
│ ├── WebAppInitializer.java
149
+
│ ├── config
150
+
│ │ └── WebAppConfig.java
151
+
│ └── controller
152
+
│ └── HelloController.java
153
+
├── resources
154
+
│ └── application.properties
155
+
└── webapp
156
+
└── WEB-INF
157
+
└── web.xml
158
+
159
+
``WebAppInitializer.java`` is a basic Spring WebMVC application class. It overrides the ``onStartup`` method from the ``WebApplicationInitializer`` interface:
Here we have our first taste of Stormpath in action. On line 5 we are getting hold of the Stormpath application and on
107
-
line 6 we are obtaining its name for display.
234
+
On line 5 we are getting hold of the Stormpath Application and on line 9 we are obtaining its name for display.
108
235
109
236
For this example, we don't want Spring Security locking everything down, which is its default behavior. So, we will simply
110
237
disable it. That's where the ``application.properties`` files comes in:
@@ -665,3 +792,8 @@ write a REST API that makes use of Spring Security that has no web layer.
665
792
666
793
Take a look at the `javadocs </java/apidocs>`_ as well as the `other code examples <https://github.com/stormpath/stormpath-sdk-java/tree/master/examples>`_
667
794
for more information on all that the Stormpath Java SDK has to offer.
0 commit comments