cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Initial work toward linking Client and Consumer as suggested by Jan
Date Tue, 01 Dec 2015 12:30:34 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ec15e3580 -> 6d58c0742


Initial work toward linking Client and Consumer as suggested by Jan


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

Branch: refs/heads/master
Commit: 6d58c07420b09e1f617084661f03c418a5b4bed7
Parents: ec15e35
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Dec 1 12:30:20 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Dec 1 12:30:20 2015 +0000

----------------------------------------------------------------------
 .../oauth2/client/ClientCodeRequestFilter.java  |  2 +-
 .../cxf/rs/security/oauth2/client/Consumer.java | 75 ++++++++------------
 .../rs/security/oauth2/client/Consumers.java    | 40 -----------
 .../oauth2/client/OAuthClientUtils.java         |  8 +--
 .../cxf/rs/security/oidc/rp/IdTokenReader.java  |  4 +-
 5 files changed, 36 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6d58c074/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
index ae54e99..1af26c6 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
@@ -135,7 +135,7 @@ public class ClientCodeRequestFilter implements ContainerRequestFilter
{
         String redirectScope = redirectState != null ? redirectState.getFirst(OAuthConstants.SCOPE)
: null;
         String theScope = redirectScope != null ? redirectScope : scopes;
         UriBuilder ub = OAuthClientUtils.getAuthorizationURIBuilder(authorizationServiceUri,

-                                             consumer.getKey(), 
+                                             consumer.getClientId(), 
                                              getAbsoluteRedirectUri(ui).toString(), 
                                              theState, 
                                              theScope);

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d58c074/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumer.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumer.java
index e592ec9..f58c28a 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumer.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumer.java
@@ -18,80 +18,63 @@
  */
 package org.apache.cxf.rs.security.oauth2.client;
 
-import java.util.HashSet;
-import java.util.Set;
-
 public class Consumer {
 
-    private String key;
-    private String secret;
-    private Set<String> redirectURIs;
-    private String name;
-    private String description;
-
+    private String clientId;
+    private String clientSecret;
+    
     public Consumer() {
 
     }
 
-    public Consumer(String key, String secret) {
-        this.setKey(key);
-        this.setSecret(secret);
+    public Consumer(String id, String secret) {
+        this.clientId = id;
+        this.clientSecret = secret;
     }
 
+    @Deprecated
     public String getKey() {
-        return key;
+        return getClientId();
     }
 
+    @Deprecated
     public void setKey(String key) {
-        this.key = key;
+        setClientId(key);
+    }
+    
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String id) {
+        this.clientId = id;
     }
 
+    @Deprecated
     public String getSecret() {
-        return secret;
+        return getClientSecret();
     }
 
+    @Deprecated
     public void setSecret(String secret) {
-        this.secret = secret;
+        setClientSecret(secret);
     }
-
-    public String getDescription() {
-        return description;
+    public String getClientSecret() {
+        return clientSecret;
     }
 
-    public void setDescription(String description) {
-        this.description = description;
+    public void setClientSecret(String secret) {
+        this.clientSecret = secret;
     }
 
     @Override
     public int hashCode() {
-        return key.hashCode();
+        return clientId.hashCode();
     }
 
     @Override
     public boolean equals(Object o) {
-        return o instanceof Consumer && key.equals(((Consumer)o).key);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Set<String> getRedirectURIs() {
-        return redirectURIs;
-    }
-
-    public void setRedirectURIs(Set<String> redirectUri) {
-        this.redirectURIs = redirectUri;
-    }
-
-    public boolean addRedirectURI(String redirectURI) {
-        if (this.redirectURIs == null) {
-            this.redirectURIs = new HashSet<String>();
-        }
-        return this.redirectURIs.add(redirectURI);
+        return o instanceof Consumer && clientId.equals(((Consumer)o).clientId);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d58c074/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumers.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumers.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumers.java
deleted file mode 100644
index 1e28de7..0000000
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/Consumers.java
+++ /dev/null
@@ -1,40 +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.client;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class Consumers {
-    
-    private Set<Consumer> consumers = new HashSet<Consumer>();
-    public Consumers() {
-        
-    }
-    public Consumers(Consumers consumers) {
-        this(consumers.getConsumers());
-    }
-    public Consumers(Set<Consumer> consumers) {
-        this.consumers = consumers;
-    }
-
-    public Set<Consumer> getConsumers() {
-        return consumers;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d58c074/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtils.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtils.java
index 17471f8..9d19af9 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtils.java
@@ -282,21 +282,21 @@ public final class OAuthClientUtils {
             }
         }
         if (consumer != null) {
-            boolean secretAvailable = !StringUtils.isEmpty(consumer.getSecret());
+            boolean secretAvailable = !StringUtils.isEmpty(consumer.getClientSecret());
             if (setAuthorizationHeader && secretAvailable) {
                 StringBuilder sb = new StringBuilder();
                 sb.append("Basic ");
                 try {
-                    String data = consumer.getKey() + ":" + consumer.getSecret();
+                    String data = consumer.getClientId() + ":" + consumer.getClientSecret();
                     sb.append(Base64Utility.encode(data.getBytes(StandardCharsets.UTF_8)));
                 } catch (Exception ex) {
                     throw new ProcessingException(ex);
                 }
                 accessTokenService.replaceHeader("Authorization", sb.toString());
             } else {
-                form.param(OAuthConstants.CLIENT_ID, consumer.getKey());
+                form.param(OAuthConstants.CLIENT_ID, consumer.getClientId());
                 if (secretAvailable) {
-                    form.param(OAuthConstants.CLIENT_SECRET, consumer.getSecret());
+                    form.param(OAuthConstants.CLIENT_SECRET, consumer.getClientSecret());
                 }
             }
         } else {

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d58c074/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenReader.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenReader.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenReader.java
index 9072add..4c9071c 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenReader.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/IdTokenReader.java
@@ -41,8 +41,8 @@ public class IdTokenReader extends AbstractTokenValidator {
         return jwt;
     }
     public JwtToken getIdJwtToken(String idJwtToken, Consumer client) {
-        JwtToken jwt = getJwtToken(idJwtToken, client.getSecret());
-        validateJwtClaims(jwt.getClaims(), client.getKey(), true);
+        JwtToken jwt = getJwtToken(idJwtToken, client.getClientSecret());
+        validateJwtClaims(jwt.getClaims(), client.getClientId(), true);
         return jwt;
     }
     private IdToken getIdTokenFromJwt(JwtToken jwt) {


Mime
View raw message