Author: lmoren
Date: Tue Nov 9 00:28:15 2010
New Revision: 1032795
URL: http://svn.apache.org/viewvc?rev=1032795&view=rev
Log:
- separated spring module
- few improvements and simplifications
Added:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
(with props)
Removed:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/spring/SpringOAuthAuthenticationFilter.java
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/spring/SpringSecurityExceptionMapper.java
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/pom.xml
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/ClientApp.java
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/oauth/SampleOAuthDataProvider.java
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/oauth-beans.xml
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/displayVerifier.jsp
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/web.xml
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/pom.xml?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/pom.xml
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/pom.xml
Tue Nov 9 00:28:15 2010
@@ -49,9 +49,16 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-oauth</artifactId>
+ <artifactId>cxf-rt-rs-oauth-core</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-oauth-spring-security</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/ClientApp.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/ClientApp.java?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/ClientApp.java
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/ClientApp.java
Tue Nov 9 00:28:15 2010
@@ -23,7 +23,6 @@ import java.io.Serializable;
/**
* @author Lukasz Moren
*/
-//todo deny does not work
public class ClientApp implements Serializable {
private String clientName = "OAuth 1.0a client";
private String callbackURL = "http://localhost:8080/app/callback";
Added:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java?rev=1032795&view=auto
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
(added)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
Tue Nov 9 00:28:15 2010
@@ -0,0 +1,56 @@
+/**
+ * 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.demo.server;
+
+import javax.annotation.security.RolesAllowed;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.springframework.security.access.annotation.Secured;
+
+/**
+ * Sample JAX-RS resource service
+ *
+ * @author Lukasz Moren
+ */
+...@path("/")
+public class SampleResourceProvider {
+
+ @GET
+ @Produces("text/html")
+ @Path("/person/get/{name}")
+ @Secured ({"ROLE_USER"})
+ public Response getInfo(@PathParam("name") String name, @Context
HttpServletRequest request) {
+ return Response.ok("Successfully accessed OAuth protected person: " +
name).build();
+ }
+
+ @POST
+ @Produces("text/html")
+ @Path("/person/modify/{name}")
+ @Secured( {"ROLE_ADMIN"})
+ public Response modifyInfo(@PathParam("name") String name, @Context
HttpServletRequest request) {
+ return Response.ok("Successfully modified OAuth protected person: " +
name).build();
+ }
+}
Propchange:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/SampleResourceProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/oauth/SampleOAuthDataProvider.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/oauth/SampleOAuthDataProvider.java?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/oauth/SampleOAuthDataProvider.java
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/java/org/apache/cxf/auth/oauth/demo/server/oauth/SampleOAuthDataProvider.java
Tue Nov 9 00:28:15 2010
@@ -19,10 +19,14 @@
package org.apache.cxf.auth.oauth.demo.server.oauth;
import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.cxf.auth.oauth.provider.MemoryOauthDataProvider;
+import org.apache.cxf.auth.oauth.tokens.OAuthScope;
import org.springframework.security.core.context.SecurityContext;
import
org.springframework.security.web.context.HttpSessionSecurityContextRepository;
@@ -32,6 +36,28 @@ import org.springframework.security.web.
*/
public class SampleOAuthDataProvider extends MemoryOauthDataProvider {
+ protected ConcurrentHashMap<String, OAuthScope> availableScopes
+ = new ConcurrentHashMap<String, OAuthScope>();
+
+ {
+ availableScopes
+ .put("read_info", new OAuthScope("read_info", "Read your personal
information", "ROLE_USER"));
+ availableScopes.put("modify_info",
+ new OAuthScope("modify_info", "Modify your personal information",
"ROLE_ADMIN"));
+ }
+
+ @Override
+ public List<OAuthScope> getAvailableScopes(List<String> requestScopes) {
+ List<OAuthScope> scopes = new ArrayList<OAuthScope>();
+ for (String requestScope : requestScopes) {
+ OAuthScope oAuthScope = availableScopes.get(requestScope);
+ scopes.add(oAuthScope);
+ }
+
+ return scopes;
+ }
+
+ @Override
public Principal loggedPrincipal(HttpServletRequest request) {
HttpSession session = request.getSession();
SecurityContext ctx = (SecurityContext)session
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/oauth-beans.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/oauth-beans.xml?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/oauth-beans.xml
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/oauth-beans.xml
Tue Nov 9 00:28:15 2010
@@ -41,16 +41,11 @@
<!-- Publish OAuth endpoints-->
- <jaxrs:server id="oauthServer" address="/oauth/">
+ <jaxrs:server id="oauthServer" address="/oauth/" >
<jaxrs:serviceBeans>
<ref bean="temporaryCredentialService"/>
- <ref bean="tokenService"/>
- </jaxrs:serviceBeans>
- </jaxrs:server>
-
- <jaxrs:server id="oauthAuthorization" address="/oauth/authorize">
- <jaxrs:serviceBeans>
<ref bean="resourceOwnerAuthorizationEndpoint"/>
+ <ref bean="tokenService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="dispatchProvider"/>
@@ -62,8 +57,6 @@
<property name="resourcePath" value="/oAuthLogin.jsp"/>
</bean>
- <bean id="validator"
class="org.apache.cxf.auth.oauth.validation.OAuthMessageValidator"/>
-
<!--Definitions of OAuth module endpoints-->
<bean id="resourceOwnerAuthorizationEndpoint"
class="org.apache.cxf.auth.oauth.endpoints.AuthorizationServiceImpl">
@@ -90,7 +83,7 @@
</jaxrs:server>
<bean id="springSecurityExceptionMapper"
-
class="org.apache.cxf.auth.oauth.demo.server.spring.SpringSecurityExceptionMapper"/>
+
class="org.apache.cxf.auth.oauth.integration.spring.security.SpringSecurityExceptionMapper"/>
<!-- Resource Provider -->
<bean id="resource"
class="org.apache.cxf.auth.oauth.demo.server.SampleResourceProvider"/>
</beans>
\ No newline at end of file
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/displayVerifier.jsp
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/displayVerifier.jsp?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/displayVerifier.jsp
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/displayVerifier.jsp
Tue Nov 9 00:28:15 2010
@@ -29,7 +29,7 @@ under the License.
<table>
<tr>
<td>OAuth verifier:</td>
- <td>${oauth_verifier}</td>
+ <td><%=request.getParameter("oauth_verifier")%></td>
</tr>
</table>
</body>
Modified:
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/web.xml?rev=1032795&r1=1032794&r2=1032795&view=diff
==============================================================================
---
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/web.xml
(original)
+++
cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/web.xml
Tue Nov 9 00:28:15 2010
@@ -41,7 +41,7 @@
<filter>
<filter-name>oauthSpringFilter</filter-name>
-
<filter-class>org.apache.cxf.auth.oauth.demo.server.spring.SpringOAuthAuthenticationFilter
+
<filter-class>org.apache.cxf.auth.oauth.integration.spring.security.SpringOAuthAuthenticationFilter
</filter-class>
</filter>
<filter-mapping>