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/06/16 00:57:20 UTC
svn commit: r955079 - in /cxf/sandbox/oauth_1.0a/rt/rs/oauth: ./
src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cxf/
src/main/java/org/apache/cxf/auth/ src/main/java/org/apache/cxf/auth/oauth/
src/main/java/org/apache/cxf/auth/oa...
Author: lmoren
Date: Tue Jun 15 22:57:19 2010
New Revision: 955079
URL: http://svn.apache.org/viewvc?rev=955079&view=rev
Log:
Temporary Credentail Request endpoint draft
Added:
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java (with props)
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/
cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml (with props)
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=955079&r1=955078&r2=955079&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml (original)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/pom.xml Tue Jun 15 22:57:19 2010
@@ -22,7 +22,7 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-oauth</artifactId>
- <version>1.0a</version>
+ <version>2.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Apache CXF OAuth 1.0a</name>
<url>http://cxf.apache.org</url>
@@ -38,19 +38,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>2.3.0-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
-
<dependency>
- <groupId>net.oauth.core</groupId>
- <artifactId>oauth</artifactId>
- <version>20100527</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>net.oauth.core</groupId>
- <artifactId>oauth-consumer</artifactId>
+ <artifactId>oauth</artifactId>
<version>20100527</version>
</dependency>
+ <!--<dependency>-->
+ <!--<groupId>net.oauth.core</groupId>-->
+ <!--<artifactId>oauth-consumer</artifactId>-->
+ <!--<version>20100527</version>-->
+ <!--</dependency>-->
<dependency>
<groupId>net.oauth.core</groupId>
<artifactId>oauth-provider</artifactId>
@@ -63,6 +67,24 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>2.5.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<repositories>
@@ -73,4 +95,12 @@
</repository>
</repositories>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ </build>
+
</project>
\ No newline at end of file
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,26 @@
+/**
+ * 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.endpoints;
+
+/**
+ * @author Lukasz Moren
+ */
+public class AccessTokenService {
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/AccessTokenService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,39 @@
+/**
+ * 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.endpoints;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Lukasz Moren
+ */
+@Service
+@Path("/initiate")
+public interface TemporaryCredentialService {
+ @POST
+ @Produces("application/x-www-form-urlencoded")
+ Response getRequestService(@Context HttpServletRequest request);
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,131 @@
+/**
+ * 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.endpoints;
+
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import net.oauth.OAuth;
+import net.oauth.OAuthAccessor;
+import net.oauth.OAuthConsumer;
+import net.oauth.OAuthException;
+import net.oauth.OAuthMessage;
+import net.oauth.OAuthProblemException;
+import net.oauth.SimpleOAuthValidator;
+import net.oauth.server.OAuthServlet;
+import org.apache.cxf.auth.oauth.provider.*;
+import org.apache.cxf.auth.oauth.provider.OAuthDataProvider;
+import org.apache.cxf.auth.oauth.provider.OAuthToken;
+
+import org.apache.cxf.auth.oauth.validation.OAuthValidatorWrapper;
+import org.apache.cxf.auth.oauth.validation.OAuthValidatorWrapperImpl;
+import org.apache.cxf.common.logging.LogUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Lukasz Moren
+ */
+@Service
+@Path("/initiate")
+
+public class TemporaryCredentialServiceImpl implements TemporaryCredentialService {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(TemporaryCredentialServiceImpl.class);
+
+ //todo change way creating that, inject with spring?
+ private OAuthDataProvider oAuthDataProvider;
+
+ private OAuthValidatorWrapper oAuthValidator = new OAuthValidatorWrapperImpl(new SimpleOAuthValidator());
+
+
+ @POST
+ @Produces("application/x-www-form-urlencoded")
+ public Response getRequestService(@Context HttpServletRequest request) {
+ //todo add realm optional parameter
+ LOG.log(Level.INFO, "temporary credentails endpoint invoked");
+ try {
+ OAuthMessage oAuthMessage = OAuthServlet.getMessage(request, request.getRequestURL().toString());
+
+ oAuthMessage.requireParameters(OAuth.OAUTH_CONSUMER_KEY,
+ OAuth.OAUTH_SIGNATURE_METHOD,
+ OAuth.OAUTH_SIGNATURE,
+ OAuth.OAUTH_TIMESTAMP,
+ OAuth.OAUTH_NONCE,
+ OAuth.OAUTH_CALLBACK);
+
+
+ ClientAuthenticationInfo authenticationInfo = oAuthDataProvider
+ .getClientAuthenticationInfo(oAuthMessage.getParameter(OAuth.OAUTH_CONSUMER_KEY));
+
+ //user credentials not found
+ if (authenticationInfo == null) {
+ return Response.status(HttpServletResponse.SC_UNAUTHORIZED).build();
+ }
+
+ //todo add validation and signature checking
+ OAuthConsumer consumer = new OAuthConsumer(oAuthMessage.getParameter(OAuth.OAUTH_CALLBACK),
+ authenticationInfo.getConsumerKey(), authenticationInfo.getSecretKey(), null);
+
+ OAuthAccessor accessor = new OAuthAccessor(consumer);
+
+ //validate message
+ oAuthValidator.validateMessage(oAuthMessage, accessor);
+
+
+ OAuthToken oAuthToken = oAuthDataProvider
+ .generateOAuthToken(authenticationInfo.getConsumerKey());
+
+ Map<String, Object> responseParams = new HashMap<String, Object>();
+ responseParams.put(OAuth.OAUTH_TOKEN, oAuthToken.getOauthToken());
+ responseParams.put(OAuth.OAUTH_TOKEN_SECRET, oAuthToken.getTokenSecret());
+ responseParams.put(OAuth.OAUTH_CALLBACK_CONFIRMED, Boolean.TRUE);
+
+ String response = OAuth.formEncode(responseParams.entrySet());
+ return Response.ok(response).build();
+
+ } catch (OAuthProblemException e) {
+ e.printStackTrace(); //todo log exception
+ Response.status(e.getHttpStatusCode()).entity(e.toString()).build();
+ } catch (OAuthException e) {
+ Response.status(HttpServletResponse.SC_BAD_REQUEST).build();
+ } catch (Exception e) {
+ e.printStackTrace(); //todo log exception
+ Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).build();
+ }
+
+ return Response.status(HttpServletResponse.SC_BAD_REQUEST).build();
+ }
+
+ public OAuthDataProvider getoAuthDataProvider() {
+ return oAuthDataProvider;
+ }
+
+ public void setoAuthDataProvider(OAuthDataProvider oAuthDataProvider) {
+ this.oAuthDataProvider = oAuthDataProvider;
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,26 @@
+/**
+ * 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.endpoints;
+
+/**
+ * @author Lukasz Moren
+ */
+public class UserAuthorizationService {
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/endpoints/UserAuthorizationService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,28 @@
+/**
+ * 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.provider;
+
+/**
+ * @author Lukasz Moren
+ */
+public interface ClientAuthenticationInfo {
+ String getConsumerKey();
+
+ String getSecretKey();
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,40 @@
+/**
+ * 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.provider;
+
+/**
+ * @author Lukasz Moren
+ */
+public class ClientAuthenticationInfoImpl implements ClientAuthenticationInfo {
+ private String consumerKey;
+ private String secretKey;
+
+ public ClientAuthenticationInfoImpl(String consumerKey, String secretKey) {
+ this.consumerKey = consumerKey;
+ this.secretKey = secretKey;
+ }
+
+ public String getConsumerKey() {
+ return consumerKey;
+ }
+
+ public String getSecretKey() {
+ return secretKey;
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/ClientAuthenticationInfoImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,29 @@
+/**
+ * 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.provider;
+
+/**
+ * @author Lukasz Moren
+ */
+public interface OAuthDataProvider {
+ ClientAuthenticationInfo getClientAuthenticationInfo(String consumerKey);
+
+ OAuthToken generateOAuthToken(String consumerKey);
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,60 @@
+/**
+ * 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.provider;
+
+import org.apache.cxf.auth.oauth.utils.OAuthUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.Map;
+
+
+/**
+ * @author Lukasz Moren
+ */
+@Service
+public class OAuthDataProviderImpl implements OAuthDataProvider {
+
+ private Map<String, ClientAuthenticationInfo> clientAuthInfo
+ = new ConcurrentHashMap<String, ClientAuthenticationInfo>();
+
+ private Map<String, OAuthToken> oauthTokens = new ConcurrentHashMap<String, OAuthToken>();
+
+ public ClientAuthenticationInfo getClientAuthenticationInfo(String consumerKey) {
+ return clientAuthInfo.get(consumerKey);
+ }
+
+ public OAuthToken generateOAuthToken(String consumerKey) {
+ String token = OAuthUtils.generateToken(consumerKey);
+ String tokenSecret = OAuthUtils.generateToken(consumerKey);
+
+ OAuthToken oAuthToken = new OAuthToken(token, tokenSecret);
+ oauthTokens.put(consumerKey, oAuthToken);
+ return oAuthToken;
+ }
+
+ public Map<String, ClientAuthenticationInfo> getClientAuthInfo() {
+ return clientAuthInfo;
+ }
+
+ public void setClientAuthInfo(Map<String, ClientAuthenticationInfo> clientAuthInfo) {
+ this.clientAuthInfo = clientAuthInfo;
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthDataProviderImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java Tue Jun 15 22:57:19 2010
@@ -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.auth.oauth.provider;
+
+/**
+ * @author Lukasz Moren
+ */
+public class OAuthToken {
+ private String oauthToken;
+ private String tokenSecret;
+
+ public OAuthToken(String oauthToken, String tokenSecret) {
+ this.oauthToken = oauthToken;
+ this.tokenSecret = tokenSecret;
+ }
+
+ public String getOauthToken() {
+ return oauthToken;
+ }
+
+ public void setOauthToken(String oauthToken) {
+ this.oauthToken = oauthToken;
+ }
+
+ public String getTokenSecret() {
+ return tokenSecret;
+ }
+
+ public void setTokenSecret(String tokenSecret) {
+ this.tokenSecret = tokenSecret;
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/provider/OAuthToken.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,37 @@
+/**
+ * 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.utils;
+
+import java.util.UUID;
+
+/**
+ * @author Lukasz Moren
+ */
+public final class OAuthUtils {
+
+ private OAuthUtils() {
+
+ }
+
+ //todo random enough?
+
+ public static String generateToken(String generatorBase) {
+ return UUID.randomUUID().toString();
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/utils/OAuthUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,27 @@
+/**
+ * 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.validation;
+
+import net.oauth.OAuthValidator;
+
+/**
+ * @author Lukasz Moren
+ */
+public interface OAuthValidatorWrapper extends OAuthValidator {
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.validation;
+
+import net.oauth.OAuthAccessor;
+import net.oauth.OAuthException;
+import net.oauth.OAuthMessage;
+import net.oauth.OAuthValidator;
+
+import java.net.URISyntaxException;
+import java.io.IOException;
+
+
+/**
+ * @author Lukasz Moren
+ */
+public class OAuthValidatorWrapperImpl implements OAuthValidatorWrapper {
+ private OAuthValidator validator;
+
+ public OAuthValidatorWrapperImpl(OAuthValidator validator) {
+ this.validator = validator;
+ }
+
+ public void validateMessage(OAuthMessage message, OAuthAccessor accessor)
+ throws OAuthException, IOException, URISyntaxException {
+ validator.validateMessage(message, accessor);
+ }
+
+ public OAuthValidator getValidator() {
+ return validator;
+ }
+
+ public void setValidator(OAuthValidator validator) {
+ this.validator = validator;
+ }
+
+
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/validation/OAuthValidatorWrapperImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,41 @@
+/**
+ * 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.endpoints;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @author Lukasz Moren
+ */
+
+public class JUnit4SpringContextTests extends Assert {
+
+ protected ClassPathXmlApplicationContext ctx;
+
+ @Before
+ public void initialize() {
+ ctx = new ClassPathXmlApplicationContext(new String[]
+ {"classpath:oauth-beans.xml"});
+
+ }
+
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/JUnit4SpringContextTests.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,27 @@
+package org.apache.cxf.auth.oauth.endpoints;
+
+import net.oauth.OAuth;
+import net.oauth.OAuthMessage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author Lukasz Moren
+ */
+public class OAuthResponseMessage extends OAuthMessage {
+ public OAuthResponseMessage(String method, String URL, Collection<? extends Map.Entry> parameters, InputStream inputStream) {
+ super(method, URL, parameters, inputStream);
+ }
+
+ @Override
+ protected void completeParameters() throws IOException {
+ super.completeParameters();
+ String body = readBodyAsString();
+ if (body != null) {
+ addParameters(OAuth.decodeForm(body.trim()));
+ }
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthResponseMessage.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java Tue Jun 15 22:57:19 2010
@@ -0,0 +1,73 @@
+/**
+ * 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.endpoints;
+
+import net.oauth.OAuth;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import java.io.InputStream;
+import java.net.URI;
+
+/**
+ * @author Lukasz Moren
+ */
+public class TemporaryCredentialServiceTest extends JUnit4SpringContextTests {
+
+ @Test
+ public void testGetRequestService() throws Exception {
+ Server s = null;
+ try {
+ JAXRSServerFactoryBean sf = (JAXRSServerFactoryBean) ctx.getBean("oauthServer");
+
+ s = sf.create();
+
+ URI uri = UriBuilder.fromUri(new URI("http://localhost:9001/auth/oauth/initiate"))
+ .queryParam("oauth_consumer_key", 12345678).queryParam("oauth_signature_method", "PLAINTEXT")
+ .queryParam("oauth_callback", "http%3A%2F%2Fprinter.example.com%2Fready")
+ .queryParam("oauth_signature", "secret%26").queryParam("oauth_nonce", "sfsdfsdfs")
+ .queryParam("oauth_timestamp", String.valueOf(System.currentTimeMillis() / 1000))
+ .buildFromEncoded();
+
+ WebClient cl = WebClient.create(uri);
+ cl.accept("application/x-www-form-urlencoded");
+
+ Response r = cl.post(null);
+
+ OAuthResponseMessage message = new OAuthResponseMessage(null, null, null, (InputStream) r.getEntity());
+ message.completeParameters();
+ message.requireParameters(OAuth.OAUTH_CALLBACK_CONFIRMED, OAuth.OAUTH_TOKEN, OAuth.OAUTH_TOKEN_SECRET);
+
+ assertEquals(3, message.getParameters().size());
+ assertEquals(HttpServletResponse.SC_OK, r.getStatus());
+
+ } finally {
+ if (s != null) {
+ s.destroy();
+ }
+ }
+ }
+}
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/TemporaryCredentialServiceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml?rev=955079&view=auto
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml (added)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml Tue Jun 15 22:57:19 2010
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
+
+ <!--<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>-->
+ <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
+
+ <jaxrs:server id="oauthServer" address="http://localhost:9001/auth/oauth">
+ <jaxrs:serviceBeans>
+ <ref bean="temporaryCredentialService"/>
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
+
+ <bean id="temporaryCredentialService" class="org.apache.cxf.auth.oauth.endpoints.TemporaryCredentialServiceImpl">
+ <property name="oAuthDataProvider" ref="oauthDataProvider"/>
+ </bean>
+
+ <bean id="oauthDataProvider" class="org.apache.cxf.auth.oauth.provider.OAuthDataProviderImpl">
+ <property name="clientAuthInfo">
+ <map key-type="java.lang.String" value-type="org.apache.cxf.auth.oauth.provider.ClientAuthenticationInfo">
+ <entry key="12345678" value-ref="clientAuthInfo" />
+ </map>
+ </property>
+ </bean>
+
+ <bean id="clientAuthInfo" class="org.apache.cxf.auth.oauth.provider.ClientAuthenticationInfoImpl">
+ <constructor-arg value="12345678"/>
+ <constructor-arg value="secret"/>
+ </bean>
+
+
+</beans>
\ No newline at end of file
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/resources/oauth-beans.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml