cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1435332 - in /cxf/fediz/trunk/plugins: ./ cxf/ cxf/src/ cxf/src/main/ cxf/src/main/assembly/ cxf/src/main/java/ cxf/src/main/java/org/ cxf/src/main/java/org/apache/ cxf/src/main/java/org/apache/cxf/ cxf/src/main/java/org/apache/cxf/fediz/ ...
Date Fri, 18 Jan 2013 20:25:05 GMT
Author: owulff
Date: Fri Jan 18 20:25:04 2013
New Revision: 1435332

URL: http://svn.apache.org/viewvc?rev=1435332&view=rev
Log:
[FEDIZ-9] Initial work started

Added:
    cxf/fediz/trunk/plugins/cxf/
    cxf/fediz/trunk/plugins/cxf/pom.xml
    cxf/fediz/trunk/plugins/cxf/src/
    cxf/fediz/trunk/plugins/cxf/src/main/
    cxf/fediz/trunk/plugins/cxf/src/main/assembly/
    cxf/fediz/trunk/plugins/cxf/src/main/assembly/assembly.xml
    cxf/fediz/trunk/plugins/cxf/src/main/java/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/FederationFilter.java
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/SecurityTokenThreadLocal.java
    cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/ThreadLocalCallbackHandler.java
Modified:
    cxf/fediz/trunk/plugins/pom.xml

Added: cxf/fediz/trunk/plugins/cxf/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/cxf/pom.xml?rev=1435332&view=auto
==============================================================================
--- cxf/fediz/trunk/plugins/cxf/pom.xml (added)
+++ cxf/fediz/trunk/plugins/cxf/pom.xml Fri Jan 18 20:25:04 2013
@@ -0,0 +1,101 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.cxf.fediz</groupId>
+        <artifactId>fediz</artifactId>
+        <version>1.1.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>fediz-cxf</artifactId>
+    <name>Apache Fediz Plugin CXF</name>
+    <packaging>bundle</packaging>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf.fediz</groupId>
+            <artifactId>fediz-core</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>${servlet.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-ws-security</artifactId>
+            <version>${cxf.version}</version>   
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.2.1</version>
+                <executions>
+                    <execution>
+                        <id>zip-file</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>src/main/assembly/assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.4</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Implementation-Title>Apache CXF Fediz</Implementation-Title>
+                        <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
+                        <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+                        <Implementation-Version>${project.version}</Implementation-Version>
+                        <Specification-Title>Apache CXF Fediz</Specification-Title>
+                        <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
+                        <Specification-Version>${project.version}</Specification-Version>
+                        <Export-Package>
+                            org.apache.cxf.fediz.spring.*;version="${project.version}"
+                        </Export-Package>
+                        <Import-Package>
+                            !org.apache.cxf.fediz.spring*,
+                            org.apache.cxf.fediz.core.*,
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: cxf/fediz/trunk/plugins/cxf/src/main/assembly/assembly.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/cxf/src/main/assembly/assembly.xml?rev=1435332&view=auto
==============================================================================
--- cxf/fediz/trunk/plugins/cxf/src/main/assembly/assembly.xml (added)
+++ cxf/fediz/trunk/plugins/cxf/src/main/assembly/assembly.xml Fri Jan 18 20:25:04 2013
@@ -0,0 +1,18 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
+http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+  <id>zip-with-dependencies</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <useProjectArtifact>true</useProjectArtifact>
+      <unpack>false</unpack>
+      <scope>runtime</scope>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/FederationFilter.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/FederationFilter.java?rev=1435332&view=auto
==============================================================================
--- cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/FederationFilter.java
(added)
+++ cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/FederationFilter.java
Fri Jan 18 20:25:04 2013
@@ -0,0 +1,79 @@
+/**
+ * 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.cxf.web;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.w3c.dom.Element;
+
+/**
+ * Add security token to thread local
+ */
+public class FederationFilter implements Filter {
+
+    private static final String DEFAULT_SECURITY_TOKEN_ATTR = "org.apache.fediz.SECURITY_TOKEN";
+    private static final String SECURITY_TOKEN_ATTR_CONFIG = "security.token.attribute";
+
+    private String securityTokenAttr = DEFAULT_SECURITY_TOKEN_ATTR;
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+        String attrName = filterConfig.getInitParameter(SECURITY_TOKEN_ATTR_CONFIG);
+        if (attrName != null) {
+            securityTokenAttr = attrName;
+        }
+    }
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain) throws IOException, ServletException {
+
+        if (request instanceof HttpServletRequest) {
+            HttpServletRequest hrequest = (HttpServletRequest)request;
+            Element el = (Element)hrequest.getSession().getAttribute(securityTokenAttr);
+            if (el != null) {
+                try {
+                    SecurityTokenThreadLocal.setToken(el);
+                    chain.doFilter(request, response);
+                } finally {
+                    SecurityTokenThreadLocal.setToken(null);
+                }
+            } else {
+                chain.doFilter(request, response);
+            }
+
+        } else {
+            chain.doFilter(request, response);
+        }
+    }
+
+    @Override
+    public void destroy() {
+    }
+
+}

Added: cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/SecurityTokenThreadLocal.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/SecurityTokenThreadLocal.java?rev=1435332&view=auto
==============================================================================
--- cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/SecurityTokenThreadLocal.java
(added)
+++ cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/SecurityTokenThreadLocal.java
Fri Jan 18 20:25:04 2013
@@ -0,0 +1,49 @@
+/**
+ * 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.cxf.web;
+
+import org.w3c.dom.Element;
+
+
+/**
+ * Thread local storage for security token
+ */
+public final class SecurityTokenThreadLocal {
+
+    private static final ThreadLocal<Element> TLS = 
+        new ThreadLocal<Element>();
+
+    private SecurityTokenThreadLocal() {
+    }    
+        
+    public static void setToken(Element token) {
+        if (token == null) { 
+            TLS.remove();
+        } else {
+            TLS.set(token);
+        }
+    }
+
+    public static Element getToken() {
+        return TLS.get();
+    }
+    
+
+}

Added: cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/ThreadLocalCallbackHandler.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/ThreadLocalCallbackHandler.java?rev=1435332&view=auto
==============================================================================
--- cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/ThreadLocalCallbackHandler.java
(added)
+++ cxf/fediz/trunk/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/web/ThreadLocalCallbackHandler.java
Fri Jan 18 20:25:04 2013
@@ -0,0 +1,68 @@
+/**
+ * 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.cxf.web;
+
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.w3c.dom.Element;
+import org.apache.cxf.ws.security.trust.delegation.DelegationCallback;
+import org.apache.ws.security.util.DOM2Writer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This CallbackHandler implementation obtains the security token from
+ * the thread local storage to be used as the delegation token.
+ */ 
+public class ThreadLocalCallbackHandler implements CallbackHandler {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ThreadLocalCallbackHandler.class);
+
+
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof DelegationCallback) {
+                DelegationCallback callback = (DelegationCallback) callbacks[i];
+                Element token = SecurityTokenThreadLocal.getToken();
+                if (token == null) {
+                    LOG.error("Security token not cached in thread local storage. Check configuration");
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("******************** TOKEN ********************");
+                        LOG.debug(DOM2Writer.nodeToString(token));
+                        LOG.debug("****************** END TOKEN *******************");
+                    }
+                    callback.setToken(token);     
+                }
+
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
+            }
+        }
+    }
+
+}

Modified: cxf/fediz/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/pom.xml?rev=1435332&r1=1435331&r2=1435332&view=diff
==============================================================================
--- cxf/fediz/trunk/plugins/pom.xml (original)
+++ cxf/fediz/trunk/plugins/pom.xml Fri Jan 18 20:25:04 2013
@@ -34,5 +34,6 @@
       <module>tomcat</module>
       <module>jetty</module>
       <module>spring</module>
+      <module>cxf</module>
    </modules>
 </project>



Mime
View raw message