cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmo...@apache.org
Subject svn commit: r985766 - in /cxf/sandbox/oauth_1.0a: distribution/src/main/release/samples/oauth_1.0a/client/ distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/ distribution/src/main/release/...
Date Sun, 15 Aug 2010 21:57:09 GMT
Author: lmoren
Date: Sun Aug 15 21:57:08 2010
New Revision: 985766

URL: http://svn.apache.org/viewvc?rev=985766&view=rev
Log:
- oauth demo update

Modified:
    cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/pom.xml
    cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/OAuthParams.java
    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/controllers/ApplicationController.java
    cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/newClientForm.jsp
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/handlers/AbstractOAuthRequestHandler.java
    cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthTestUtils.java

Modified: cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/pom.xml?rev=985766&r1=985765&r2=985766&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/pom.xml
(original)
+++ cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/pom.xml
Sun Aug 15 21:57:08 2010
@@ -13,6 +13,7 @@
         <groupId>org.apache.cxf.samples</groupId>
         <artifactId>cxf-samples</artifactId>
         <version>2.3.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
     </parent>
 
     <build>

Modified: cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/OAuthParams.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/OAuthParams.java?rev=985766&r1=985765&r2=985766&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/OAuthParams.java
(original)
+++ cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/client/src/main/java/org/apache/cxf/auth/oauth/demo/client/model/OAuthParams.java
Sun Aug 15 21:57:08 2010
@@ -48,7 +48,6 @@ public class OAuthParams implements Seri
     private List<SignatureMethod> methods = new ArrayList<SignatureMethod>();
 
     public OAuthParams() {
-        methods.add(new SignatureMethod("PLAINTEXT"));
         methods.add(new SignatureMethod("HMAC-SHA1"));
     }
 

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=985766&r1=985765&r2=985766&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
Sun Aug 15 21:57:08 2010
@@ -12,6 +12,7 @@
         <groupId>org.apache.cxf.samples</groupId>
         <artifactId>cxf-samples</artifactId>
         <version>2.3.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
     </parent>
 
     <build>

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=985766&r1=985765&r2=985766&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
Sun Aug 15 21:57:08 2010
@@ -27,6 +27,7 @@ import java.io.Serializable;
 public class ClientApp implements Serializable {
     private String clientName = "OAuth 1.0a client";
     private String callbackURL = "http://localhost:8080/app/callback";
+    private String consumerKey;
     private String error;
 
     public String getClientName() {
@@ -52,4 +53,12 @@ public class ClientApp implements Serial
     public void setError(String error) {
         this.error = error;
     }
+
+    public String getConsumerKey() {
+        return consumerKey;
+    }
+
+    public void setConsumerKey(String consumerKey) {
+        this.consumerKey = consumerKey;
+    }
 }

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/controllers/ApplicationController.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/controllers/ApplicationController.java?rev=985766&r1=985765&r2=985766&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/controllers/ApplicationController.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/controllers/ApplicationController.java
Sun Aug 15 21:57:08 2010
@@ -64,15 +64,14 @@ public class ApplicationController {
             return handleInternalRedirect(clientApp);
         }
 
-        if (StringUtils.isEmpty(clientApp.getCallbackURL())) {
-            clientApp.setCallbackURL(org.apache.cxf.auth.oauth.provider.Client.OAUTH_OOB);
-        }
-
         TokenGenerator tokenGen = new MD5TokenGenerator();
         Principal principal = SecurityContextHolder.getContext().getAuthentication();
+        String consumerKey = clientApp.getConsumerKey();
+        if (StringUtils.isEmpty(consumerKey)) {
+            consumerKey = tokenGen
+                .generateToken((principal.getName() + clientApp.getClientName()).getBytes("UTF-8"));
+        }
 
-        String consumerKey = tokenGen
-            .generateToken((principal.getName() + clientApp.getClientName()).getBytes("UTF-8"));
         String secretKey = tokenGen.generateToken(new SecureRandom().generateSeed(20));
 
         Client clientInfo = new ClientImpl(consumerKey,

Modified: cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/newClientForm.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/newClientForm.jsp?rev=985766&r1=985765&r2=985766&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/newClientForm.jsp
(original)
+++ cxf/sandbox/oauth_1.0a/distribution/src/main/release/samples/oauth_1.0a/server/src/main/webapp/WEB-INF/views/newClientForm.jsp
Sun Aug 15 21:57:08 2010
@@ -31,6 +31,11 @@ under the License.
 <table>
     <form:form commandName="client" action="/app/registerClient">
         <tr>
+            <td>Consumer key:</td>
+            <td><form:input size="70" path="consumerKey"/> - You can provide
consumer key,
+                if not it will be automatically generated</td>
+        </tr>
+        <tr>
             <td>Client Name:</td>
             <td><form:input size="70" path="clientName"/></td>
         </tr>

Modified: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/handlers/AbstractOAuthRequestHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/handlers/AbstractOAuthRequestHandler.java?rev=985766&r1=985765&r2=985766&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/handlers/AbstractOAuthRequestHandler.java
(original)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/main/java/org/apache/cxf/auth/oauth/handlers/AbstractOAuthRequestHandler.java
Sun Aug 15 21:57:08 2010
@@ -81,7 +81,7 @@ public abstract class AbstractOAuthReque
         Client authNInfo = dataProvider
             .getClientAuthenticationInfo(oAuthMessage.getParameter(OAuth.OAUTH_CONSUMER_KEY));
 
-        //client credentials not found //todo handle exception
+        //client credentials not found
         if (authNInfo == null) {
             OAuthProblemException problemEx = new OAuthProblemException(
                 OAuth.Problems.CONSUMER_KEY_UNKNOWN);
@@ -283,15 +283,29 @@ public abstract class AbstractOAuthReque
         return secData;
     }
 
-    //todo check if this same as registered
-
     protected Client setCallbackURL(Client authNInfo,
-                                    String oauthCallback) {
+                                    String oauthCallback) throws OAuthProblemException {
+
+        if (oauthCallback.equals(Client.OAUTH_OOB)) {
+            return authNInfo;
+        }
 
-        if (!oauthCallback.equals(Client.OAUTH_OOB)) {
-            authNInfo.setCallbackURL(oauthCallback);
+        String registeredCallbackURL = authNInfo.getCallbackURL();
+        if (!StringUtils.isEmpty(registeredCallbackURL)) {
+            if (!registeredCallbackURL.equals(oauthCallback)) {
+                OAuthProblemException problemEx = new OAuthProblemException(
+                    OAuth.Problems.PARAMETER_REJECTED + " - " + OAuth.OAUTH_CALLBACK);
+                problemEx
+                    .setParameter(OAuthProblemException.HTTP_STATUS_CODE,
+                        HttpServletResponse.SC_BAD_REQUEST);
+                throw problemEx;
+            }
+            return authNInfo;
         }
 
+        //there was no preregistered url, use one from request
+        authNInfo.setCallbackURL(oauthCallback);
+
         return authNInfo;
     }
 

Modified: cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthTestUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthTestUtils.java?rev=985766&r1=985765&r2=985766&view=diff
==============================================================================
--- cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthTestUtils.java
(original)
+++ cxf/sandbox/oauth_1.0a/rt/rs/oauth/src/test/java/org/apache/cxf/auth/oauth/endpoints/OAuthTestUtils.java
Sun Aug 15 21:57:08 2010
@@ -50,7 +50,7 @@ import org.junit.Assert;
  */
 public final class OAuthTestUtils {
 
-    public static final String CALLBACK = "http://www.printer.example.com/ready/callback";
+    public static final String CALLBACK = "http://www.example.com/callback";
     public static final String CLIENT_ID = "12345678";
     public static final String CLIENT_SECRET = "secret";
     public static final String CLIENT_SHARED_SECRET = "shared_secret";



Mime
View raw message