cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5705] Renaming ClientCredential to ClientKey
Date Wed, 30 Apr 2014 09:43:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a6eaa6b0e -> b4c365203


[CXF-5705] Renaming ClientCredential to ClientKey


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

Branch: refs/heads/master
Commit: b4c365203916ee977e8b2261eac7f46efbfdada5
Parents: a6eaa6b
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Apr 30 10:43:00 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Apr 30 10:43:00 2014 +0100

----------------------------------------------------------------------
 .../cxf/rs/security/oauth2/common/Client.java   | 22 +++---
 .../oauth2/common/ClientCredential.java         | 83 --------------------
 .../rs/security/oauth2/common/ClientKey.java    | 83 ++++++++++++++++++++
 .../oauth2/services/AbstractTokenService.java   | 26 +++---
 .../services/AuthorizationCodeGrantService.java |  2 +-
 .../oauth2/utils/ModelEncryptionSupport.java    |  9 +--
 .../oauth2/utils/EncryptionUtilsTest.java       |  2 +-
 .../security/oauth2/OAuthDataProviderImpl.java  |  4 +-
 8 files changed, 115 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/Client.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/Client.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/Client.java
index a6d81f2..f58d38c 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/Client.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/Client.java
@@ -32,7 +32,7 @@ public class Client implements Serializable {
     private static final long serialVersionUID = -5550840247125850922L;
     
     private String clientId;
-    private ClientCredential clientCred;
+    private ClientKey clientKey;
     
     private String applicationName;
     private String applicationDescription;
@@ -52,30 +52,30 @@ public class Client implements Serializable {
         
     }
     
-    public Client(String clientId, String clientCred, boolean isConfidential) {
+    public Client(String clientId, String clientSecret, boolean isConfidential) {
         this.clientId = clientId;
-        this.clientCred = clientCred == null ? null : new ClientCredential(clientCred);
+        this.clientKey = clientSecret == null ? null : new ClientKey(clientSecret);
         this.isConfidential = isConfidential;
     }
 
     public Client(String clientId, 
-                  String clientCred,
+                  String clientSecret,
                   boolean isConfidential,
                   String applicationName,
                   String applicationWebUri) {
-        this(clientId, clientCred, isConfidential);
+        this(clientId, clientSecret, isConfidential);
         this.applicationName = applicationName;
         this.applicationWebUri = applicationWebUri;
         
     }
     
     public Client(String clientId, 
-                  ClientCredential clientCred,
+                  ClientKey clientKey,
                   boolean isConfidential,
                   String applicationName,
                   String applicationWebUri) {
         this.clientId = clientId;
-        this.clientCred = clientCred;
+        this.clientKey = clientKey;
         this.isConfidential = isConfidential;
         this.applicationName = applicationName;
         this.applicationWebUri = applicationWebUri;
@@ -99,12 +99,12 @@ public class Client implements Serializable {
      * it has to be a Base64 encoded representation
      * @return the credential
      */
-    public ClientCredential getClientCredential() {
-        return clientCred;
+    public ClientKey getClientKey() {
+        return clientKey;
     }
 
-    public void setClientCredential(ClientCredential cred) {
-        this.clientCred = cred;
+    public void setClientKey(ClientKey key) {
+        this.clientKey = key;
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientCredential.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientCredential.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientCredential.java
deleted file mode 100644
index d21e84c..0000000
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientCredential.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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.common;
-
-import java.io.Serializable;
-
-public class ClientCredential implements Serializable {
-    private static final long serialVersionUID = 6151645789585333184L;
-    public enum Type {
-        PASSWORD,
-        X509CERTIFICATE,
-        PUBLIC_KEY
-    }
-    
-    private String credential;
-    private Type type;
-    
-    public ClientCredential() {
-        
-    }
-    
-    public ClientCredential(String password) {
-        this(password, Type.PASSWORD);
-    }
-    
-    public ClientCredential(Type type) {
-        this(null, type);
-    }
-    
-    public ClientCredential(String cred, Type type) {
-        this.credential = cred;
-        this.type = type;
-    }
-
-    public String getCredential() {
-        return credential;
-    }
-
-    public void setCredential(String credential) {
-        this.credential = credential;
-    }
-
-    public Type getType() {
-        return type;
-    }
-
-    public void setType(Type type) {
-        this.type = type;
-    }
-    
-    public int hashCode() {
-        return (credential == null ? 37 : credential.hashCode()) * type.hashCode(); 
-    }
-    public boolean equals(Object obj) {
-        if (obj instanceof ClientCredential) {
-            ClientCredential other = (ClientCredential)obj;
-            if (this.credential == null && other.credential != null
-                || this.credential != null && other.credential == null) {
-                return false;
-            }
-            return this.credential.equals(other.credential) && this.type.equals(other.type);
-        } else {
-            return false;
-        }
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientKey.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientKey.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientKey.java
new file mode 100644
index 0000000..f7f94f3
--- /dev/null
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/ClientKey.java
@@ -0,0 +1,83 @@
+/**
+ * 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.common;
+
+import java.io.Serializable;
+
+public class ClientKey implements Serializable {
+    private static final long serialVersionUID = 6151645789585333184L;
+    public enum Type {
+        PASSWORD,
+        X509CERTIFICATE,
+        PUBLIC_KEY
+    }
+    
+    private String credential;
+    private Type type;
+    
+    public ClientKey() {
+        
+    }
+    
+    public ClientKey(String password) {
+        this(password, Type.PASSWORD);
+    }
+    
+    public ClientKey(Type type) {
+        this(null, type);
+    }
+    
+    public ClientKey(String cred, Type type) {
+        this.credential = cred;
+        this.type = type;
+    }
+
+    public String getCredential() {
+        return credential;
+    }
+
+    public void setCredential(String credential) {
+        this.credential = credential;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+    
+    public int hashCode() {
+        return (credential == null ? 37 : credential.hashCode()) * type.hashCode(); 
+    }
+    public boolean equals(Object obj) {
+        if (obj instanceof ClientKey) {
+            ClientKey other = (ClientKey)obj;
+            if (this.credential == null && other.credential != null
+                || this.credential != null && other.credential == null) {
+                return false;
+            }
+            return this.credential.equals(other.credential) && this.type.equals(other.type);
+        } else {
+            return false;
+        }
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractTokenService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractTokenService.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractTokenService.java
index 5c07464..3d19921 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractTokenService.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractTokenService.java
@@ -36,7 +36,7 @@ import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
-import org.apache.cxf.rs.security.oauth2.common.ClientCredential;
+import org.apache.cxf.rs.security.oauth2.common.ClientKey;
 import org.apache.cxf.rs.security.oauth2.common.OAuthError;
 import org.apache.cxf.rs.security.oauth2.provider.ClientIdProvider;
 import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
@@ -100,19 +100,19 @@ public class AbstractTokenService extends AbstractOAuthService {
     protected Client getAndValidateClientFromIdAndSecret(String clientId, String clientSecret)
{
         Client client = getClient(clientId);
         if (clientSecret != null 
-            && (client.getClientCredential().getType() == null 
-            || ClientCredential.Type.PASSWORD != client.getClientCredential().getType()))
{
+            && (client.getClientKey().getType() == null 
+            || ClientKey.Type.PASSWORD != client.getClientKey().getType())) {
             throw ExceptionUtils.toNotAuthorizedException(null, null);
         }
         if (canSupportPublicClients 
             && !client.isConfidential() 
-            && client.getClientCredential() == null 
+            && client.getClientKey() == null 
             && clientSecret == null) {
             return client;
         }
-        if (clientSecret == null || client.getClientCredential() == null 
+        if (clientSecret == null || client.getClientKey() == null 
             || !client.getClientId().equals(clientId) 
-            || !client.getClientCredential().getCredential().equals(clientSecret)) {
+            || !client.getClientKey().getCredential().equals(clientSecret)) {
             throw ExceptionUtils.toNotAuthorizedException(null, null);
         }
         return client;
@@ -158,24 +158,24 @@ public class AbstractTokenService extends AbstractOAuthService {
     }
     
     protected void validateTwoWayTlsClient(SecurityContext sc, TLSSessionInfo tlsSessionInfo,
Client client) {
-        ClientCredential.Type credType = client.getClientCredential().getType();
-        if (credType != ClientCredential.Type.X509CERTIFICATE 
-            && credType != ClientCredential.Type.PUBLIC_KEY) {
+        ClientKey.Type credType = client.getClientKey().getType();
+        if (credType != ClientKey.Type.X509CERTIFICATE 
+            && credType != ClientKey.Type.PUBLIC_KEY) {
             reportInvalidClient();
-        } else if (client.getClientCredential().getCredential() != null) {
+        } else if (client.getClientKey().getCredential() != null) {
             // Client has a Base64 encoded representation of the certificate loaded
             // so lets validate the TLS certificates
-            compareCertificates(tlsSessionInfo, client.getClientCredential().getCredential(),
credType);
+            compareCertificates(tlsSessionInfo, client.getClientKey().getCredential(), credType);
         }
     }
     
     protected void compareCertificates(TLSSessionInfo tlsInfo, 
                                        String base64EncodedCert,
-                                       ClientCredential.Type type) {
+                                       ClientKey.Type type) {
         Certificate[] clientCerts = tlsInfo.getPeerCertificates();
         try {
             X509Certificate cert = (X509Certificate)clientCerts[0];
-            byte[] encodedKey = type == ClientCredential.Type.PUBLIC_KEY 
+            byte[] encodedKey = type == ClientKey.Type.PUBLIC_KEY 
                 ? cert.getPublicKey().getEncoded() : cert.getEncoded();
             byte[] clientKey = Base64Utility.decode(base64EncodedCert);
             if (Arrays.equals(encodedKey, clientKey)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationCodeGrantService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationCodeGrantService.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationCodeGrantService.java
index a345204..ed3fa46 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationCodeGrantService.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationCodeGrantService.java
@@ -126,7 +126,7 @@ public class AuthorizationCodeGrantService extends RedirectionBasedGrantService
 
     @Override
     protected boolean canSupportPublicClient(Client c) {
-        return canSupportPublicClients && !c.isConfidential() && c.getClientCredential()
== null;
+        return canSupportPublicClients && !c.isConfidential() && c.getClientKey()
== null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/ModelEncryptionSupport.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/ModelEncryptionSupport.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/ModelEncryptionSupport.java
index 5d4a98d..b7ca8bc 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/ModelEncryptionSupport.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/ModelEncryptionSupport.java
@@ -31,7 +31,7 @@ import javax.crypto.SecretKey;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
-import org.apache.cxf.rs.security.oauth2.common.ClientCredential;
+import org.apache.cxf.rs.security.oauth2.common.ClientKey;
 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;
@@ -324,9 +324,8 @@ public final class ModelEncryptionSupport {
 
     private static Client recreateClientInternal(String sequence) {
         String[] parts = getParts(sequence);
-        ClientCredential clientCred = StringUtils.isEmpty(parts[1]) 
-            ? null : new ClientCredential(parts[1], 
-                                          ClientCredential.Type.valueOf(parts[2]));
+        ClientKey clientCred = StringUtils.isEmpty(parts[1]) ? null 
+            : new ClientKey(parts[1], ClientKey.Type.valueOf(parts[2]));
         Client c = new Client(parts[0], 
                               clientCred, 
                               Boolean.valueOf(parts[3]), 
@@ -346,7 +345,7 @@ public final class ModelEncryptionSupport {
         // 0: id
         state.append(tokenizeString(client.getClientId()));
         state.append(SEP);
-        ClientCredential cred = client.getClientCredential();
+        ClientKey cred = client.getClientKey();
         // 1: secret
         state.append(tokenizeString(cred == null ? null : cred.getCredential()));
         state.append(SEP);

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/EncryptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/EncryptionUtilsTest.java
b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/EncryptionUtilsTest.java
index 26f3100..ef44818 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/EncryptionUtilsTest.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/EncryptionUtilsTest.java
@@ -178,7 +178,7 @@ public class EncryptionUtilsTest extends Assert {
                                                   new ByteArrayInputStream(decrypted.getBytes()));
         
         assertEquals(c.getClientId(), c2.getClientId());
-        assertEquals(c.getClientCredential(), c2.getClientCredential());
+        assertEquals(c.getClientKey(), c2.getClientKey());
         assertTrue(c2.isConfidential());
         assertEquals("subject", c2.getSubject().getLogin());
         assertEquals("id", c2.getSubject().getId());

http://git-wip-us.apache.org/repos/asf/cxf/blob/b4c36520/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
index 3ec9f2b..ebbe428 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/OAuthDataProviderImpl.java
@@ -24,7 +24,7 @@ import java.util.Map;
 
 import org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration;
 import org.apache.cxf.rs.security.oauth2.common.Client;
-import org.apache.cxf.rs.security.oauth2.common.ClientCredential;
+import org.apache.cxf.rs.security.oauth2.common.ClientKey;
 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;
@@ -45,7 +45,7 @@ public class OAuthDataProviderImpl implements OAuthDataProvider {
         clients.put(client.getClientId(), client);
         
         Client client2 = new Client("CN=whateverhost.com,OU=Morpit,O=ApacheTest,L=Syracuse,C=US",

-                                    new ClientCredential(ClientCredential.Type.X509CERTIFICATE),
+                                    new ClientKey(ClientKey.Type.X509CERTIFICATE),
                                     true,
                                     null,
                                     null);


Mime
View raw message