changed id token handling
parent
d7ba02a74c
commit
4dc1625496
|
@ -48,32 +48,37 @@ public class OAuth2AccessTokenEntity extends OAuth2AccessToken {
|
||||||
|
|
||||||
private OAuth2Authentication authentication; // the authentication that made this access
|
private OAuth2Authentication authentication; // the authentication that made this access
|
||||||
|
|
||||||
private String idTokenString;
|
// JWT-encoded access token value
|
||||||
|
private Jwt jwtValue;
|
||||||
|
|
||||||
//JWT-encoded representation of this access token entity
|
// JWT-encoded OpenID Connect IdToken
|
||||||
private Jwt jwt;
|
private IdToken idToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create a new, blank access token
|
||||||
*/
|
*/
|
||||||
public OAuth2AccessTokenEntity() {
|
public OAuth2AccessTokenEntity() {
|
||||||
|
// we ignore the "value" field in the superclass because we can't cleanly override it
|
||||||
super(null);
|
super(null);
|
||||||
|
setJwt(new Jwt()); // give us a blank jwt to work with at least
|
||||||
|
setIdToken(new IdToken()); // and a blank IdToken
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this method to insert the ID Token
|
* Get all additional information to be sent to the serializer. Inserts a copy of the IdToken (in JWT String form).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transient
|
@Transient
|
||||||
public Map<String, Object> getAdditionalInformation() {
|
public Map<String, Object> getAdditionalInformation() {
|
||||||
Map<String, Object> map = super.getAdditionalInformation();
|
Map<String, Object> map = super.getAdditionalInformation();
|
||||||
map.put(ID_TOKEN, idTokenString);
|
map.put(ID_TOKEN, getIdTokenString());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The authentication in place when this token was created.
|
||||||
* @return the authentication
|
* @return the authentication
|
||||||
*/
|
*/
|
||||||
@Lob
|
@Lob
|
||||||
|
@ -111,25 +116,24 @@ public class OAuth2AccessTokenEntity extends OAuth2AccessToken {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.springframework.security.oauth2.common.OAuth2AccessToken#getValue()
|
* @see org.springframework.security.oauth2.common.OAuth2AccessToken#getValue()
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* Get the string-encoded value of this access token.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Id
|
@Id
|
||||||
@Column(name="id")
|
@Column(name="id")
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return jwt.toString();
|
return jwtValue.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the "value" of this Access Token
|
* Set the "value" of this Access Token
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value the JWT string
|
||||||
|
* @throws IllegalArgumentException if "value" is not a properly formatted JWT string
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
try {
|
setJwt(Jwt.parse(value));
|
||||||
Jwt valueJwt = Jwt.parse(value);
|
|
||||||
setJwt(valueJwt);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
//TODO: What to do in this case?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -239,7 +243,7 @@ public class OAuth2AccessTokenEntity extends OAuth2AccessToken {
|
||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
public IdToken getIdToken() {
|
public IdToken getIdToken() {
|
||||||
return IdToken.parse(idTokenString);
|
return idToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +251,7 @@ public class OAuth2AccessTokenEntity extends OAuth2AccessToken {
|
||||||
* @param idToken the idToken to set
|
* @param idToken the idToken to set
|
||||||
*/
|
*/
|
||||||
public void setIdToken(IdToken idToken) {
|
public void setIdToken(IdToken idToken) {
|
||||||
this.idTokenString = idToken.toString();
|
this.idToken = idToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,29 +259,30 @@ public class OAuth2AccessTokenEntity extends OAuth2AccessToken {
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getIdTokenString() {
|
public String getIdTokenString() {
|
||||||
return idTokenString;
|
return idToken.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param idTokenString the idTokenString to set
|
* @param idTokenString the idTokenString to set
|
||||||
|
* @throws IllegalArgumentException if "value" is not a properly formatted JWT string
|
||||||
*/
|
*/
|
||||||
public void setIdTokenString(String idTokenString) {
|
public void setIdTokenString(String idTokenString) {
|
||||||
this.idTokenString = idTokenString;
|
this.idToken = IdToken.parse(idTokenString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the jwt
|
* @return the jwtValue
|
||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
public Jwt getJwt() {
|
public Jwt getJwt() {
|
||||||
return jwt;
|
return jwtValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param jwt the jwt to set
|
* @param jwtValue the jwtValue to set
|
||||||
*/
|
*/
|
||||||
public void setJwt(Jwt jwt) {
|
public void setJwt(Jwt jwt) {
|
||||||
this.jwt = jwt;
|
this.jwtValue = jwt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue