2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.oauthprovider.data;
24 import com.fasterxml.jackson.annotation.JsonIgnore;
25 import java.util.HashMap;
27 import org.onap.ccsdk.features.sdnr.wt.oauthprovider.providers.OAuthProviderFactory.OAuthProvider;
29 public class OAuthProviderConfig {
32 private String internalUrl;
33 private String clientId;
34 private String secret;
38 private String realmName;
39 private boolean trustAll;
40 private OAuthProvider type;
41 private Map<String, String> roleMapping;
43 public OAuthProvider getType() {
47 public OAuthProviderConfig(String id, String url, String internalUrl, String clientId, String secret, String scope,
48 String title, String realmName, boolean trustAll) {
51 this.internalUrl = internalUrl;
52 this.clientId = clientId;
56 this.realmName = realmName;
57 this.trustAll = trustAll;
58 this.roleMapping = new HashMap<>();
62 public String toString() {
63 return "OAuthProviderConfig [url=" + url + ", clientId=" + clientId + ", secret=" + secret + ", id=" + id
64 + ", title=" + title + ", scope=" + scope + ", realmName=" + realmName + ", trustAll=" + trustAll
65 + ", type=" + type + ", roleMapping=" + roleMapping + "]";
68 public void setType(OAuthProvider type) {
72 public OAuthProviderConfig() {
73 this(null, null, null, null, null, null, null, null, false);
76 public void setUrl(String url) {
80 public void setClientId(String clientId) {
81 this.clientId = clientId;
84 public void setSecret(String secret) {
88 public void setId(String id) {
92 public void setTitle(String title) {
96 public void setScope(String scope) {
100 public String getId() {
104 public String getUrl() {
108 public String getClientId() {
109 return this.clientId;
112 public String getSecret() {
116 public String getTitle() {
120 public String getScope() {
124 public String getRealmName() {
128 public void setRealmName(String realmName) {
129 this.realmName = realmName;
132 public boolean trustAll() {
136 public void setTrustAll(boolean trustAll) {
137 this.trustAll = trustAll;
140 public Map<String, String> getRoleMapping() {
144 public void setRoleMapping(Map<String, String> roleMapping) {
145 this.roleMapping = roleMapping;
148 public String getInternalUrl() {
152 public void setInternalUrl(String internalUrl) {
153 this.internalUrl = internalUrl;
157 public void handleEnvironmentVars() {
158 if (Config.isEnvExpression(this.id)) {
159 this.id = Config.getProperty(this.id, null);
161 if (Config.isEnvExpression(this.url)) {
162 this.url = Config.getProperty(this.url, null);
164 if (Config.isEnvExpression(this.internalUrl)) {
165 this.internalUrl = Config.getProperty(this.internalUrl, null);
167 if (Config.isEnvExpression(this.clientId)) {
168 this.clientId = Config.getProperty(this.clientId, null);
170 if (Config.isEnvExpression(this.secret)) {
171 this.secret = Config.getProperty(this.secret, null);
173 if (Config.isEnvExpression(this.scope)) {
174 this.scope = Config.getProperty(this.scope, null);
176 if (Config.isEnvExpression(this.title)) {
177 this.title = Config.getProperty(this.title, null);
179 if (Config.isEnvExpression(this.realmName)) {
180 this.realmName = Config.getProperty(this.realmName, null);
185 public String getUrlOrInternal() {
186 return this.internalUrl != null && this.internalUrl.length() > 0 ? this.internalUrl : this.url;