1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.security.oauth.provider;
18
19 import org.springframework.security.authentication.AbstractAuthenticationToken;
20
21 import java.util.Map;
22
23
24
25
26
27
28 @SuppressWarnings("serial")
29 public class ConsumerAuthentication extends AbstractAuthenticationToken {
30
31 private final ConsumerDetails consumerDetails;
32 private final ConsumerCredentials consumerCredentials;
33 private final Map<String, String> oauthParameters;
34 private boolean signatureValidated = false;
35
36 public ConsumerAuthentication(ConsumerDetails consumerDetails, ConsumerCredentials consumerCredentials) {
37 super(consumerDetails.getAuthorities());
38 this.consumerDetails = consumerDetails;
39 this.consumerCredentials = consumerCredentials;
40 this.oauthParameters = null;
41 }
42
43 public ConsumerAuthentication(ConsumerDetails consumerDetails, ConsumerCredentials consumerCredentials, Map<String, String> oauthParams) {
44 super(consumerDetails.getAuthorities());
45 this.consumerDetails = consumerDetails;
46 this.consumerCredentials = consumerCredentials;
47 this.oauthParameters = oauthParams;
48 }
49
50
51
52
53
54
55
56 public Object getCredentials() {
57 return getConsumerCredentials();
58 }
59
60
61
62
63
64
65 public ConsumerCredentials getConsumerCredentials() {
66 return consumerCredentials;
67 }
68
69
70
71
72
73
74
75 public Object getPrincipal() {
76 return getConsumerDetails();
77 }
78
79
80
81
82
83
84 public ConsumerDetails getConsumerDetails() {
85 return consumerDetails;
86 }
87
88
89
90
91
92
93 public Map<String, String> getOAuthParameters() {
94 return oauthParameters;
95 }
96
97
98
99
100
101
102 public String getName() {
103 return getConsumerDetails() != null ? getConsumerDetails().getConsumerKey() : null;
104 }
105
106
107
108
109
110
111 public boolean isSignatureValidated() {
112 return signatureValidated;
113 }
114
115
116
117
118
119
120 public void setSignatureValidated(boolean signatureValidated) {
121 this.signatureValidated = signatureValidated;
122 }
123
124
125
126
127
128
129 @Override
130 public boolean isAuthenticated() {
131 return isSignatureValidated();
132 }
133
134
135
136
137
138
139 @Override
140 public void setAuthenticated(boolean authenticated) {
141 setSignatureValidated(authenticated);
142 }
143
144 }