cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1376897 - /cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java
Date Fri, 24 Aug 2012 12:45:41 GMT
Author: sergeyb
Date: Fri Aug 24 12:45:41 2012
New Revision: 1376897

URL: http://svn.apache.org/viewvc?rev=1376897&view=rev
Log:
Adding two more MAC token constructors

Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java?rev=1376897&r1=1376896&r2=1376897&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/mac/MacAccessToken.java
Fri Aug 24 12:45:41 2012
@@ -24,6 +24,12 @@ import org.apache.cxf.rs.security.oauth2
 import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils;
 
 public class MacAccessToken extends ServerAccessToken {
+    
+    public MacAccessToken(Client client, 
+                          long lifetime) {
+        this(client, HmacAlgorithm.HmacSHA256, lifetime);
+    }
+    
     public MacAccessToken(Client client, 
                           String macAuthAlgo,
                           long lifetime) {
@@ -45,12 +51,23 @@ public class MacAccessToken extends Serv
                           long lifetime, 
                           long issuedAt) {
         super(client, OAuthConstants.MAC_TOKEN_TYPE, tokenKey, lifetime, issuedAt);
-        this.setExtraParameters(algo);
+        this.setExtraParameters(algo, null);
+    }
+    
+    public MacAccessToken(Client client,
+                          HmacAlgorithm algo,
+                          String tokenKey,
+                          String tokenSecret,
+                          long lifetime, 
+                          long issuedAt) {
+        super(client, OAuthConstants.MAC_TOKEN_TYPE, tokenKey, lifetime, issuedAt);
+        this.setExtraParameters(algo, tokenSecret);
     }
     
-    private void setExtraParameters(HmacAlgorithm algo) {
+    private void setExtraParameters(HmacAlgorithm algo, String secret) {
+        String theSecret = secret == null ? HmacUtils.generateSecret(algo) : secret; 
         super.getParameters().put(OAuthConstants.MAC_TOKEN_SECRET,
-                                  HmacUtils.generateSecret(algo));
+                                  theSecret);
         super.getParameters().put(OAuthConstants.MAC_TOKEN_ALGORITHM,
                                   algo.getOAuthName());
     }



Mime
View raw message