e4d67432f125ad3b1412bf50a4aa2dc76e0eafc2
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2021 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 com.fasterxml.jackson.annotation.JsonIgnore;
25 import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.OAuthProviderFactory.OAuthProvider;
26
27 public class OAuthProviderConfig {
28
29     private String host;
30     private String clientId;
31     private String secret;
32     private String id;
33     private String title;
34     private String scope;
35     private OAuthProvider type;
36
37     public OAuthProvider getType() {
38         return type;
39     }
40
41     public OAuthProviderConfig(String id, String host, String clientId, String secret, String scope,
42             String title) {
43         this.id = id;
44         this.host = host;
45         this.clientId = clientId;
46         this.secret = secret;
47         this.scope = scope;
48         this.title = title;
49     }
50
51     @Override
52     public String toString() {
53         return "OAuthProviderConfig [host=" + host + ", clientId=" + clientId + ", secret=" + secret + ", id=" + id
54                 + ", title=" + title + ", scope=" + scope + ", type=" + type + "]";
55     }
56
57     public void setType(OAuthProvider type) {
58         this.type = type;
59     }
60
61     public OAuthProviderConfig() {
62         this(null, null, null, null, null, null);
63     }
64
65     public void setHost(String host) {
66         this.host = host;
67     }
68
69     public void setClientId(String clientId) {
70         this.clientId = clientId;
71     }
72
73     public void setSecret(String secret) {
74         this.secret = secret;
75     }
76
77     public void setId(String id) {
78         this.id = id;
79     }
80
81     public void setTitle(String title) {
82         this.title = title;
83     }
84
85     public void setScope(String scope) {
86         this.scope = scope;
87     }
88
89     public String getId() {
90         return this.id;
91     }
92
93     public String getHost() {
94         return this.host;
95     }
96
97     public String getClientId() {
98         return this.clientId;
99     }
100
101     public String getSecret() {
102         return this.secret;
103     }
104
105     public String getTitle() {
106         return this.title;
107     }
108
109     public String getScope() {
110         return this.scope;
111     }
112
113     @JsonIgnore
114     public void handleEnvironmentVars() {
115         if (Config.isEnvExpression(id)) {
116             this.id = Config.getProperty(id, null);
117         }
118         if (Config.isEnvExpression(host)) {
119             this.host = Config.getProperty(host, null);
120         }
121         if (Config.isEnvExpression(clientId)) {
122             this.clientId = Config.getProperty(clientId, null);
123         }
124         if (Config.isEnvExpression(secret)) {
125             this.secret = Config.getProperty(secret, null);
126         }
127         if (Config.isEnvExpression(scope)) {
128             this.scope = Config.getProperty(scope, null);
129         }
130         if (Config.isEnvExpression(title)) {
131             this.title = Config.getProperty(title, null);
132         }
133     }
134
135 }