Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit e17b675

Browse files
committed
updates per review by @mrioan
1 parent 642ba08 commit e17b675

File tree

24 files changed

+85
-31
lines changed

24 files changed

+85
-31
lines changed

tutorials/spring-boot/01-some-access-controls/src/main/java/com/stormpath/tutorial/controller/HelloController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class HelloController {
3232

3333
private AccountResolver accountResolver;
3434

35+
@Autowired
3536
public HelloController(AccountResolver accountResolver) {
3637
Assert.notNull(accountResolver);
3738
this.accountResolver = accountResolver;

tutorials/spring/00-the-basics/src/main/java/com/stormpath/tutorial/WebAppInitializer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.stormpath.tutorial;
1717

18+
import com.stormpath.sdk.servlet.filter.StormpathFilter;
1819
import com.stormpath.tutorial.config.WebAppConfig;
1920
import org.springframework.web.WebApplicationInitializer;
2021
import org.springframework.web.context.ContextLoaderListener;
@@ -46,9 +47,10 @@ public void onStartup(ServletContext sc) throws ServletException {
4647
dispatcher.setLoadOnStartup(1);
4748
dispatcher.addMapping("/");
4849

49-
FilterRegistration.Dynamic filter = sc.addFilter("stormpathFilter", new DelegatingFilterProxy());
50+
FilterRegistration.Dynamic stormpathFilter =
51+
sc.addFilter(StormpathFilter.DEFAULT_FILTER_NAME, DelegatingFilterProxy.class);
5052
EnumSet<DispatcherType> types =
51-
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
52-
filter.addMappingForUrlPatterns(types, false, "/*");
53+
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
54+
stormpathFilter.addMappingForUrlPatterns(types, false, "/*");
5355
}
5456
}

tutorials/spring/01-some-access-controls/src/main/java/com/stormpath/tutorial/WebAppInitializer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.stormpath.tutorial;
1717

18+
import com.stormpath.sdk.servlet.filter.StormpathFilter;
1819
import com.stormpath.tutorial.config.WebAppConfig;
1920
import org.springframework.web.WebApplicationInitializer;
2021
import org.springframework.web.context.ContextLoaderListener;
@@ -46,9 +47,10 @@ public void onStartup(ServletContext sc) throws ServletException {
4647
dispatcher.setLoadOnStartup(1);
4748
dispatcher.addMapping("/");
4849

49-
FilterRegistration.Dynamic filter = sc.addFilter("stormpathFilter", new DelegatingFilterProxy());
50+
FilterRegistration.Dynamic stormpathFilter =
51+
sc.addFilter(StormpathFilter.DEFAULT_FILTER_NAME, DelegatingFilterProxy.class);
5052
EnumSet<DispatcherType> types =
51-
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
52-
filter.addMappingForUrlPatterns(types, false, "/*");
53+
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
54+
stormpathFilter.addMappingForUrlPatterns(types, false, "/*");
5355
}
5456
}

tutorials/spring/01-some-access-controls/src/main/java/com/stormpath/tutorial/config/WebAppConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class WebAppConfig {
4545
private Client client; //can be used to interact with all things in your Stormpath tenant
4646

4747
/**
48-
* This bean and the @PropertySource annotation above allow you to configure Stormpath beans with properties
48+
* This bean and the @PropertySource annotation above allows you to configure Stormpath beans with properties
4949
* prefixed with {@code stormpath.}, i.e. {@code stormpath.application.href}, {@code stormpath.client.apiKey.file}, etc.
5050
*
5151
* <p>Combine this with Spring's Profile support to override property values based on specific runtime environments,

tutorials/spring/01-some-access-controls/src/main/webapp/WEB-INF/jsp/home.jsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
<c:when test="${account != null}">
5656
<h1>Hello, ${account.givenName}</h1>
5757
<form action="${pageContext.request.contextPath}/logout" method="post">
58-
<a href="/restricted" class="btn btn-primary">Restricted</a>
58+
<a href="${pageContext.request.contextPath}/restricted" class="btn btn-primary">Restricted</a>
5959
<input type="submit" class="btn btn-danger" value="Logout"/>
6060
</form>
6161
</c:when>
6262
<c:otherwise>
6363
<h1>Who are you?</h1>
64-
<a href="/restricted" class="btn btn-primary">Restricted</a>
64+
<a href="${pageContext.request.contextPath}/restricted" class="btn btn-primary">Restricted</a>
6565
</c:otherwise>
6666
</c:choose>
6767
</div>

tutorials/spring/01-some-access-controls/src/main/webapp/WEB-INF/jsp/restricted.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</div>
4646

4747
<h1>Hello, ${account.givenName}! You're allowed to see this page!</h1>
48-
<a href="/" class="btn btn-primary">Go Home</a>
48+
<a href="${pageContext.request.contextPath}/" class="btn btn-primary">Go Home</a>
4949

5050
</div>
5151
</div>

tutorials/spring/02-spring-security-ftw/src/main/java/com/stormpath/tutorial/WebAppInitializer.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2017 Stormpath, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.stormpath.tutorial;
217

318
import com.stormpath.sdk.servlet.filter.StormpathFilter;
@@ -36,7 +51,7 @@ public void onStartup(ServletContext sc) throws ServletException {
3651
//Stormpath Filter (after Spring Security)
3752
FilterRegistration.Dynamic stormpathFilter = sc.addFilter(StormpathFilter.DEFAULT_FILTER_NAME, DelegatingFilterProxy.class);
3853
EnumSet<DispatcherType> types =
39-
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
54+
EnumSet.of(DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
4055
stormpathFilter.addMappingForUrlPatterns(types, false, "/*");
4156
}
4257
}

tutorials/spring/02-spring-security-ftw/src/main/java/com/stormpath/tutorial/config/SpringSecurityWebAppConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class SpringSecurityWebAppConfig extends WebSecurityConfigurerAdapter {
3636
protected void configure(HttpSecurity http) throws Exception {
3737

3838
http
39-
.apply(stormpath())
40-
.and() // Starting with Spring Security 4.2 we do not need to explicitly apply the Stormpath configuration in Spring Boot but it is still required in Spring
39+
.apply(stormpath()) // Starting with Spring Security 4.2 we do not need to explicitly apply the Stormpath configuration in Spring Boot but it is still required in Spring
40+
.and()
4141
.authorizeRequests()
4242
.antMatchers("/restricted").fullyAuthenticated()
4343
.antMatchers("/**").permitAll()

tutorials/spring/02-spring-security-ftw/src/main/webapp/WEB-INF/jsp/error.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<h1>${errors.status}</h1>
4949
</div>
5050
<p class="lead text-muted">${errors.message}</p>
51-
<a href="/" class="btn btn-primary">Go Home</a>
51+
<a href="${pageContext.request.contextPath}/" class="btn btn-primary">Go Home</a>
5252
</div>
5353
</div>
5454
</div>

tutorials/spring/02-spring-security-ftw/src/main/webapp/WEB-INF/jsp/home.jsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
<c:when test="${account != null}">
5656
<h1>Hello, ${account.givenName}</h1>
5757
<form action="${pageContext.request.contextPath}/logout" method="post">
58-
<a href="/restricted" class="btn btn-primary">Restricted</a>
58+
<a href="${pageContext.request.contextPath}/restricted" class="btn btn-primary">Restricted</a>
5959
<input type="submit" class="btn btn-danger" value="Logout"/>
6060
</form>
6161
</c:when>
6262
<c:otherwise>
6363
<h1>Who are you?</h1>
64-
<a href="/restricted" class="btn btn-primary">Restricted</a>
64+
<a href="${pageContext.request.contextPath}/restricted" class="btn btn-primary">Restricted</a>
6565
</c:otherwise>
6666
</c:choose>
6767
</div>

0 commit comments

Comments
 (0)