cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf-fediz git commit: Switching OIDC provider to be EhCache based instead
Date Wed, 25 Nov 2015 17:28:32 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master bc638f45e -> ab2ef8660


Switching OIDC provider to be EhCache based instead


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

Branch: refs/heads/master
Commit: ab2ef8660aff3d115d069e2531eeb8218553b59e
Parents: bc638f4
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Nov 25 17:28:14 2015 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Nov 25 17:28:14 2015 +0000

----------------------------------------------------------------------
 .../service/oidc/ClientRegistrationService.java |  2 +-
 .../fediz/service/oidc/OAuthDataManager.java    | 62 +-------------------
 2 files changed, 3 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/ab2ef866/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
index e8bacd5..87c0381 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
@@ -95,7 +95,7 @@ public class ClientRegistrationService {
     }
     
     private Consumers registerNewClient(Client newClient) {
-        manager.registerClient(newClient);
+        manager.setClient(newClient);
         String userName = sc.getUserPrincipal().getName();
         Map<String, Consumer> userClientRegs = registrations.get(userName);
         if (userClientRegs == null) {

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/ab2ef866/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/OAuthDataManager.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/OAuthDataManager.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/OAuthDataManager.java
index 719c557..64a562e 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/OAuthDataManager.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/OAuthDataManager.java
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.cxf.fediz.core.FedizPrincipal;
 import org.apache.cxf.jaxrs.ext.MessageContext;
@@ -35,17 +34,16 @@ import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
 import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
-import org.apache.cxf.rs.security.oauth2.grants.code.AbstractCodeDataProvider;
 import org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeRegistration;
+import org.apache.cxf.rs.security.oauth2.grants.code.DefaultEHCacheCodeDataProvider;
 import org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant;
 import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
-import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
 import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
 import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils;
 import org.apache.cxf.rs.security.oidc.common.IdToken;
 import org.apache.cxf.rs.security.oidc.utils.OidcUtils;
 
-public class OAuthDataManager extends AbstractCodeDataProvider {
+public class OAuthDataManager extends DefaultEHCacheCodeDataProvider {
 
     private static final OAuthPermission OPENID_PERMISSION;
     private static final OAuthPermission REFRESH_TOKEN_PERMISSION;
@@ -58,14 +56,9 @@ public class OAuthDataManager extends AbstractCodeDataProvider {
             "Refresh access tokens");
     }
 
-    private static Map<String, Client> clients = new ConcurrentHashMap<String, Client>();
     private Map<String, OAuthPermission> permissionMap = new HashMap<String, OAuthPermission>();
     private MessageContext messageContext;
     private SamlTokenConverter tokenConverter = new LocalSamlTokenConverter();
-    private Map<String, ServerAccessToken> accessTokens = new ConcurrentHashMap<String,
ServerAccessToken>();
-    private Map<String, RefreshToken> refreshTokens = new ConcurrentHashMap<String,
RefreshToken>();
-    private Map<String, ServerAuthorizationCodeGrant> codeGrants = 
-            new ConcurrentHashMap<String, ServerAuthorizationCodeGrant>();
     private boolean signIdTokenWithClientSecret;
     
     
@@ -78,14 +71,6 @@ public class OAuthDataManager extends AbstractCodeDataProvider {
         this.permissionMap = permissionMap;
     }
     
-    public void registerClient(Client c) {
-        clients.put(c.getClientId(), c);
-    }
-
-    public Client getClient(String clientId) throws OAuthServiceException {
-        return clients.get(clientId);
-    }
-
     // Grants
     @Override
     public ServerAuthorizationCodeGrant createCodeGrant(AuthorizationCodeRegistration reg)

@@ -95,17 +80,6 @@ public class OAuthDataManager extends AbstractCodeDataProvider {
         return grant;
     }
     
-    @Override
-    protected void saveCodeGrant(ServerAuthorizationCodeGrant grant) {
-        codeGrants.put(grant.getCode(), grant);
-    }
-
-    
-    @Override
-    public ServerAuthorizationCodeGrant removeCodeGrant(String code) throws OAuthServiceException
{
-        return codeGrants.remove(code);
-    }
-
     // Access Tokens
     @Override
     public ServerAccessToken createAccessToken(AccessTokenRegistration reg)
@@ -115,38 +89,6 @@ public class OAuthDataManager extends AbstractCodeDataProvider {
         return token;
     }
     
-    @Override
-    protected void saveAccessToken(ServerAccessToken token) {
-        accessTokens.put(token.getTokenKey(), token);
-    }
-
-    
-    @Override
-    protected boolean revokeAccessToken(String tokenKey) {
-        return accessTokens.remove(tokenKey) != null;
-    }
-
-    @Override
-    public ServerAccessToken getAccessToken(String tokenId) throws OAuthServiceException
{
-        return accessTokens.get(tokenId);
-    }
-
-    // Refresh Tokens
-    @Override
-    protected void saveRefreshToken(ServerAccessToken accessToken, RefreshToken refreshToken)
{
-        refreshTokens.put(refreshToken.getTokenKey(), refreshToken);
-    }
-
-    @Override
-    protected RefreshToken revokeRefreshToken(Client c, String tokenKey) {
-        return refreshTokens.remove(tokenKey);
-    }
-
-    @Override
-    protected boolean isRefreshTokenSupported(List<String> theScopes) {
-        return theScopes.contains(OAuthConstants.REFRESH_TOKEN_SCOPE);
-    }
-
     // Scope to Permission conversion
     @Override
     public List<OAuthPermission> convertScopeToPermissions(Client client, List<String>
scopes)


Mime
View raw message