1 package org.springframework.security.oauth2.provider;
2
3 import java.util.Collection;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import org.springframework.security.oauth2.common.util.OAuth2Utils;
8 import org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint;
9 import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
10
11
12
13
14
15
16
17
18
19
20
21
22
23 @SuppressWarnings("serial")
24 public class TokenRequest extends BaseRequest {
25
26 private String grantType;
27
28
29
30
31 protected TokenRequest() {
32 }
33
34
35
36
37
38
39
40
41
42 public TokenRequest(Map<String, String> requestParameters, String clientId, Collection<String> scope,
43 String grantType) {
44 setClientId(clientId);
45 setRequestParameters(requestParameters);
46 setScope(scope);
47 this.grantType = grantType;
48 }
49
50 public String getGrantType() {
51 return grantType;
52 }
53
54 public void setGrantType(String grantType) {
55 this.grantType = grantType;
56 }
57
58 public void setClientId(String clientId) {
59 super.setClientId(clientId);
60 }
61
62
63
64
65
66
67
68
69
70 public void setScope(Collection<String> scope) {
71 super.setScope(scope);
72 }
73
74
75
76
77
78
79
80
81
82 public void setRequestParameters(Map<String, String> requestParameters) {
83 super.setRequestParameters(requestParameters);
84 }
85
86 public OAuth2Request createOAuth2Request(ClientDetails client) {
87 Map<String, String> requestParameters = getRequestParameters();
88 HashMap<String, String> modifiable = new HashMap<String, String>(requestParameters);
89
90 modifiable.remove("password");
91 modifiable.remove("client_secret");
92
93 modifiable.put("grant_type", grantType);
94 return new OAuth2Request(modifiable, client.getClientId(), client.getAuthorities(), true, this.getScope(),
95 client.getResourceIds(), null, null, null);
96 }
97
98 }