You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2015/11/27 13:19:18 UTC
cxf-fediz git commit: [FEDIZ-134] Avoiding refreshing the data manager
Repository: cxf-fediz
Updated Branches:
refs/heads/master d96ff4d4f -> 0b096f713
[FEDIZ-134] Avoiding refreshing the data manager
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/0b096f71
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/0b096f71
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/0b096f71
Branch: refs/heads/master
Commit: 0b096f713ed7578f503f5bcbc226d66facf1fee6
Parents: d96ff4d
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Nov 27 12:18:59 2015 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Nov 27 12:18:59 2015 +0000
----------------------------------------------------------------------
.../oidc/ApplicationContextProvider.java | 35 ++++++++++++++
.../service/oidc/HomeRealmCallbackHandler.java | 9 ++--
.../oidc/src/main/resources/data-manager.xml | 49 --------------------
.../main/webapp/WEB-INF/applicationContext.xml | 2 +-
.../src/main/webapp/WEB-INF/data-manager.xml | 49 ++++++++++++++++++++
5 files changed, 88 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/0b096f71/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ApplicationContextProvider.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ApplicationContextProvider.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ApplicationContextProvider.java
new file mode 100644
index 0000000..83e2ec8
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ApplicationContextProvider.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.fediz.service.oidc;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class ApplicationContextProvider implements ApplicationContextAware {
+ private static ApplicationContext context;
+
+ public static ApplicationContext getApplicationContext() {
+ return context;
+ }
+
+ @Override
+ public void setApplicationContext(ApplicationContext ctx) {
+ context = ctx;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/0b096f71/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/HomeRealmCallbackHandler.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/HomeRealmCallbackHandler.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/HomeRealmCallbackHandler.java
index db93ca2..41186ad 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/HomeRealmCallbackHandler.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/HomeRealmCallbackHandler.java
@@ -29,8 +29,6 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.cxf.fediz.core.spi.HomeRealmCallback;
import org.apache.cxf.rs.security.oauth2.common.Client;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HomeRealmCallbackHandler implements CallbackHandler {
@@ -39,20 +37,19 @@ public class HomeRealmCallbackHandler implements CallbackHandler {
if (callbacks[i] instanceof HomeRealmCallback) {
HomeRealmCallback callback = (HomeRealmCallback) callbacks[i];
- ApplicationContext ctx = new ClassPathXmlApplicationContext("data-manager.xml");
- OAuthDataManager dataManager = (OAuthDataManager)ctx.getBean("oauthProvider");
-
HttpServletRequest request = callback.getRequest();
String clientId = request.getParameter("client_id");
if (clientId != null) {
+ ApplicationContext ctx = ApplicationContextProvider.getApplicationContext();
+ OAuthDataManager dataManager = (OAuthDataManager)ctx.getBean("oauthProvider");
+
Client client = dataManager.getClient(clientId);
if (client instanceof FedizClient) {
callback.setHomeRealm(((FedizClient)client).getHomeRealm());
}
}
- ((AbstractApplicationContext)ctx).close();
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/0b096f71/services/oidc/src/main/resources/data-manager.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/resources/data-manager.xml b/services/oidc/src/main/resources/data-manager.xml
deleted file mode 100644
index ce3f0a3..0000000
--- a/services/oidc/src/main/resources/data-manager.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://cxf.apache.org/jaxrs
- http://cxf.apache.org/schemas/jaxrs.xsd">
-
- <bean id="samlTokenConverter" class="org.apache.cxf.fediz.service.oidc.LocalSamlTokenConverter">
- <property name="issuer" value="accounts.fediz.com"/>
- </bean>
- <bean id="oauthProvider" class="org.apache.cxf.fediz.service.oidc.OAuthDataManager"
- destroy-method="close">
- <!--
- <property name="scopes">
- <map>
- <entry key="scopeName" value="scopeDescription" />
- </map>
- </property>
- -->
- <!--
- <property name="signIdTokenWithClientSecret" value="true"/>
- <property name="accessTokenLifetime" value="3600"/>
- -->
- <property name="tokenConverter" ref="samlTokenConverter"/>
- </bean>
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/0b096f71/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
index c8c85bb..a2bb650 100644
--- a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
@@ -26,7 +26,7 @@
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
- <import resource="classpath:data-manager.xml" />
+ <import resource="data-manager.xml" />
<bean id="oidcAuthorizationService" class="org.apache.cxf.rs.security.oidc.idp.OidcAuthorizationCodeService">
<property name="dataProvider" ref="oauthProvider"/>
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/0b096f71/services/oidc/src/main/webapp/WEB-INF/data-manager.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/data-manager.xml b/services/oidc/src/main/webapp/WEB-INF/data-manager.xml
new file mode 100644
index 0000000..7440464
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/data-manager.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ ">
+
+ <bean id="applicationContextProvider" class="org.apache.cxf.fediz.service.oidc.ApplicationContextProvider"/>
+
+ <bean id="samlTokenConverter" class="org.apache.cxf.fediz.service.oidc.LocalSamlTokenConverter">
+ <property name="issuer" value="accounts.fediz.com"/>
+ </bean>
+ <bean id="oauthProvider" class="org.apache.cxf.fediz.service.oidc.OAuthDataManager"
+ destroy-method="close">
+ <!--
+ <property name="scopes">
+ <map>
+ <entry key="scopeName" value="scopeDescription" />
+ </map>
+ </property>
+ -->
+ <!--
+ <property name="signIdTokenWithClientSecret" value="true"/>
+ <property name="accessTokenLifetime" value="3600"/>
+ -->
+ <property name="tokenConverter" ref="samlTokenConverter"/>
+ </bean>
+
+</beans>
+