2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalsdk.external.authorization.util;
40 import java.io.IOException;
41 import java.io.InputStream;
42 import java.util.Properties;
44 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
47 public class EcompExternalAuthProperties {
49 public static final String EXTERNAL_AUTH_USER_NAME = "extern_auth_user_name";
51 public static final String EXTERNAL_AUTH_PASSWORD = "extern_auth_password";
53 public static final String EXTERNAL_AUTH_URL = "extern_auth_url";
55 public static final String EXTERNAL_AUTH_USER_DOMAIN = "extern_auth_user_domain";
57 public static final String EXTERNAL_AUTH_NAMESPACE = "extern_auth_namespace";
59 private EcompExternalAuthProperties(){}
61 private static Properties properties;
63 private static String propertyFileName = "external-auth.properties";
65 private static final Object lockObject = new Object();
67 private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EcompExternalAuthProperties.class);
70 * Gets the property value for the specified key. If a value is found, leading
71 * and trailing space is trimmed.
75 * @return Value for the named property; null if the property file was not
76 * loaded or the key was not found.
78 public static String getProperty(String property) {
79 if (properties == null) {
80 synchronized (lockObject) {
83 logger.error(EELFLoggerDelegate.errorLogger,"Failed to read property file " + propertyFileName);
86 } catch (IOException e) {
87 logger.error(EELFLoggerDelegate.errorLogger,"Failed to read property file " + propertyFileName ,e);
92 String value = properties.getProperty(property);
99 * Reads properties from a portal.properties file on the classpath.
101 * Clients do NOT need to call this method. Clients MAY call this method to test
102 * whether the properties file can be loaded successfully.
104 * @return True if properties were successfully loaded, else false.
105 * @throws IOException
108 private static boolean initialize() throws IOException {
109 if (properties != null)
111 InputStream in = EcompExternalAuthProperties.class.getClassLoader().getResourceAsStream(propertyFileName);
114 properties = new Properties();