001/******************************************************************************* 002 * Copyright 2017 The MIT Internet Trust Consortium 003 * 004 * Portions copyright 2011-2013 The MITRE Corporation 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 *******************************************************************************/ 018/** 019 * 020 */ 021package org.mitre.openid.connect.client.service.impl; 022 023import java.util.Map; 024import java.util.Set; 025 026import org.mitre.openid.connect.client.service.ServerConfigurationService; 027import org.mitre.openid.connect.config.ServerConfiguration; 028 029/** 030 * Houses both a static server configuration and a dynamic server configuration 031 * service in one object. Checks the static service first, then falls through to 032 * the dynamic service. 033 * 034 * Provides configuration passthrough to the dynamic service's whitelist and blacklist, 035 * and to the static service's server map. 036 * 037 * 038 * @author jricher 039 * 040 */ 041public class HybridServerConfigurationService implements ServerConfigurationService { 042 043 private StaticServerConfigurationService staticServerService = new StaticServerConfigurationService(); 044 045 private DynamicServerConfigurationService dynamicServerService = new DynamicServerConfigurationService(); 046 047 048 /* (non-Javadoc) 049 * @see org.mitre.openid.connect.client.service.ServerConfigurationService#getServerConfiguration(java.lang.String) 050 */ 051 @Override 052 public ServerConfiguration getServerConfiguration(String issuer) { 053 ServerConfiguration server = staticServerService.getServerConfiguration(issuer); 054 if (server != null) { 055 return server; 056 } else { 057 return dynamicServerService.getServerConfiguration(issuer); 058 } 059 } 060 061 062 /** 063 * @return 064 * @see org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService#getServers() 065 */ 066 public Map<String, ServerConfiguration> getServers() { 067 return staticServerService.getServers(); 068 } 069 070 071 /** 072 * @param servers 073 * @see org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService#setServers(java.util.Map) 074 */ 075 public void setServers(Map<String, ServerConfiguration> servers) { 076 staticServerService.setServers(servers); 077 } 078 079 080 /** 081 * @return 082 * @see org.mitre.openid.connect.client.service.impl.DynamicServerConfigurationService#getWhitelist() 083 */ 084 public Set<String> getWhitelist() { 085 return dynamicServerService.getWhitelist(); 086 } 087 088 089 /** 090 * @param whitelist 091 * @see org.mitre.openid.connect.client.service.impl.DynamicServerConfigurationService#setWhitelist(java.util.Set) 092 */ 093 public void setWhitelist(Set<String> whitelist) { 094 dynamicServerService.setWhitelist(whitelist); 095 } 096 097 098 /** 099 * @return 100 * @see org.mitre.openid.connect.client.service.impl.DynamicServerConfigurationService#getBlacklist() 101 */ 102 public Set<String> getBlacklist() { 103 return dynamicServerService.getBlacklist(); 104 } 105 106 107 /** 108 * @param blacklist 109 * @see org.mitre.openid.connect.client.service.impl.DynamicServerConfigurationService#setBlacklist(java.util.Set) 110 */ 111 public void setBlacklist(Set<String> blacklist) { 112 dynamicServerService.setBlacklist(blacklist); 113 } 114 115}