Commit b214fa7b authored by Matija Obreza's avatar Matija Obreza

Refactored OAuth JPA model

parent d3935972
cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.add_serial_version_id=false
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=false
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_parentheses_in_expressions=true
cleanup.always_use_this_for_non_static_field_access=true
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_to_enhanced_for_loop=true
cleanup.correct_indentation=false
cleanup.format_source_code=false
cleanup.convert_to_enhanced_for_loop=false
cleanup.correct_indentation=true
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=false
cleanup.make_parameters_final=true
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.never_use_parentheses_in_expressions=false
cleanup.organize_imports=true
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
......@@ -40,16 +40,16 @@ cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members=true
cleanup.sort_members_all=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_parentheses_in_expressions=true
cleanup.use_this_for_non_static_field_access=false
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=false
cleanup.use_this_for_non_static_method_access=false
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Crophub
cleanup_profile=_genesys2
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_Crophub
......
......@@ -20,46 +20,51 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.genesys2.server.model.HibernateModel;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.util.SerializationUtils;
import org.genesys2.server.model.BusinessModel;
@Entity
@Table(name = "oauth_access_token")
public class OAuthAccessToken implements HibernateModel {
@Table(name = "oauthaccesstoken")
public class OAuthAccessToken extends BusinessModel implements OAuthToken {
private static final long serialVersionUID = -424404058531521676L;
@Id
@Column(name = "token_id", unique = true, nullable = false)
private String tokenId;
@Column(nullable = false)
private String clientId;
@Lob
@Column(name = "token")
private byte[] token;
@Column(length = 36)
private String refreshToken;
@Column(name = "authentication_id")
private String authenticationId;
@Column
private Date createdDate;
@Column(name = "user_name")
private String userName;
@Temporal(TemporalType.TIMESTAMP)
@Column
private Date expiration;
@Column(name = "client_id")
private String clientId;
@Column(length = 100)
private String tokenType;
@Lob
@Column(name = "authentication")
private byte[] authentication;
@Column(length = 100, nullable = false)
private String value;
@Column(name = "refresh_token")
private String refreshToken;
@Column(length = 100)
private String scopes;
@Column(name = "created_date")
private Date createdDate;
@Column(length = 500)
private String additionalInfo;
@Column(length = 64)
private String userUuid;
@Column(length = 200)
private String redirectUri;
@Column(length = 200, nullable = false, unique = true)
private String authenticationId;
public Date getCreatedDate() {
return createdDate;
......@@ -69,111 +74,83 @@ public class OAuthAccessToken implements HibernateModel {
this.createdDate = createdDate;
}
public String getTokenId() {
return tokenId;
public String getAuthenticationId() {
return authenticationId;
}
public void setTokenId(String tokenId) {
this.tokenId = tokenId;
public void setAuthenticationId(String authenticationId) {
this.authenticationId = authenticationId;
}
public byte[] getToken() {
return token;
public String getClientId() {
return clientId;
}
public void setToken(byte[] token) {
this.token = token;
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getAuthenticationId() {
return authenticationId;
public String getRefreshToken() {
return refreshToken;
}
public void setAuthenticationId(String authenticationId) {
this.authenticationId = authenticationId;
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public String getUserName() {
return userName;
public void setExpiration(Date expiration) {
this.expiration = expiration;
}
public void setUserName(String userName) {
this.userName = userName;
public Date getExpiration() {
return expiration;
}
public String getClientId() {
return clientId;
public void setTokenType(String tokenType) {
this.tokenType = tokenType;
}
public void setClientId(String clientId) {
this.clientId = clientId;
public String getTokenType() {
return tokenType;
}
public byte[] getAuthentication() {
return authentication;
public void setValue(String value) {
this.value = value;
}
public void setAuthentication(byte[] authentication) {
this.authentication = authentication;
public String getValue() {
return value;
}
public String getRefreshToken() {
return refreshToken;
public void setScopes(String scopes) {
this.scopes = scopes;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
public String getScopes() {
return scopes;
}
public void setAdditionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
}
public String getAdditionalInfo() {
return additionalInfo;
}
public void setUserUuid(String uuid) {
this.userUuid = uuid;
}
public String getUserUuid() {
return userUuid;
}
public String getRedirectUri() {
return redirectUri;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof OAuthAccessToken)) {
return false;
}
final OAuthAccessToken that = (OAuthAccessToken) o;
if (authentication != null ? !authentication.equals(that.authentication) : that.authentication != null) {
return false;
}
if (authenticationId != null ? !authenticationId.equals(that.authenticationId) : that.authenticationId != null) {
return false;
}
if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) {
return false;
}
if (refreshToken != null ? !refreshToken.equals(that.refreshToken) : that.refreshToken != null) {
return false;
}
if (token != null ? !token.equals(that.token) : that.token != null) {
return false;
}
if (tokenId != null ? !tokenId.equals(that.tokenId) : that.tokenId != null) {
return false;
}
if (userName != null ? !userName.equals(that.userName) : that.userName != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = tokenId != null ? tokenId.hashCode() : 0;
result = 31 * result + (token != null ? token.hashCode() : 0);
result = 31 * result + (authenticationId != null ? authenticationId.hashCode() : 0);
result = 31 * result + (userName != null ? userName.hashCode() : 0);
result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
result = 31 * result + (authentication != null ? authentication.hashCode() : 0);
result = 31 * result + (refreshToken != null ? refreshToken.hashCode() : 0);
return result;
}
public OAuth2AccessToken getAccessToken() {
return SerializationUtils.deserialize(this.token);
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
}
......@@ -16,29 +16,16 @@
package org.genesys2.server.model.oauth;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.genesys2.server.model.HibernateModel;
import org.genesys2.server.model.BusinessModel;
@Entity
@Table(name = "oauth_client_token")
public class OAuthClientToken implements HibernateModel {
private static final long serialVersionUID = 8810301060389684282L;
@Id
@Column(name = "token_id", unique = true, nullable = false)
private String tokenId;
@Lob
@Column(name = "token")
private Blob token;
@Table(name = "oauthclienttoken")
public class OAuthClientToken extends BusinessModel {
@Column(name = "authentication_id")
private String authenticationId;
......@@ -48,22 +35,6 @@ public class OAuthClientToken implements HibernateModel {
@Column(name = "client_id")
private String clientId;
public String getTokenId() {
return tokenId;
}
public void setTokenId(String tokenId) {
this.tokenId = tokenId;
}
public Blob getToken() {
return token;
}
public void setToken(Blob token) {
this.token = token;
}
public String getAuthenticationId() {
return authenticationId;
}
......@@ -87,44 +58,4 @@ public class OAuthClientToken implements HibernateModel {
public void setClientId(String clientId) {
this.clientId = clientId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof OAuthClientToken)) {
return false;
}
final OAuthClientToken that = (OAuthClientToken) o;
if (authenticationId != null ? !authenticationId.equals(that.authenticationId) : that.authenticationId != null) {
return false;
}
if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) {
return false;
}
if (token != null ? !token.equals(that.token) : that.token != null) {
return false;
}
if (tokenId != null ? !tokenId.equals(that.tokenId) : that.tokenId != null) {
return false;
}
if (userName != null ? !userName.equals(that.userName) : that.userName != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = tokenId != null ? tokenId.hashCode() : 0;
result = 31 * result + (token != null ? token.hashCode() : 0);
result = 31 * result + (authenticationId != null ? authenticationId.hashCode() : 0);
result = 31 * result + (userName != null ? userName.hashCode() : 0);
result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
return result;
}
}
......@@ -29,11 +29,11 @@ import org.genesys2.server.model.BusinessModel;
/**
* Verification code model
*
*
* @author matijaobreza
*/
@Entity
@Table(name = "oauth_code")
@Table(name = "oauthcode")
public class OAuthCode extends BusinessModel {
private static final long serialVersionUID = 8018089692223912764L;
......@@ -47,6 +47,18 @@ public class OAuthCode extends BusinessModel {
@Temporal(TemporalType.TIMESTAMP)
private Date createdDate;
@Column(length = 36, nullable = false)
private String userUuid;
@Column(length = 100, nullable = false)
private String clientId;
@Column(length = 200)
private String redirectUri;
@Column(length = 100)
private String scopes;
public OAuthCode() {
createdDate = new Date();
}
......@@ -74,4 +86,36 @@ public class OAuthCode extends BusinessModel {
public byte[] getAuthentication() {
return authentication;
}
public void setUserUuid(String uuid) {
this.userUuid = uuid;
}
public String getUserUuid() {
return userUuid;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientId() {
return clientId;
}
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
public String getRedirectUri() {
return redirectUri;
}
public String getScopes() {
return this.scopes;
}
public void setScopes(String scopes) {
this.scopes = scopes;
}
}
......@@ -16,84 +16,101 @@
package org.genesys2.server.model.oauth;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.genesys2.server.model.HibernateModel;
import org.genesys2.server.model.BusinessModel;
import org.springframework.security.oauth2.common.DefaultExpiringOAuth2RefreshToken;
import org.springframework.security.oauth2.common.DefaultOAuth2RefreshToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
@Entity
@Table(name = "oauth_refresh_token")
public class OAuthRefreshToken implements HibernateModel {
@Table(name = "oauthrefreshtoken")
public class OAuthRefreshToken extends BusinessModel implements OAuthToken {
private static final long serialVersionUID = -5779707306510231956L;
@Id
@Column(name = "token_id", unique = true, nullable = false)
private String tokenId;
@Column(length = 128, nullable = false)
private String value;
@Temporal(TemporalType.TIMESTAMP)
private Date expiration;
@Column
private String clientId;
@Lob
@Column(name = "token")
private byte[] token;
@Column(length = 100)
private String scopes;
@Lob
@Column(name = "authentication")
private byte[] authentication;
@Column(length = 64)
private String userUuid;
public String getTokenId() {
return tokenId;
@Column(length = 200)
private String redirectUri;
@Override
public String getClientId() {
return this.clientId;
}
public void setTokenId(String tokenId) {
this.tokenId = tokenId;
public Date getExpiration() {
return this.expiration;
}
public byte[] getToken() {
return token;
@Override
public String getRedirectUri() {
return this.redirectUri;
}
public void setToken(byte[] bs) {
this.token = bs;
@Override
public String getScopes() {
return this.scopes;
}
public byte[] getAuthentication() {
return authentication;
@Override
public String getUserUuid() {
return this.userUuid;
}
public void setAuthentication(byte[] authentication) {
this.authentication = authentication;
public String getValue() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof OAuthRefreshToken)) {
return false;
}
public void setClientId(final String clientId) {
this.clientId = clientId;
}
final OAuthRefreshToken that = (OAuthRefreshToken) o;
public void setExpiration(final Date expiration) {
this.expiration = expiration;
}
if (authentication != null ? !authentication.equals(that.authentication) : that.authentication != null) {
return false;
}
if (token != null ? !token.equals(that.token) : that.token != null) {
return false;