fixing bugs; needed to make all ids BIGINT AUTO-INCREMENT PRIMARY KEY in sql files
parent
0757642e67
commit
49cb8bd0cb
|
@ -523,7 +523,7 @@ public class ClientDetailsEntity implements ClientDetails {
|
||||||
*/
|
*/
|
||||||
@ElementCollection(fetch = FetchType.EAGER)
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@CollectionTable(
|
@CollectionTable(
|
||||||
name="resource_ids",
|
name="resource_id",
|
||||||
joinColumns=@JoinColumn(name="owner_id")
|
joinColumns=@JoinColumn(name="owner_id")
|
||||||
)
|
)
|
||||||
@Column(name="resource_id")
|
@Column(name="resource_id")
|
||||||
|
|
|
@ -73,6 +73,9 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
|
|
||||||
private Jwt jwtValue; // JWT-encoded access token value
|
private Jwt jwtValue; // JWT-encoded access token value
|
||||||
|
|
||||||
|
//TODO should not need this
|
||||||
|
private String value;
|
||||||
|
|
||||||
private IdToken idToken; // JWT-encoded OpenID Connect IdToken
|
private IdToken idToken; // JWT-encoded OpenID Connect IdToken
|
||||||
|
|
||||||
private Date expiration;
|
private Date expiration;
|
||||||
|
@ -155,7 +158,8 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name="token_value")
|
@Column(name="token_value")
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return jwtValue.toString();
|
this.value = jwtValue.toString();
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,6 +169,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
* @throws IllegalArgumentException if "value" is not a properly formatted JWT string
|
* @throws IllegalArgumentException if "value" is not a properly formatted JWT string
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
setJwt(Jwt.parse(value));
|
setJwt(Jwt.parse(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +281,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
*/
|
*/
|
||||||
public void setJwt(Jwt jwt) {
|
public void setJwt(Jwt jwt) {
|
||||||
this.jwtValue = jwt;
|
this.jwtValue = jwt;
|
||||||
|
this.value = jwt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,7 @@ import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByClient", query = "select r from OAuth2RefreshTokenEntity r where r.client = :client"),
|
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByClient", query = "select r from OAuth2RefreshTokenEntity r where r.client = :client"),
|
||||||
@NamedQuery(name = "OAuth2RefreshTokenEntity.getExpired", query = "select r from OAuth2RefreshTokenEntity r where r.expiration is not null and r.expiration < current_timestamp"),
|
@NamedQuery(name = "OAuth2RefreshTokenEntity.getExpired", query = "select r from OAuth2RefreshTokenEntity r where r.expiration is not null and r.expiration < current_timestamp"),
|
||||||
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByTokenValue", query = "select r from OAuth2RefreshTokenEntity r where r.tokenValue = :tokenValue"),
|
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByTokenValue", query = "select r from OAuth2RefreshTokenEntity r where r.value = :tokenValue"),
|
||||||
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByAuthentication", query = "select r from OAuth2RefreshTokenEntity r where r.authenticationHolder.authentication = :authentication")
|
@NamedQuery(name = "OAuth2RefreshTokenEntity.getByAuthentication", query = "select r from OAuth2RefreshTokenEntity r where r.authenticationHolder.authentication = :authentication")
|
||||||
})
|
})
|
||||||
public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
|
@ -64,6 +64,9 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
//JWT-encoded representation of this access token entity
|
//JWT-encoded representation of this access token entity
|
||||||
private Jwt jwt;
|
private Jwt jwt;
|
||||||
|
|
||||||
|
//TOOD: shouldn't need this
|
||||||
|
private String value;
|
||||||
|
|
||||||
// our refresh tokens might expire
|
// our refresh tokens might expire
|
||||||
private Date expiration;
|
private Date expiration;
|
||||||
|
|
||||||
|
@ -117,7 +120,8 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name="token_value")
|
@Column(name="token_value")
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return jwt.toString();
|
value = jwt.toString();
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,6 +130,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
* @throws IllegalArgumentException if the value is not a valid JWT string
|
* @throws IllegalArgumentException if the value is not a valid JWT string
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
setJwt(Jwt.parse(value));
|
setJwt(Jwt.parse(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +206,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
*/
|
*/
|
||||||
public void setJwt(Jwt jwt) {
|
public void setJwt(Jwt jwt) {
|
||||||
this.jwt = jwt;
|
this.jwt = jwt;
|
||||||
|
this.value = jwt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.mitre.oauth2.model.ClientDetailsEntity;
|
||||||
|
|
||||||
public interface OAuth2ClientRepository {
|
public interface OAuth2ClientRepository {
|
||||||
|
|
||||||
|
public ClientDetailsEntity getById(Long id);
|
||||||
|
|
||||||
public ClientDetailsEntity getClientById(String clientId);
|
public ClientDetailsEntity getClientById(String clientId);
|
||||||
|
|
||||||
public ClientDetailsEntity saveClient(ClientDetailsEntity client);
|
public ClientDetailsEntity saveClient(ClientDetailsEntity client);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE access_token (
|
CREATE TABLE access_token (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
token_value VARCHAR(4096),
|
token_value VARCHAR(4096),
|
||||||
expiration TIMESTAMP,
|
expiration TIMESTAMP,
|
||||||
token_type VARCHAR(256),
|
token_type VARCHAR(256),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE approved_site (
|
CREATE TABLE approved_site (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
user_id VARCHAR(256),
|
user_id VARCHAR(256),
|
||||||
client_id VARCHAR(256),
|
client_id VARCHAR(256),
|
||||||
creation_date DATE,
|
creation_date DATE,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE authentication_holder (
|
CREATE TABLE authentication_holder (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
owner_id VARCHAR(256),
|
owner_id VARCHAR(256),
|
||||||
authentication LONGBLOB
|
authentication LONGBLOB
|
||||||
);
|
);
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE client_details (
|
CREATE TABLE client_details (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
client_description VARCHAR(256),
|
client_description VARCHAR(256),
|
||||||
allow_refresh TINYINT,
|
allow_refresh TINYINT,
|
||||||
allow_multiple_access_tokens TINYINT,
|
allow_multiple_access_tokens TINYINT,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE refresh_token (
|
CREATE TABLE refresh_token (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
token_value VARCHAR(4096),
|
token_value VARCHAR(4096),
|
||||||
expiration TIMESTAMP,
|
expiration TIMESTAMP,
|
||||||
client_id VARCHAR(256)
|
client_id VARCHAR(256)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
CREATE TABLE whitelisted_site (
|
CREATE TABLE whitelisted_site (
|
||||||
id VARCHAR(256),
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||||
creator_user_id VARCHAR(256),
|
creator_user_id VARCHAR(256),
|
||||||
client_id VARCHAR(256)
|
client_id VARCHAR(256)
|
||||||
);
|
);
|
|
@ -46,12 +46,18 @@ public class JpaOAuth2ClientRepository implements OAuth2ClientRepository {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientDetailsEntity getById(Long id) {
|
||||||
|
return manager.find(ClientDetailsEntity.class, id);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.mitre.oauth2.repository.OAuth2ClientRepository#getClientById(java.lang.String)
|
* @see org.mitre.oauth2.repository.OAuth2ClientRepository#getClientById(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ClientDetailsEntity getClientById(String clientId) {
|
public ClientDetailsEntity getClientById(String clientId) {
|
||||||
return manager.find(ClientDetailsEntity.class, clientId);
|
TypedQuery<ClientDetailsEntity> query = manager.createNamedQuery("ClientDetailsEntity.getByClientId", ClientDetailsEntity.class);
|
||||||
|
query.setParameter("clientId", clientId);
|
||||||
|
return JpaUtil.getSingleResult(query.getResultList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class ApprovedSiteServiceImpl implements ApprovedSiteService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public ApprovedSite save(ApprovedSite approvedSite) {
|
public ApprovedSite save(ApprovedSite approvedSite) {
|
||||||
return approvedSiteRepository.save(approvedSite);
|
return approvedSiteRepository.save(approvedSite);
|
||||||
}
|
}
|
||||||
|
@ -72,20 +73,23 @@ public class ApprovedSiteServiceImpl implements ApprovedSiteService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void remove(ApprovedSite approvedSite) {
|
public void remove(ApprovedSite approvedSite) {
|
||||||
approvedSiteRepository.remove(approvedSite);
|
approvedSiteRepository.remove(approvedSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void removeById(Long id) {
|
public void removeById(Long id) {
|
||||||
approvedSiteRepository.removeById(id);
|
approvedSiteRepository.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public ApprovedSite createApprovedSite(String clientId, String userId, Date timeoutDate, Set<String> allowedScopes,
|
public ApprovedSite createApprovedSite(String clientId, String userId, Date timeoutDate, Set<String> allowedScopes,
|
||||||
WhitelistedSite whitelistedSite) {
|
WhitelistedSite whitelistedSite) {
|
||||||
|
|
||||||
ApprovedSite as = new ApprovedSite();
|
ApprovedSite as = approvedSiteRepository.save(new ApprovedSite());
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
as.setCreationDate(now);
|
as.setCreationDate(now);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<class>org.mitre.oauth2.model.ClientDetailsEntity</class>
|
<class>org.mitre.oauth2.model.ClientDetailsEntity</class>
|
||||||
<class>org.mitre.oauth2.model.OAuth2AccessTokenEntity</class>
|
<class>org.mitre.oauth2.model.OAuth2AccessTokenEntity</class>
|
||||||
<class>org.mitre.oauth2.model.OAuth2RefreshTokenEntity</class>
|
<class>org.mitre.oauth2.model.OAuth2RefreshTokenEntity</class>
|
||||||
|
<class>org.mitre.oauth2.model.AuthenticationHolder</class>
|
||||||
<class>org.mitre.openid.connect.model.Address</class>
|
<class>org.mitre.openid.connect.model.Address</class>
|
||||||
<class>org.mitre.openid.connect.model.ApprovedSite</class>
|
<class>org.mitre.openid.connect.model.ApprovedSite</class>
|
||||||
<class>org.mitre.openid.connect.model.Event</class>
|
<class>org.mitre.openid.connect.model.Event</class>
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span4 offset2 well-small" style="text-align:left">Do you authorize
|
<div class="span4 offset2 well-small" style="text-align:left">Do you authorize
|
||||||
"<c:choose>
|
"<c:choose>
|
||||||
<c:when test="${empty client.clientName}">
|
<c:when test="${empty client.applicationName}">
|
||||||
<c:out value="${client.clientId}"/>
|
<c:out value="${client.clientId}"/>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<c:out value="${client.clientName}"/>
|
<c:out value="${client.applicationName}"/>
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>" to sign you into their site
|
</c:choose>" to sign you into their site
|
||||||
using your identity?
|
using your identity?
|
||||||
|
|
Loading…
Reference in New Issue