Repository: cxf Updated Branches: refs/heads/master 0b9ce1c16 -> aaabd57fb
Add equals/hashCode methods for OAuthPermission so that the containsAll call in AbstractOAuthDataProvider.doRefreshAccessToken works Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8583a24a Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8583a24a Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8583a24a Branch: refs/heads/master Commit: 8583a24ac541dc373503d7a6c59cd90890acdae3 Parents: 796fda4 Author: Colm O hEigeartaigh <[email protected]> Authored: Fri Dec 4 16:34:03 2015 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Fri Dec 4 16:35:04 2015 +0000 ---------------------------------------------------------------------- .../security/oauth2/common/OAuthPermission.java | 58 ++++++++++++++++++++ .../services/AbstractImplicitGrantService.java | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/8583a24a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/OAuthPermission.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/OAuthPermission.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/OAuthPermission.java index 1be8106..2b31fa8 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/OAuthPermission.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/common/OAuthPermission.java @@ -146,4 +146,62 @@ public class OAuthPermission implements Serializable { public void setInvisibleToClient(boolean invisibleToClient) { this.invisibleToClient = invisibleToClient; } + + @Override + public boolean equals(Object object) { + if (!(object instanceof OAuthPermission)) { + return false; + } + + OAuthPermission that = (OAuthPermission)object; + if (this.httpVerbs != null && that.httpVerbs == null + || this.httpVerbs == null && that.httpVerbs != null + || this.httpVerbs != null && !this.httpVerbs.equals(that.httpVerbs)) { + return false; + } + if (this.uris != null && that.uris == null + || this.uris == null && that.uris != null + || this.uris != null && !this.uris.equals(that.uris)) { + return false; + } + if (this.permission != null && that.permission == null + || this.permission == null && that.permission != null + || this.permission != null && !this.permission.equals(that.permission)) { + return false; + } + if (this.description != null && that.description == null + || this.description == null && that.description != null + || this.description != null && !this.description.equals(that.description)) { + return false; + } + if (this.invisibleToClient != that.invisibleToClient) { + return false; + } + if (this.isDefault != that.isDefault) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 17; + if (httpVerbs != null) { + hashCode = 31 * hashCode + httpVerbs.hashCode(); + } + if (uris != null) { + hashCode = 31 * hashCode + uris.hashCode(); + } + if (permission != null) { + hashCode = 31 * hashCode + permission.hashCode(); + } + if (description != null) { + hashCode = 31 * hashCode + description.hashCode(); + } + hashCode = 31 * hashCode + Boolean.hashCode(invisibleToClient); + hashCode = 31 * hashCode + Boolean.hashCode(isDefault); + + return hashCode; + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/8583a24a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractImplicitGrantService.java ---------------------------------------------------------------------- diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractImplicitGrantService.java b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractImplicitGrantService.java index 139c05b..cee77da 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractImplicitGrantService.java +++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractImplicitGrantService.java @@ -71,7 +71,7 @@ public abstract class AbstractImplicitGrantService extends RedirectionBasedGrant reg.setGrantType(super.getSupportedGrantType()); reg.setSubject(userSubject); reg.setRequestedScope(requestedScope); - if (approvedScope != null && approvedScope.isEmpty()) { + if (approvedScope == null || approvedScope.isEmpty()) { // no down-scoping done by a user, all of the requested scopes have been authorized reg.setApprovedScope(requestedScope); } else {
