fix oauth code
[ccsdk/features.git] / sdnr / wt / oauth-provider / oauth-core / src / main / java / org / onap / ccsdk / features / sdnr / wt / oauthprovider / data / UserTokenPayload.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.oauthprovider.data;
23
24 import java.util.List;
25
26 public class UserTokenPayload {
27
28     public static final String PROVIDERID_INTERNAL="Internal";
29
30     private List<String> roles;
31     private String preferredUsername;
32     private String givenName;
33     private String familyName;
34     private long exp;
35     private long iat;
36
37     private String providerId;
38
39     public long getExp() {
40         return exp;
41     }
42
43     public long getIat() {
44         return this.iat;
45     }
46
47     public void setPreferredUsername(String preferredUsername) {
48         this.preferredUsername = preferredUsername;
49     }
50
51     public void setGivenName(String givenName) {
52         this.givenName = givenName;
53     }
54
55     public void setFamilyName(String familyName) {
56         this.familyName = familyName;
57     }
58
59     public void setExp(long exp) {
60         this.exp = exp;
61     }
62
63     public void setIat(long iat) {
64         this.iat = iat;
65     }
66
67     public String getPreferredUsername() {
68         return preferredUsername;
69     }
70
71     public String getGivenName() {
72         return givenName;
73     }
74
75     public String getFamilyName() {
76         return familyName;
77     }
78
79     public List<String> getRoles() {
80         return this.roles;
81     }
82
83     public void setRoles(List<String> roles) {
84         this.roles = roles;
85     }
86
87     public void setProviderId(String providerId){ this.providerId = providerId;}
88
89     public  String getProviderId(){ return this.providerId;}
90
91     public static UserTokenPayload createInternal(String username, List<String> roles) {
92         UserTokenPayload data = new UserTokenPayload();
93         data.setPreferredUsername(username);
94         data.setRoles(roles);
95         data.setProviderId(PROVIDERID_INTERNAL);
96         return data;
97     }
98
99
100     public boolean isInternal() {
101         return PROVIDERID_INTERNAL.equals(this.providerId);
102     }
103 }