cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6572] Upddating hawk normalization procedure with a hawk.1.header and a default port if needed
Date Tue, 01 Sep 2015 16:36:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 3808f19a8 -> 6b38b193b


[CXF-6572] Upddating hawk normalization procedure with a hawk.1.header and a default port
if needed


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6b38b193
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6b38b193
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6b38b193

Branch: refs/heads/3.0.x-fixes
Commit: 6b38b193ba34b28602d04700f2cc0e1fa8e21f4a
Parents: 3808f19
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Sep 1 17:34:02 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Sep 1 17:36:26 2015 +0100

----------------------------------------------------------------------
 .../oauth2/client/HttpRequestProperties.java         | 15 ++++++++++++++-
 .../oauth2/tokens/hawk/HawkAuthorizationScheme.java  |  4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6b38b193/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/HttpRequestProperties.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/HttpRequestProperties.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/HttpRequestProperties.java
index 4a705a8..6f9c207 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/HttpRequestProperties.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/HttpRequestProperties.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.rs.security.oauth2.client;
 
+import java.net.MalformedURLException;
 import java.net.URI;
 
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -35,7 +36,7 @@ public class HttpRequestProperties {
     }
     
     public HttpRequestProperties(URI uri, String httpMethod) {
-        this(uri.getHost(), uri.getPort(), httpMethod,
+        this(uri.getHost(), getPortFromURI(uri), httpMethod,
              uri.getRawPath(), uri.getRawQuery());
     }
     
@@ -51,6 +52,18 @@ public class HttpRequestProperties {
         this.httpMethod = httpMethod;
     }
     
+    private static int getPortFromURI(URI uri) {
+        int port = uri.getPort();
+        if (port == -1) {
+            try {
+                port = uri.toURL().getDefaultPort();
+            } catch (MalformedURLException ex) {
+                // ignore
+            }
+        }
+        return port;
+    }
+    
     public String getRequestPath() {
         return requestPath;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/6b38b193/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/hawk/HawkAuthorizationScheme.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/hawk/HawkAuthorizationScheme.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/hawk/HawkAuthorizationScheme.java
index ce02419..c0e1a6b 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/hawk/HawkAuthorizationScheme.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/hawk/HawkAuthorizationScheme.java
@@ -32,6 +32,7 @@ import org.apache.cxf.rt.security.crypto.HmacUtils;
 // https://github.com/hueniverse/hawk/blob/master/README.md
 public class HawkAuthorizationScheme {
     private static final String SEPARATOR = "\n";
+    private static final String HAWK_1_HEADER = "hawk.1.header";
     
     private HttpRequestProperties props;
     private String macKey;
@@ -98,7 +99,8 @@ public class HawkAuthorizationScheme {
         }
         
         
-        String value = timestamp + SEPARATOR 
+        String value = HAWK_1_HEADER + SEPARATOR 
+            + timestamp + SEPARATOR 
             + nonce + SEPARATOR
             + props.getHttpMethod().toUpperCase() + SEPARATOR
             + requestURI + SEPARATOR 


Mime
View raw message