You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by lm...@apache.org on 2010/11/09 01:41:07 UTC

svn commit: r1032796 - in /cxf/sandbox/oauth_1.0a/rt/rs/oauth: ./ spring-security/ spring-security/src/ spring-security/src/main/ spring-security/src/main/java/ spring-security/src/main/java/org/ spring-security/src/main/java/org/apache/ spring-securit...

Author: lmoren
Date: Tue Nov  9 00:41:07 2010
New Revision: 1032796

URL: http://svn.apache.org/viewvc?rev=1032796&view=rev
Log:
- separated spring module
- few improvements and simplifications

Added:
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml   (with props)
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java   (with props)
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java   (with props)
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/test/
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/test/java/
Modified:
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml

Modified: cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml?rev=1032796&r1=1032795&r2=1032796&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml Tue Nov  9 00:41:07 2010
@@ -23,7 +23,7 @@
     <groupId>org.apache.cxf</groupId>
     <artifactId>cxf-rt-rs-oauth</artifactId>
     <version>2.3.0-SNAPSHOT</version>
-    <packaging>jar</packaging>
+    <packaging>pom</packaging>
     <name>Apache CXF Runtime OAuth 1.0a</name>
     <url>http://cxf.apache.org</url>
 
@@ -34,6 +34,11 @@
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 
+    <modules>
+        <module>oauth-core</module>
+        <module>spring-security</module>
+    </modules>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.cxf</groupId>

Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml?rev=1032796&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml Tue Nov  9 00:41:07 2010
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>cxf-rt-rs-oauth</artifactId>
+        <groupId>org.apache.cxf</groupId>
+        <version>2.3.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>cxf-rt-rs-oauth-spring-security</artifactId>
+    <groupId>org.apache.cxf</groupId>
+
+    <name>Apache CXF Runtime OAuth 1.0a Spring Security Integration</name>
+    <packaging>jar</packaging>
+    <version>2.3.0-SNAPSHOT</version>
+
+    <properties>
+        <spring-security.version>3.0.3.RELEASE</spring-security.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-core</artifactId>
+            <version>${spring-security.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-web</artifactId>
+            <version>${spring-security.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-config</artifactId>
+            <version>${spring-security.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-acl</artifactId>
+            <version>${spring-security.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java?rev=1032796&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java Tue Nov  9 00:41:07 2010
@@ -0,0 +1,75 @@
+/**
+ * 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.auth.oauth.integration.spring.security;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+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 javax.servlet.http.HttpServletResponse;
+
+import org.springframework.security.authentication.AnonymousAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.GrantedAuthorityImpl;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * @author Lukasz Moren
+ */
+public class SpringOAuthAuthenticationFilter implements Filter {
+    public static final String OAUTH_AUTHORITIES = "oauth_authorities";
+
+    public void init(FilterConfig filterConfig) throws ServletException {
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+        throws IOException, ServletException {
+        HttpServletRequest req = (HttpServletRequest)request;
+        HttpServletResponse resp = (HttpServletResponse)response;
+
+        List<String> authorities = (List<String>)request.getAttribute(OAUTH_AUTHORITIES);
+        List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
+
+        if (authorities != null) {
+            for (String authority : authorities) {
+                grantedAuthorities.add(new GrantedAuthorityImpl(authority));
+            }
+
+            Authentication auth = new AnonymousAuthenticationToken(UUID.randomUUID().toString(),
+                req.getUserPrincipal(), grantedAuthorities);
+
+            SecurityContextHolder.getContext().setAuthentication(auth);
+        }
+
+
+        chain.doFilter(req, resp);
+    }
+
+    public void destroy() {
+
+    }
+}

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringOAuthAuthenticationFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java?rev=1032796&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java Tue Nov  9 00:41:07 2010
@@ -0,0 +1,34 @@
+/**
+ * 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.auth.oauth.integration.spring.security;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import org.springframework.security.access.AccessDeniedException;
+
+/**
+ * @author Lukasz Moren
+ */
+public class SpringSecurityExceptionMapper implements ExceptionMapper<AccessDeniedException> {
+
+    public Response toResponse(AccessDeniedException exception) {
+        return Response.status(Response.Status.FORBIDDEN).build();
+    }
+}

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/spring-security/src/main/java/org/apache/cxf/auth/oauth/integration/spring/security/SpringSecurityExceptionMapper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date