View Javadoc
1   /*
2    * Copyright 2008-2009 Web Cohesion
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    *   https://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   */
16  
17  package org.springframework.security.oauth.provider;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import org.springframework.security.core.GrantedAuthority;
23  import org.springframework.security.oauth.common.signature.SignatureSecret;
24  
25  /**
26   * Base implementation for consumer details.
27   *
28   * @author Ryan Heaton
29   * @author Andrew McCall
30   */
31  @SuppressWarnings("serial")
32  public class BaseConsumerDetails implements ResourceSpecificConsumerDetails, ExtraTrustConsumerDetails {
33  
34    private String consumerKey;
35    private String consumerName;
36    private SignatureSecret signatureSecret;
37    private List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
38    private String resourceName;
39    private String resourceDescription;
40    private boolean requiredToObtainAuthenticatedToken = true;
41  
42    /**
43     * The consumer key.
44     *
45     * @return The consumer key.
46     */
47    public String getConsumerKey() {
48      return consumerKey;
49    }
50  
51    /**
52     * The consumer key.
53     *
54     * @param consumerKey The consumer key.
55     */
56    public void setConsumerKey(String consumerKey) {
57      this.consumerKey = consumerKey;
58    }
59  
60    /**
61     * The name of the consumer.
62     *
63     * @return The name of the consumer.
64     */
65    public String getConsumerName() {
66      return consumerName;
67    }
68  
69    /**
70     * The name of the consumer.
71     *
72     * @param consumerName The name of the consumer.
73     */
74    public void setConsumerName(String consumerName) {
75      this.consumerName = consumerName;
76    }
77  
78    /**
79     * The signature secret.
80     *
81     * @return The signature secret.
82     */
83    public SignatureSecret getSignatureSecret() {
84      return signatureSecret;
85    }
86  
87    /**
88     * The signature secret.
89     *
90     * @param signatureSecret The signature secret.
91     */
92    public void setSignatureSecret(SignatureSecret signatureSecret) {
93      this.signatureSecret = signatureSecret;
94    }
95  
96    /**
97     * The base authorities for this consumer.
98     *
99     * @return The base authorities for this consumer.
100    */
101   public List<GrantedAuthority> getAuthorities() {
102     return authorities;
103   }
104 
105   /**
106    * The base authorities for this consumer.
107    *
108    * @param authorities The base authorities for this consumer.
109    */
110   public void setAuthorities(List<GrantedAuthority> authorities) {
111     this.authorities = authorities;
112   }
113 
114   /**
115    * The name of the resource.
116    *
117    * @return The name of the resource.
118    */
119   public String getResourceName() {
120     return resourceName;
121   }
122 
123   /**
124    * The name of the resource.
125    *
126    * @param resourceName The name of the resource.
127    */
128   public void setResourceName(String resourceName) {
129     this.resourceName = resourceName;
130   }
131 
132   /**
133    * The description of the resource.
134    *
135    * @return The description of the resource.
136    */
137   public String getResourceDescription() {
138     return resourceDescription;
139   }
140 
141   /**
142    * The description of the resource.
143    *
144    * @param resourceDescription The description of the resource.
145    */
146   public void setResourceDescription(String resourceDescription) {
147     this.resourceDescription = resourceDescription;
148   }
149 
150   /**
151    * Whether this consumer is required to obtain an authenticated oauth token.
152    *
153    * @return Whether this consumer is required to obtain an authenticated oauth token.
154    */
155   public boolean isRequiredToObtainAuthenticatedToken() {
156     return requiredToObtainAuthenticatedToken;
157   }
158 
159   /**
160    * Whether this consumer is required to obtain an authenticated oauth token.
161    *
162    * @param requiredToObtainAuthenticatedToken Whether this consumer is required to obtain an authenticated oauth token.
163    */
164   public void setRequiredToObtainAuthenticatedToken(boolean requiredToObtainAuthenticatedToken) {
165     this.requiredToObtainAuthenticatedToken = requiredToObtainAuthenticatedToken;
166   }
167 }