moved token classes to use Nimbus-JOSE
parent
1f50945831
commit
d00b351f32
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.mitre.oauth2.model;
|
package org.mitre.oauth2.model;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -42,11 +43,14 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.mitre.jwt.model.Jwt;
|
|
||||||
import org.mitre.openid.connect.model.IdToken;
|
|
||||||
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||||
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
||||||
|
|
||||||
|
import com.nimbusds.jwt.JWT;
|
||||||
|
import com.nimbusds.jwt.JWTClaimsSet;
|
||||||
|
import com.nimbusds.jwt.JWTParser;
|
||||||
|
import com.nimbusds.jwt.PlainJWT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jricher
|
* @author jricher
|
||||||
*
|
*
|
||||||
|
@ -76,7 +80,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
|
|
||||||
private AuthenticationHolderEntity authenticationHolder; // the authentication that made this access
|
private AuthenticationHolderEntity authenticationHolder; // the authentication that made this access
|
||||||
|
|
||||||
private Jwt jwtValue; // JWT-encoded access token value
|
private JWT jwtValue; // JWT-encoded access token value
|
||||||
|
|
||||||
private OAuth2AccessTokenEntity idToken; // JWT-encoded OpenID Connect IdToken
|
private OAuth2AccessTokenEntity idToken; // JWT-encoded OpenID Connect IdToken
|
||||||
|
|
||||||
|
@ -92,7 +96,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
* Create a new, blank access token
|
* Create a new, blank access token
|
||||||
*/
|
*/
|
||||||
public OAuth2AccessTokenEntity() {
|
public OAuth2AccessTokenEntity() {
|
||||||
setJwt(new Jwt()); // give us a blank jwt to work with at least
|
setJwt(new PlainJWT(new JWTClaimsSet())); // give us a blank jwt to work with at least
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,10 +173,10 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
* Set the "value" of this Access Token
|
* Set the "value" of this Access Token
|
||||||
*
|
*
|
||||||
* @param value the JWT string
|
* @param value the JWT string
|
||||||
* @throws IllegalArgumentException if "value" is not a properly formatted JWT string
|
* @throws ParseException if "value" is not a properly formatted JWT string
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) throws ParseException {
|
||||||
setJwt(Jwt.parse(value));
|
setJwt(JWTParser.parse(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@ -264,14 +268,14 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
||||||
* @return the jwtValue
|
* @return the jwtValue
|
||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
public Jwt getJwt() {
|
public JWT getJwt() {
|
||||||
return jwtValue;
|
return jwtValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param jwtValue the jwtValue to set
|
* @param jwtValue the jwtValue to set
|
||||||
*/
|
*/
|
||||||
public void setJwt(Jwt jwt) {
|
public void setJwt(JWT jwt) {
|
||||||
this.jwtValue = jwt;
|
this.jwtValue = jwt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.mitre.oauth2.model;
|
package org.mitre.oauth2.model;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
|
@ -35,9 +36,13 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.mitre.jwt.model.Jwt;
|
|
||||||
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
||||||
|
|
||||||
|
import com.nimbusds.jwt.JWT;
|
||||||
|
import com.nimbusds.jwt.JWTClaimsSet;
|
||||||
|
import com.nimbusds.jwt.JWTParser;
|
||||||
|
import com.nimbusds.jwt.PlainJWT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jricher
|
* @author jricher
|
||||||
*
|
*
|
||||||
|
@ -59,7 +64,7 @@ public class OAuth2RefreshTokenEntity implements 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
|
// our refresh tokens might expire
|
||||||
private Date expiration;
|
private Date expiration;
|
||||||
|
@ -68,7 +73,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public OAuth2RefreshTokenEntity() {
|
public OAuth2RefreshTokenEntity() {
|
||||||
setJwt(new Jwt()); // start with a blank JWT value
|
setJwt(new PlainJWT(new JWTClaimsSet())); // start with a blank JWT value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,10 +123,10 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
/**
|
/**
|
||||||
* Set the value of this token as a string. Parses the string into a JWT.
|
* Set the value of this token as a string. Parses the string into a JWT.
|
||||||
* @param value
|
* @param value
|
||||||
* @throws IllegalArgumentException if the value is not a valid JWT string
|
* @throws ParseException if the value is not a valid JWT string
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) throws ParseException {
|
||||||
setJwt(Jwt.parse(value));
|
setJwt(JWTParser.parse(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@ -168,14 +173,14 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
||||||
* @return the jwt
|
* @return the jwt
|
||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
public Jwt getJwt() {
|
public JWT getJwt() {
|
||||||
return jwt;
|
return jwt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param jwt the jwt to set
|
* @param jwt the jwt to set
|
||||||
*/
|
*/
|
||||||
public void setJwt(Jwt jwt) {
|
public void setJwt(JWT jwt) {
|
||||||
this.jwt = jwt;
|
this.jwt = jwt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue