From fe31d703f58c903671a60dd7716a6ee38697ab9b Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 14 Jan 2015 16:03:52 +0000 Subject: [PATCH] Move VCAP listener to spring-cloud-security --- .../VcapServiceCredentialsListener.java | 90 ------------------- src/main/resources/META-INF/spring.factories | 3 - 2 files changed, 93 deletions(-) delete mode 100644 src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsListener.java diff --git a/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsListener.java b/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsListener.java deleted file mode 100644 index eff9558..0000000 --- a/src/main/java/org/springframework/cloud/cloudfoundry/environment/VcapServiceCredentialsListener.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2013-2014 the original author or authors. - * - * 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. - */ -package org.springframework.cloud.cloudfoundry.environment; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.boot.context.config.ConfigFileApplicationListener; -import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.core.Ordered; -import org.springframework.core.env.MapPropertySource; - -/** - * @author Dave Syer - * - */ -public class VcapServiceCredentialsListener implements - ApplicationListener, Ordered { - - // After VcapApplicationListener and ConfigFileApplicationListener so values here can - // use those ones - private int order = ConfigFileApplicationListener.DEFAULT_ORDER + 1; - - @Override - public int getOrder() { - return order; - } - - @Override - public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { - Map source = new HashMap(); - source.put("oauth.sso.logoutUri", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.logoutUri:}"); - source.put("spring.oauth2.resource.id", - "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.id:}"); - source.put( - "spring.oauth2.resource.userInfoUri", - "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.userInfoUri:" - + "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.userInfoUri:}}"); - source.put( - "spring.oauth2.resource.tokenInfoUri", - "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.tokenInfoUri:" - + "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.tokenInfoUri:}}"); - source.put( - "spring.oauth2.resource.jwt.keyUri", - "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.keyUri:" - + "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.keyUri:}}"); - source.put( - "spring.oauth2.resource.jwt.keyValue", - "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.keyValue:" - + "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.keyValue:}}"); - source.put( - "spring.oauth2.client.tokenUri", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.tokenUri:" - + "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.tokenUri:}}"); - source.put( - "spring.oauth2.client.authorizationUri", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.authorizationUri:" - + "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.authorizationUri:}}"); - source.put( - "spring.oauth2.client.clientId", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.clientId:" - + "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.clientId:}}"); - source.put( - "spring.oauth2.client.clientSecret", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.clientSecret:" - + "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.clientSecret:}}"); - source.put( - "spring.oauth2.client.scope", - "${vcap.services.${oauth2.sso.serviceId:sso}.credentials.scope:" - + "${vcap.services.${oauth2.resource.serviceId:resource}.credentials.scope:}}"); - event.getEnvironment().getPropertySources() - .addLast(new MapPropertySource("cloudDefaultBindings", source)); - } - -} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index afab75e..e69de29 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1,3 +0,0 @@ -# Application Listeners -org.springframework.context.ApplicationListener=\ -org.springframework.cloud.cloudfoundry.environment.VcapServiceCredentialsListener