updated and commented refreshtoken implementation

pull/59/head
Justin Richer 13 years ago
parent c46e0f1969
commit e7362f93b3

@ -23,6 +23,7 @@ import javax.persistence.Transient;
import org.mitre.jwt.model.Jwt; import org.mitre.jwt.model.Jwt;
import org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken; import org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
/** /**
* @author jricher * @author jricher
@ -34,26 +35,33 @@ import org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken;
@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")
}) })
public class OAuth2RefreshTokenEntity extends ExpiringOAuth2RefreshToken { public class OAuth2RefreshTokenEntity extends OAuth2RefreshToken {
private ClientDetailsEntity client; private ClientDetailsEntity client;
//JWT-encoded representation of this access token entity //JWT-encoded representation of this access token entity
private Jwt jwt; private Jwt jwt;
// our refresh tokens might expire
private Date expiration;
private Set<String> scope; // we save the scope issued to the refresh token so that we can reissue a new access token private Set<String> scope; // we save the scope issued to the refresh token so that we can reissue a new access token
/** /**
* *
*/ */
public OAuth2RefreshTokenEntity() { public OAuth2RefreshTokenEntity() {
// TODO Auto-generated constructor stub // we ignore the superclass's Value field
super(null, null); super(null);
setJwt(new Jwt()); // start with a blank JWT value
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.springframework.security.oauth2.common.OAuth2RefreshToken#getValue() * @see org.springframework.security.oauth2.common.OAuth2RefreshToken#getValue()
*/ */
/**
* Get the JWT-encoded value of this token
*/
@Override @Override
@Id @Id
@Column(name="id") @Column(name="id")
@ -62,23 +70,20 @@ public class OAuth2RefreshTokenEntity extends ExpiringOAuth2RefreshToken {
return jwt.toString(); return jwt.toString();
} }
/* (non-Javadoc) /**
* @see org.springframework.security.oauth2.common.OAuth2RefreshToken#setValue(java.lang.String) * Set the value of this token as a string. Parses the string into a JWT.
* @param value
* @throws IllegalArgumentException if the value is not a valid JWT string
*/ */
public void setValue(String value) { public void setValue(String value) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
setJwt(Jwt.parse(value)); setJwt(Jwt.parse(value));
} }
/* (non-Javadoc)
* @see org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken#getExpiration()
*/
@Override
@Basic @Basic
@Temporal(javax.persistence.TemporalType.TIMESTAMP) @Temporal(javax.persistence.TemporalType.TIMESTAMP)
public Date getExpiration() { public Date getExpiration() {
// TODO Auto-generated method stub return expiration;
return super.getExpiration();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -86,8 +91,7 @@ public class OAuth2RefreshTokenEntity extends ExpiringOAuth2RefreshToken {
*/ */
public void setExpiration(Date expiration) { public void setExpiration(Date expiration) {
// TODO Auto-generated method stub this.expiration = expiration;
//super.setExpiration(expiration);
} }
/** /**
@ -136,6 +140,7 @@ public class OAuth2RefreshTokenEntity extends ExpiringOAuth2RefreshToken {
} }
/** /**
* Get the JWT object directly
* @return the jwt * @return the jwt
*/ */
@Transient @Transient

Loading…
Cancel
Save