From a68a4f97967c3a876b2b805903e4a5bcf1772713 Mon Sep 17 00:00:00 2001 From: Amanda Anganes Date: Wed, 8 Aug 2012 09:39:28 -0400 Subject: [PATCH] Organized ClientDetailsEntity, updated JPA annotations. Updated sql files to match. Naming conventions: table and column names with multiple words should be seperated by underscores; table and column names should be singular. --- .../oauth2/model/ClientDetailsEntity.java | 290 ++++++++++-------- .../db/tables/authorities.sql | 4 - openid-connect-server/db/tables/authority.sql | 4 + .../db/tables/authorized_grant_type.sql | 4 + .../db/tables/clientdetails.sql | 38 ++- openid-connect-server/db/tables/contact.sql | 4 + .../db/tables/granttypes.sql | 4 - .../db/tables/redirect_uri.sql | 4 + .../db/tables/redirect_uris.sql | 4 - .../db/tables/resource_id.sql | 4 + .../db/tables/resource_ids.sql | 4 - 11 files changed, 211 insertions(+), 153 deletions(-) delete mode 100644 openid-connect-server/db/tables/authorities.sql create mode 100644 openid-connect-server/db/tables/authority.sql create mode 100644 openid-connect-server/db/tables/authorized_grant_type.sql create mode 100644 openid-connect-server/db/tables/contact.sql delete mode 100644 openid-connect-server/db/tables/granttypes.sql create mode 100644 openid-connect-server/db/tables/redirect_uri.sql delete mode 100644 openid-connect-server/db/tables/redirect_uris.sql create mode 100644 openid-connect-server/db/tables/resource_id.sql delete mode 100644 openid-connect-server/db/tables/resource_ids.sql diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java index d2df3cbe3..722f47842 100644 --- a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java +++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java @@ -25,6 +25,7 @@ import java.util.Set; import javax.persistence.Basic; import javax.persistence.CollectionTable; +import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -266,7 +267,6 @@ public class ClientDetailsEntity implements ClientDetails { } /** - * * @return the id */ @Id @@ -283,109 +283,6 @@ public class ClientDetailsEntity implements ClientDetails { this.id = id; } - /** - * @return the clientId - */ - @Basic - public String getClientId() { - return clientId; - } - - /** - * @param clientId The OAuth2 client_id, must be unique to this client - */ - public void setClientId(String clientId) { - this.clientId = clientId; - } - - /** - * @return the clientSecret - */ - @Basic - public String getClientSecret() { - return clientSecret; - } - - /** - * @param clientSecret the OAuth2 client_secret (optional) - */ - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - /** - * @return the scope - */ - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable( - name="scope", - joinColumns=@JoinColumn(name="owner_id") - ) - public Set getScope() { - return scope; - } - - /** - * @param scope the set of scopes allowed to be issued to this client - */ - public void setScope(Set scope) { - this.scope = scope; - } - - /** - * @return the authorizedGrantTypes - */ - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable( - name="authorizedgranttypes", - joinColumns=@JoinColumn(name="owner_id") - ) - public Set getAuthorizedGrantTypes() { - return authorizedGrantTypes; - } - - /** - * @param authorizedGrantTypes the OAuth2 grant types that this client is allowed to use - */ - public void setAuthorizedGrantTypes(Set authorizedGrantTypes) { - this.authorizedGrantTypes = authorizedGrantTypes; - } - - /** - * @return the authorities - */ - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable( - name="authorities", - joinColumns=@JoinColumn(name="owner_id") - ) - public Set getAuthorities() { - return authorities; - } - - /** - * @param authorities the Spring Security authorities this client is given - */ - public void setAuthorities(Set authorities) { - this.authorities = authorities; - } - - /** - * If the clientSecret is not null, then it is always required. - */ - @Override - public boolean isSecretRequired() { - return getClientSecret() != null; - } - - /** - * If the scope list is not null or empty, then this client has been scoped. - */ - @Override - public boolean isScoped() { - return getScope() != null && !getScope().isEmpty(); - } - /** * @return the clientDescription */ @@ -415,6 +312,140 @@ public class ClientDetailsEntity implements ClientDetails { public void setAllowRefresh(Boolean allowRefresh) { this.allowRefresh = allowRefresh; } + + @Basic + public Boolean isAllowMultipleAccessTokens() { + return allowMultipleAccessTokens; + } + + public void setAllowMultipleAccessTokens(Boolean allowMultipleAccessTokens) { + this.allowMultipleAccessTokens = allowMultipleAccessTokens; + } + + @Basic + public Boolean isReuseRefreshToken() { + return reuseRefreshToken; + } + + public void setReuseRefreshToken(Boolean reuseRefreshToken) { + this.reuseRefreshToken = reuseRefreshToken; + } + + + + + + /** + * If the clientSecret is not null, then it is always required. + */ + @Override + @Transient + public boolean isSecretRequired() { + return getClientSecret() != null; + } + + /** + * If the scope list is not null or empty, then this client has been scoped. + */ + @Override + @Transient + public boolean isScoped() { + return getScope() != null && !getScope().isEmpty(); + } + + /** + * @return the clientId + */ + @Basic + @Override + public String getClientId() { + return clientId; + } + + /** + * @param clientId The OAuth2 client_id, must be unique to this client + */ + public void setClientId(String clientId) { + this.clientId = clientId; + } + + /** + * @return the clientSecret + */ + @Basic + @Override + public String getClientSecret() { + return clientSecret; + } + + /** + * @param clientSecret the OAuth2 client_secret (optional) + */ + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + /** + * @return the scope + */ + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name="scope", + joinColumns=@JoinColumn(name="owner_id") + ) + @Override + public Set getScope() { + return scope; + } + + /** + * @param scope the set of scopes allowed to be issued to this client + */ + public void setScope(Set scope) { + this.scope = scope; + } + + /** + * @return the authorizedGrantTypes + */ + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name="authorized_grant_type", + joinColumns=@JoinColumn(name="owner_id") + ) + @Override + @Column(name="authorized_grant_type") + public Set getAuthorizedGrantTypes() { + return authorizedGrantTypes; + } + + /** + * @param authorizedGrantTypes the OAuth2 grant types that this client is allowed to use + */ + public void setAuthorizedGrantTypes(Set authorizedGrantTypes) { + this.authorizedGrantTypes = authorizedGrantTypes; + } + + /** + * @return the authorities + */ + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name="authority", + joinColumns=@JoinColumn(name="owner_id") + ) + @Override + @Column(name="authority") + public Set getAuthorities() { + return authorities; + } + + /** + * @param authorities the Spring Security authorities this client is given + */ + public void setAuthorities(Set authorities) { + this.authorities = authorities; + } @Override @Basic @@ -429,7 +460,6 @@ public class ClientDetailsEntity implements ClientDetails { this.accessTokenValiditySeconds = accessTokenValiditySeconds; } - @Override @Basic public Integer getRefreshTokenValiditySeconds() { @@ -443,25 +473,15 @@ public class ClientDetailsEntity implements ClientDetails { this.refreshTokenValiditySeconds = refreshTokenValiditySeconds; } - /** - * We're not using this field, so it is not stored with JPA. - * - * @return an empty map - */ - @Override - @Transient - public Map getAdditionalInformation() { - return this.additionalInformation; - } - - /** + /** * @return the registeredRedirectUri */ @ElementCollection(fetch = FetchType.EAGER) @CollectionTable( - name="redirect_uris", + name="redirect_uri", joinColumns=@JoinColumn(name="owner_id") ) + @Column(name="redirect_uri") public Set getRegisteredRedirectUri() { return registeredRedirectUri; } @@ -481,6 +501,7 @@ public class ClientDetailsEntity implements ClientDetails { name="resource_ids", joinColumns=@JoinColumn(name="owner_id") ) + @Column(name="resource_id") public Set getResourceIds() { return resourceIds; } @@ -492,23 +513,21 @@ public class ClientDetailsEntity implements ClientDetails { this.resourceIds = resourceIds; } - @Basic - public Boolean isAllowMultipleAccessTokens() { - return allowMultipleAccessTokens; + + /** + * This library does not make use of this field, so it is not + * stored using our persistence layer. + * + * @return an empty map + */ + @Override + @Transient + public Map getAdditionalInformation() { + return this.additionalInformation; } - public void setAllowMultipleAccessTokens(Boolean allowMultipleAccessTokens) { - this.allowMultipleAccessTokens = allowMultipleAccessTokens; - } + - @Basic - public Boolean isReuseRefreshToken() { - return reuseRefreshToken; - } - - public void setReuseRefreshToken(Boolean reuseRefreshToken) { - this.reuseRefreshToken = reuseRefreshToken; - } @Basic public AppType getApplicationType() { @@ -546,7 +565,12 @@ public class ClientDetailsEntity implements ClientDetails { this.userIdType = userIdType; } - @Basic + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name="contact", + joinColumns=@JoinColumn(name="owner_id") + ) + @Column(name="contact") public Set getContacts() { return contacts; } diff --git a/openid-connect-server/db/tables/authorities.sql b/openid-connect-server/db/tables/authorities.sql deleted file mode 100644 index f9b18fc7f..000000000 --- a/openid-connect-server/db/tables/authorities.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE authorities ( - owner_id VARCHAR(4096), - authorities LONGBLOB -); \ No newline at end of file diff --git a/openid-connect-server/db/tables/authority.sql b/openid-connect-server/db/tables/authority.sql new file mode 100644 index 000000000..f56c3ab40 --- /dev/null +++ b/openid-connect-server/db/tables/authority.sql @@ -0,0 +1,4 @@ +CREATE TABLE authority ( + owner_id VARCHAR(4096), + authority LONGBLOB +); \ No newline at end of file diff --git a/openid-connect-server/db/tables/authorized_grant_type.sql b/openid-connect-server/db/tables/authorized_grant_type.sql new file mode 100644 index 000000000..16997f991 --- /dev/null +++ b/openid-connect-server/db/tables/authorized_grant_type.sql @@ -0,0 +1,4 @@ +CREATE TABLE authorized_grant_type ( + owner_id VARCHAR(256), + authorized_grant_type VARCHAR(2000) +); \ No newline at end of file diff --git a/openid-connect-server/db/tables/clientdetails.sql b/openid-connect-server/db/tables/clientdetails.sql index 881b31797..ab272fb83 100644 --- a/openid-connect-server/db/tables/clientdetails.sql +++ b/openid-connect-server/db/tables/clientdetails.sql @@ -1,11 +1,41 @@ CREATE TABLE clientdetails ( id VARCHAR(256), + clientDescription VARCHAR(256), + allowRefresh TINYINT, + allowMultipleAccessTokens TINYINT, + reuseRefreshTokens TINYINT, + clientId VARCHAR(256), clientSecret VARCHAR(2000), - clientName VARCHAR(256), - clientDescription VARCHAR(2000), - allowRefresh TINYINT, accessTokenValiditySeconds BIGINT, refreshTokenValiditySeconds BIGINT, - owner VARCHAR(256) + + applicationType VARCHAR(256), + applicationName VARCHAR(256), + tokenEndpointAuthType VARCHAR(256), + userIdType VARCHAR(256), + + logoUrl VARCHAR(256), + policyUrl VARCHAR(256), + jwkUrl VARCHAR(256), + jwkEncryptionUrl VARCHAR(256), + x509Url VARCHAR(256) + x509EncryptionUrl VARCHAR(256), + sectorIdentifierUrl VARCHAR(256), + + requreSignedRequestObject VARCHAR(256), + + userInfoSignedResponseAlg VARCHAR(256), + userInfoEncryptedResponseAlg VARCHAR(256), + userInfoEncryptedResponseEnc VARCHAR(256), + userInfoEncryptedResponseInt VARCHAR(256), + + idTokenSignedResponseAlg VARCHAR(256), + idTokenEncryptedResponseAlg VARCHAR(256), + idTokenEncryptedResponseEnc VARCHAR(256), + idTokenEncryptedResponseInt VARCHAR(256), + + defaultMaxAge BIGINT, + requireAuthTime TINYINT, + defaultACR VARCHAR(256) ); \ No newline at end of file diff --git a/openid-connect-server/db/tables/contact.sql b/openid-connect-server/db/tables/contact.sql new file mode 100644 index 000000000..abda041fe --- /dev/null +++ b/openid-connect-server/db/tables/contact.sql @@ -0,0 +1,4 @@ +CREATE TABLE contact { + owner_id VARCHAR(256), + contact VARCHAR(256) +} \ No newline at end of file diff --git a/openid-connect-server/db/tables/granttypes.sql b/openid-connect-server/db/tables/granttypes.sql deleted file mode 100644 index c288fe481..000000000 --- a/openid-connect-server/db/tables/granttypes.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE authorizedgranttypes ( - owner_id VARCHAR(256), - authorizedgranttypes VARCHAR(2000) -); \ No newline at end of file diff --git a/openid-connect-server/db/tables/redirect_uri.sql b/openid-connect-server/db/tables/redirect_uri.sql new file mode 100644 index 000000000..b443573e3 --- /dev/null +++ b/openid-connect-server/db/tables/redirect_uri.sql @@ -0,0 +1,4 @@ +CREATE TABLE redirect_uri ( + owner_id VARCHAR(256), + redirect_uri VARCHAR(2000) +); \ No newline at end of file diff --git a/openid-connect-server/db/tables/redirect_uris.sql b/openid-connect-server/db/tables/redirect_uris.sql deleted file mode 100644 index 08d3c0126..000000000 --- a/openid-connect-server/db/tables/redirect_uris.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE redirect_uris ( - owner_id VARCHAR(256), - registeredRedirectUri VARCHAR(2000) -); \ No newline at end of file diff --git a/openid-connect-server/db/tables/resource_id.sql b/openid-connect-server/db/tables/resource_id.sql new file mode 100644 index 000000000..454f4ee4a --- /dev/null +++ b/openid-connect-server/db/tables/resource_id.sql @@ -0,0 +1,4 @@ +CREATE TABLE resource_id ( + owner_id VARCHAR(256), + resource_id VARCHAR(256) +); \ No newline at end of file diff --git a/openid-connect-server/db/tables/resource_ids.sql b/openid-connect-server/db/tables/resource_ids.sql deleted file mode 100644 index 482a9d129..000000000 --- a/openid-connect-server/db/tables/resource_ids.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE resource_ids ( - owner_id VARCHAR(256), - resourceids VARCHAR(256) -); \ No newline at end of file