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

Commit 3901d15

Browse files
authored
Merge pull request #1219 from stormpath/issue/1174
Issue/1174
2 parents 0387fd0 + 82f1de0 commit 3901d15

File tree

82 files changed

+3403
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3403
-22
lines changed

examples/spring-boot-default/src/main/java/com/stormpath/spring/boot/examples/HelloController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class HelloController {
3232
@Autowired
3333
private HelloService helloService;
3434

35+
@Autowired
36+
AccountResolver accountResolver;
37+
3538
@RequestMapping("/")
3639
String home(HttpServletRequest request) {
3740
return "home";
@@ -40,7 +43,7 @@ String home(HttpServletRequest request) {
4043
@RequestMapping("/restricted")
4144
String restricted(HttpServletRequest request, Model model) {
4245
String msg = helloService.sayHello(
43-
AccountResolver.INSTANCE.getAccount(request)
46+
accountResolver.getAccount(request)
4447
);
4548
model.addAttribute("msg", msg);
4649
return "restricted";

examples/spring-boot-webmvc-angular/src/main/java/com/stormpath/spring/boot/examples/ProfileController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.stormpath.sdk.account.Account;
1919
import com.stormpath.sdk.servlet.account.AccountResolver;
20+
import org.springframework.beans.factory.annotation.Autowired;
2021
import org.springframework.stereotype.Controller;
2122
import org.springframework.web.bind.annotation.RequestBody;
2223
import org.springframework.web.bind.annotation.RequestMapping;
@@ -30,10 +31,13 @@
3031
@Controller
3132
public class ProfileController {
3233

34+
@Autowired
35+
AccountResolver accountResolver;
36+
3337
@RequestMapping(path = "/profile", method = POST)
3438
public void profile(HttpServletRequest req, HttpServletResponse res, @RequestBody Map<String, String> params) {
3539

36-
Account account = AccountResolver.INSTANCE.getAccount(req);
40+
Account account = accountResolver.getAccount(req);
3741

3842
if (account != null) {
3943
account.setGivenName(params.get("givenName"));

examples/spring-boot-webmvc/src/main/java/com/stormpath/spring/boot/examples/HelloController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.stormpath.sdk.account.Account;
1919
import com.stormpath.sdk.servlet.account.AccountResolver;
20+
import org.springframework.beans.factory.annotation.Autowired;
2021
import org.springframework.stereotype.Controller;
2122
import org.springframework.ui.Model;
2223
import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,12 +27,15 @@
2627
@Controller
2728
public class HelloController {
2829

30+
@Autowired
31+
AccountResolver accountResolver;
32+
2933
@RequestMapping("/")
3034
public String home(HttpServletRequest request, Model model) {
3135

3236
String name = "World";
3337

34-
Account account = AccountResolver.INSTANCE.getAccount(request);
38+
Account account = accountResolver.getAccount(request);
3539
if (account != null) {
3640
name = account.getGivenName();
3741
model.addAttribute(account);

examples/spring-security-spring-boot-webmvc/src/main/java/com/stormpath/spring/boot/examples/HelloController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ public class HelloController {
3333
@Autowired
3434
private HelloService helloService;
3535

36+
@Autowired
37+
AccountResolver accountResolver;
38+
3639
@RequestMapping("/")
3740
public String home(HttpServletRequest request, Model model) {
3841

3942
String name = "World";
4043

41-
Account account = AccountResolver.INSTANCE.getAccount(request);
44+
Account account = accountResolver.getAccount(request);
4245
if (account != null) {
4346
name = account.getGivenName();
4447
model.addAttribute(account);
@@ -51,7 +54,7 @@ public String home(HttpServletRequest request, Model model) {
5154

5255
@RequestMapping("/restricted")
5356
String restricted(HttpServletRequest request, Model model) {
54-
Account account = AccountResolver.INSTANCE.getAccount(request);
57+
Account account = accountResolver.getAccount(request);
5558
String msg = helloService.sayHello(account);
5659
model.addAttribute("msg", msg);
5760

examples/spring-security-webmvc/src/main/java/com/stormpath/spring/examples/HelloController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ public class HelloController {
3333
@Autowired
3434
private HelloService helloService;
3535

36+
@Autowired
37+
AccountResolver accountResolver;
38+
3639
@RequestMapping("/")
3740
ModelAndView home(HttpServletRequest request) {
3841

3942
String name = "World";
4043

41-
Account account = AccountResolver.INSTANCE.getAccount(request);
44+
Account account = accountResolver.getAccount(request);
4245
if (account != null) {
4346
name = account.getGivenName();
4447
}
@@ -50,7 +53,7 @@ ModelAndView home(HttpServletRequest request) {
5053

5154
@RequestMapping("/restricted")
5255
ModelAndView restricted(HttpServletRequest request) {
53-
String helloMessage = helloService.sayHello(AccountResolver.INSTANCE.getAccount(request));
56+
String helloMessage = helloService.sayHello(accountResolver.getAccount(request));
5457
ModelAndView mav = new ModelAndView("restricted");
5558
mav.addObject("message", helloMessage);
5659
return mav;

examples/spring-webmvc/src/main/java/com/stormpath/spring/examples/HelloController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.stormpath.sdk.account.Account;
1919
import com.stormpath.sdk.servlet.account.AccountResolver;
20+
import org.springframework.beans.factory.annotation.Autowired;
2021
import org.springframework.web.bind.annotation.RequestMapping;
2122
import org.springframework.web.bind.annotation.RestController;
2223
import org.springframework.web.servlet.ModelAndView;
@@ -26,12 +27,15 @@
2627
@RestController
2728
public class HelloController {
2829

30+
@Autowired
31+
AccountResolver accountResolver;
32+
2933
@RequestMapping("/")
3034
ModelAndView home(HttpServletRequest request) {
3135

3236
String name = "World";
3337

34-
Account account = AccountResolver.INSTANCE.getAccount(request);
38+
Account account = accountResolver.getAccount(request);
3539
if (account != null) {
3640
name = account.getGivenName();
3741
}

tutorials/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
<modules>
3232
<module>spring-boot</module>
33+
<module>spring</module>
3334
</modules>
3435

3536
<build>
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
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.controller;
217

318
import com.stormpath.sdk.application.Application;
4-
import com.stormpath.sdk.servlet.application.ApplicationResolver;
19+
import org.springframework.beans.factory.annotation.Autowired;
520
import org.springframework.web.bind.annotation.RequestMapping;
621
import org.springframework.web.bind.annotation.RestController;
722

@@ -10,9 +25,11 @@
1025
@RestController
1126
public class HelloController {
1227

28+
@Autowired
29+
Application app;
30+
1331
@RequestMapping("/")
1432
public String hello(HttpServletRequest req) {
15-
Application app = ApplicationResolver.INSTANCE.getApplication(req);
1633
return "Hello, " + app.getName();
1734
}
1835
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
package com.stormpath.tutorial.controller;
1717

1818
import com.stormpath.sdk.servlet.account.AccountResolver;
19+
import org.springframework.beans.factory.annotation.Autowired;
1920
import org.springframework.stereotype.Controller;
2021
import org.springframework.ui.Model;
22+
import org.springframework.util.Assert;
2123
import org.springframework.web.bind.annotation.RequestMapping;
2224

2325
import javax.servlet.http.HttpServletRequest;
@@ -28,6 +30,14 @@
2830
@Controller
2931
public class HelloController {
3032

33+
private AccountResolver accountResolver;
34+
35+
@Autowired
36+
public HelloController(AccountResolver accountResolver) {
37+
Assert.notNull(accountResolver);
38+
this.accountResolver = accountResolver;
39+
}
40+
3141
@RequestMapping("/")
3242
String home(HttpServletRequest req, Model model) {
3343
model.addAttribute("status", req.getParameter("status"));
@@ -36,7 +46,7 @@ String home(HttpServletRequest req, Model model) {
3646

3747
@RequestMapping("/restricted")
3848
String restricted(HttpServletRequest req) {
39-
if (AccountResolver.INSTANCE.getAccount(req) != null) {
49+
if (accountResolver.getAccount(req) != null) {
4050
return "restricted";
4151
}
4252

tutorials/spring-boot/02-spring-security-ftw/src/main/java/com/stormpath/tutorial/controller/HelloController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@
3131
@Controller
3232
public class HelloController {
3333

34+
private AccountResolver accountResolver;
3435
private HelloService helloService;
3536

3637
@Autowired
37-
public HelloController(HelloService helloService) {
38+
public HelloController(AccountResolver accountResolver, HelloService helloService) {
39+
Assert.notNull(accountResolver);
3840
Assert.notNull(helloService);
41+
this.accountResolver = accountResolver;
3942
this.helloService = helloService;
4043
}
4144

@@ -48,7 +51,7 @@ String home(HttpServletRequest req, Model model) {
4851
@RequestMapping("/restricted")
4952
String restricted(HttpServletRequest req, Model model) {
5053
String msg = helloService.sayHello(
51-
AccountResolver.INSTANCE.getAccount(req)
54+
accountResolver.getAccount(req)
5255
);
5356
model.addAttribute("msg", msg);
5457
return "restricted";

0 commit comments

Comments
 (0)