cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1514198 - in /cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2: tokens/refresh/ tokens/refresh/RefreshToken.java utils/OAuthConstants.java
Date Thu, 15 Aug 2013 08:35:01 GMT
Author: sergeyb
Date: Thu Aug 15 08:35:01 2013
New Revision: 1514198

URL: http://svn.apache.org/r1514198
Log:
[CXF-5180] Adding a simple RefreshToken implementation, patch on behalf of Thorsten Hoeger
applied

Added:
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.java
  (with props)
Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthConstants.java

Added: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.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/refresh/RefreshToken.java?rev=1514198&view=auto
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.java
(added)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.java
Thu Aug 15 08:35:01 2013
@@ -0,0 +1,71 @@
+/**
+ * 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.rs.security.oauth2.tokens.refresh;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils;
+
+/**
+ * Simple Refresh Token implementation
+ */
+public class RefreshToken extends ServerAccessToken {
+    
+    private Set<String> accessTokens = new HashSet<String>();
+    
+    public RefreshToken(Client client, 
+                        long lifetime) {
+        super(client, 
+              OAuthConstants.REFRESH_TOKEN_TYPE, 
+              OAuthUtils.generateRandomTokenKey(), 
+              lifetime, 
+              System.currentTimeMillis() / 1000);
+    }
+    
+    public RefreshToken(Client client, 
+                             String tokenKey,
+                             long lifetime, 
+                             long issuedAt) {
+        super(client, 
+              OAuthConstants.REFRESH_TOKEN_TYPE, 
+              tokenKey, 
+              lifetime, 
+              issuedAt);
+    }
+
+    public Set<String> getAccessTokens() {
+        return accessTokens;
+    }
+
+    public void setAccessTokens(Set<String> accessTokens) {
+        this.accessTokens = accessTokens;
+    }
+    
+    public void addAccessToken(String token) {
+        accessTokens.add(token);
+    }
+    
+    public boolean removeAccessToken(String token) {
+        return accessTokens.remove(token);
+    }
+}

Propchange: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/tokens/refresh/RefreshToken.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthConstants.java?rev=1514198&r1=1514197&r2=1514198&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthConstants.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthConstants.java
Thu Aug 15 08:35:01 2013
@@ -32,6 +32,8 @@ public final class OAuthConstants {
     public static final String ACCESS_TOKEN = "access_token";
     public static final String ACCESS_TOKEN_TYPE = "token_type";
     public static final String ACCESS_TOKEN_EXPIRES_IN = "expires_in";
+    // CXF-Specific
+    public static final String ACCESS_TOKEN_ISSUED_AT = "issued_at";
     public static final String GRANT_TYPE = "grant_type";
     public static final String RESPONSE_TYPE = "response_type";
     public static final String TOKEN_RESPONSE_TYPE = "token";
@@ -47,7 +49,9 @@ public final class OAuthConstants {
     // Well-known token types
     public static final String BEARER_TOKEN_TYPE = "bearer";
     public static final String MAC_TOKEN_TYPE = "mac";
-    
+    // CXF-specific
+    public static final String REFRESH_TOKEN_TYPE = "refresh";
+        
     // MAC token parameters
     // Set by Access Token Service
     public static final String MAC_TOKEN_KEY = "mac_key";
@@ -103,11 +107,6 @@ public final class OAuthConstants {
     public static final String REVOKED_TOKEN_TYPE_HINT = "token_type_hint";
     public static final String UNSUPPORTED_TOKEN_TYPE = "unsupported_token_type";
     
-    // CXF-Specific parameters
-    public static final String ACCESS_TOKEN_ISSUED_AT = "issued_at";
-    // End Of CXF-Specific
-    
-    
     
     private OAuthConstants() {
     }



Mime
View raw message