1 package org.springframework.security.oauth2.client.resource;
2
3 import java.util.List;
4
5 import org.springframework.security.oauth2.common.AuthenticationScheme;
6 import org.springframework.security.oauth2.common.OAuth2AccessToken;
7 import org.springframework.util.StringUtils;
8
9
10
11
12
13 public class BaseOAuth2ProtectedResourceDetails implements OAuth2ProtectedResourceDetails {
14
15 private String id;
16
17 private String grantType = "unsupported";
18
19 private String clientId;
20
21 private String accessTokenUri;
22
23 private List<String> scope;
24
25 private String clientSecret;
26
27 private AuthenticationScheme clientAuthenticationScheme = AuthenticationScheme.header;
28
29 private AuthenticationScheme authorizationScheme = AuthenticationScheme.header;
30
31 private String tokenName = OAuth2AccessToken.ACCESS_TOKEN;
32
33 public String getId() {
34 return id;
35 }
36
37 public void setId(String id) {
38 this.id = id;
39 }
40
41 public String getClientId() {
42 return clientId;
43 }
44
45 public void setClientId(String clientId) {
46 this.clientId = clientId;
47 }
48
49 public String getAccessTokenUri() {
50 return accessTokenUri;
51 }
52
53 public void setAccessTokenUri(String accessTokenUri) {
54 this.accessTokenUri = accessTokenUri;
55 }
56
57 public boolean isScoped() {
58 return scope != null && !scope.isEmpty();
59 }
60
61 public List<String> getScope() {
62 return scope;
63 }
64
65 public void setScope(List<String> scope) {
66 this.scope = scope;
67 }
68
69 public boolean isAuthenticationRequired() {
70 return StringUtils.hasText(clientId) && clientAuthenticationScheme != AuthenticationScheme.none;
71 }
72
73 public String getClientSecret() {
74 return clientSecret;
75 }
76
77 public void setClientSecret(String clientSecret) {
78 this.clientSecret = clientSecret;
79 }
80
81 public AuthenticationScheme getClientAuthenticationScheme() {
82 return clientAuthenticationScheme;
83 }
84
85 public void setClientAuthenticationScheme(AuthenticationScheme clientAuthenticationScheme) {
86 this.clientAuthenticationScheme = clientAuthenticationScheme;
87 }
88
89 public boolean isClientOnly() {
90 return false;
91 }
92
93 public AuthenticationScheme getAuthenticationScheme() {
94 return authorizationScheme;
95 }
96
97 public void setAuthenticationScheme(AuthenticationScheme authorizationScheme) {
98 this.authorizationScheme = authorizationScheme;
99 }
100
101 public String getTokenName() {
102 return tokenName;
103 }
104
105 public void setTokenName(String tokenName) {
106 this.tokenName = tokenName;
107 }
108
109 public String getGrantType() {
110 return grantType;
111 }
112
113 public void setGrantType(String grantType) {
114 this.grantType = grantType;
115 }
116
117 @Override
118 public boolean equals(Object o) {
119 if (this == o) {
120 return true;
121 }
122 if (!(o instanceof BaseOAuth2ProtectedResourceDetails)) {
123 return false;
124 }
125
126 BaseOAuth2ProtectedResourceDetails that = (BaseOAuth2ProtectedResourceDetails) o;
127 return !(id != null ? !id.equals(that.id) : that.id != null);
128
129 }
130
131 @Override
132 public int hashCode() {
133 return id != null ? id.hashCode() : 0;
134 }
135
136 }