View Javadoc

1   /**
2    *       Copyright 2010 Newcastle University
3    *
4    *          http://research.ncl.ac.uk/smart/
5    *
6    * Licensed to the Apache Software Foundation (ASF) under one or more
7    * contributor license agreements.  See the NOTICE file distributed with
8    * this work for additional information regarding copyright ownership.
9    * The ASF licenses this file to You under the Apache License, Version 2.0
10   * (the "License"); you may not use this file except in compliance with
11   * the License.  You may obtain a copy of the License at
12   *
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   */
21  package org.apache.amber.oauth2.common.domain.credentials;
22  
23  import java.lang.Long;import java.lang.Object;import java.lang.Override;import java.lang.String; /**
24   *
25   *
26   *
27   */
28  public class BasicCredentials implements Credentials {
29  
30  
31      private String clientId;
32      private String clientSecret;
33      private Long issuedAt;
34      private Long expiresIn;
35  
36      BasicCredentials() {
37  
38      }
39  
40      public BasicCredentials(String clientId, String clientSecret, Long issuedAt, Long expiresIn) {
41          this.clientId = clientId;
42          this.clientSecret = clientSecret;
43          this.issuedAt = issuedAt;
44          this.expiresIn = expiresIn;
45      }
46  
47      @Override
48      public String getClientId() {
49          return clientId;
50      }
51  
52      @Override
53      public String getClientSecret() {
54          return clientSecret;
55      }
56  
57      @Override
58      public Long getIssuedAt() {
59          return issuedAt;
60      }
61  
62      @Override
63      public Long getExpiresIn() {
64          return expiresIn;
65      }
66  
67      public void setClientId(String clientId) {
68          this.clientId = clientId;
69      }
70  
71      public void setClientSecret(String clientSecret) {
72          this.clientSecret = clientSecret;
73      }
74  
75      public void setIssuedAt(Long issuedAt) {
76          this.issuedAt = issuedAt;
77      }
78  
79      public void setExpiresIn(Long expiresIn) {
80          this.expiresIn = expiresIn;
81      }
82  
83      @Override
84      public boolean equals(Object o) {
85          if (this == o) {
86              return true;
87          }
88          if (o == null || getClass() != o.getClass()) {
89              return false;
90          }
91  
92          BasicCredentials that = (BasicCredentials)o;
93  
94          if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) {
95              return false;
96          }
97          if (clientSecret != null ? !clientSecret.equals(that.clientSecret) : that.clientSecret != null) {
98              return false;
99          }
100         if (expiresIn != null ? !expiresIn.equals(that.expiresIn) : that.expiresIn != null) {
101             return false;
102         }
103         if (issuedAt != null ? !issuedAt.equals(that.issuedAt) : that.issuedAt != null) {
104             return false;
105         }
106 
107         return true;
108     }
109 
110     @Override
111     public int hashCode() {
112         int result = clientId != null ? clientId.hashCode() : 0;
113         result = 31 * result + (clientSecret != null ? clientSecret.hashCode() : 0);
114         result = 31 * result + (issuedAt != null ? issuedAt.hashCode() : 0);
115         result = 31 * result + (expiresIn != null ? expiresIn.hashCode() : 0);
116         return result;
117     }
118 }