/** * ============LICENSE_START==================================================== * org.onap.aaf * =========================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. * =========================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END==================================================== * */ package org.onap.aaf.cadi.config; import java.util.HashMap; import java.util.Map; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.SecuritySetter; public class SecurityInfoC extends SecurityInfo { public static final String DEF_ID = "ID not Set"; private static Map,SecurityInfoC> sicMap = new HashMap,SecurityInfoC>(); public SecuritySetter defSS; public SecurityInfoC(Access access) throws CadiException { super(access); defSS = new SecuritySetter() { @Override public String getID() { return DEF_ID; } @Override public void setSecurity(CLIENT client) throws CadiException { throw new CadiException("No Client Credentials set."); } @Override public int setLastResponse(int respCode) { return 0; } }; } public static synchronized SecurityInfoC instance(Access access, Class cls) throws CadiException { @SuppressWarnings("unchecked") SecurityInfoC sic = (SecurityInfoC) sicMap.get(cls); if(sic==null) { sic = new SecurityInfoC(access); sicMap.put(cls, sic); } return sic; } public SecurityInfoC set(SecuritySetter defSS) { this.defSS = defSS; return this; } }