parent
9b7883fe10
commit
33423c46d3
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.security.jwt;
|
package org.springframework.security.jwt;
|
||||||
|
|
||||||
import org.springframework.security.oauth2.core.AbstractToken;
|
import org.springframework.security.oauth2.core.SecurityToken;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of an {@link AbstractToken} representing a <i>JSON Web Token (JWT)</i>.
|
* An implementation of a {@link SecurityToken} representing a <i>JSON Web Token (JWT)</i>.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* JWTs represent a set of "Claims" as a JSON object that is encoded in a
|
* JWTs represent a set of "Claims" as a JSON object that is encoded in a
|
||||||
|
@ -34,13 +34,13 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author Joe Grandja
|
* @author Joe Grandja
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @see AbstractToken
|
* @see SecurityToken
|
||||||
* @see JwtClaimAccessor
|
* @see JwtClaimAccessor
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519">JSON Web Token (JWT)</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519">JSON Web Token (JWT)</a>
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7515">JSON Web Signature (JWS)</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7515">JSON Web Signature (JWS)</a>
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7516">JSON Web Encryption (JWE)</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7516">JSON Web Encryption (JWE)</a>
|
||||||
*/
|
*/
|
||||||
public class Jwt extends AbstractToken implements JwtClaimAccessor {
|
public class Jwt extends SecurityToken implements JwtClaimAccessor {
|
||||||
private final Map<String, Object> headers;
|
private final Map<String, Object> headers;
|
||||||
private final Map<String, Object> claims;
|
private final Map<String, Object> claims;
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class NimbusJwtDecoderJwkSupport implements JwtDecoder {
|
||||||
if (jwtClaimsSet.getIssueTime() != null) {
|
if (jwtClaimsSet.getIssueTime() != null) {
|
||||||
issuedAt = jwtClaimsSet.getIssueTime().toInstant();
|
issuedAt = jwtClaimsSet.getIssueTime().toInstant();
|
||||||
} else {
|
} else {
|
||||||
// issuedAt is required in AbstractToken so let's default to expiresAt - 1 second
|
// issuedAt is required in SecurityToken so let's default to expiresAt - 1 second
|
||||||
issuedAt = Instant.from(expiresAt).minusSeconds(1);
|
issuedAt = Instant.from(expiresAt).minusSeconds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of an {@link AbstractToken} representing an <i>OAuth 2.0 Access Token</i>.
|
* An implementation of a {@link SecurityToken} representing an <i>OAuth 2.0 Access Token</i>.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* An access token is a credential that represents an authorization
|
* An access token is a credential that represents an authorization
|
||||||
|
@ -35,7 +35,7 @@ import java.util.Set;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.4">Section 1.4 Access Token</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.4">Section 1.4 Access Token</a>
|
||||||
*/
|
*/
|
||||||
public class AccessToken extends AbstractToken {
|
public class AccessToken extends SecurityToken {
|
||||||
private final TokenType tokenType;
|
private final TokenType tokenType;
|
||||||
private final Set<String> scopes;
|
private final Set<String> scopes;
|
||||||
private final Map<String,Object> additionalParameters;
|
private final Map<String,Object> additionalParameters;
|
||||||
|
|
|
@ -30,13 +30,13 @@ import java.time.Instant;
|
||||||
* @author Joe Grandja
|
* @author Joe Grandja
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractToken implements Serializable {
|
public abstract class SecurityToken implements Serializable {
|
||||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||||
private final String tokenValue;
|
private final String tokenValue;
|
||||||
private final Instant issuedAt;
|
private final Instant issuedAt;
|
||||||
private final Instant expiresAt;
|
private final Instant expiresAt;
|
||||||
|
|
||||||
protected AbstractToken(String tokenValue, Instant issuedAt, Instant expiresAt) {
|
protected SecurityToken(String tokenValue, Instant issuedAt, Instant expiresAt) {
|
||||||
Assert.hasLength(tokenValue, "tokenValue cannot be empty");
|
Assert.hasLength(tokenValue, "tokenValue cannot be empty");
|
||||||
Assert.notNull(issuedAt, "issuedAt cannot be null");
|
Assert.notNull(issuedAt, "issuedAt cannot be null");
|
||||||
Assert.notNull(expiresAt, "expiresAt cannot be null");
|
Assert.notNull(expiresAt, "expiresAt cannot be null");
|
||||||
|
@ -66,7 +66,7 @@ public abstract class AbstractToken implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractToken that = (AbstractToken) obj;
|
SecurityToken that = (SecurityToken) obj;
|
||||||
|
|
||||||
if (!this.getTokenValue().equals(that.getTokenValue())) {
|
if (!this.getTokenValue().equals(that.getTokenValue())) {
|
||||||
return false;
|
return false;
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.security.oauth2.oidc.core;
|
package org.springframework.security.oauth2.oidc.core;
|
||||||
|
|
||||||
import org.springframework.security.oauth2.core.AbstractToken;
|
import org.springframework.security.oauth2.core.SecurityToken;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of an {@link AbstractToken} representing an <i>OpenID Connect Core 1.0 ID Token</i>.
|
* An implementation of a {@link SecurityToken} representing an <i>OpenID Connect Core 1.0 ID Token</i>.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The <code>IdToken</code> is a security token that contains "Claims"
|
* The <code>IdToken</code> is a security token that contains "Claims"
|
||||||
|
@ -32,13 +32,13 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author Joe Grandja
|
* @author Joe Grandja
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @see AbstractToken
|
* @see SecurityToken
|
||||||
* @see IdTokenClaimAccessor
|
* @see IdTokenClaimAccessor
|
||||||
* @see StandardClaimAccessor
|
* @see StandardClaimAccessor
|
||||||
* @see <a target="_blank" href="http://openid.net/specs/openid-connect-core-1_0.html#IDToken">ID Token</a>
|
* @see <a target="_blank" href="http://openid.net/specs/openid-connect-core-1_0.html#IDToken">ID Token</a>
|
||||||
* @see <a target="_blank" href="http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims">Standard Claims</a>
|
* @see <a target="_blank" href="http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims">Standard Claims</a>
|
||||||
*/
|
*/
|
||||||
public class IdToken extends AbstractToken implements IdTokenClaimAccessor {
|
public class IdToken extends SecurityToken implements IdTokenClaimAccessor {
|
||||||
private final Map<String, Object> claims;
|
private final Map<String, Object> claims;
|
||||||
|
|
||||||
public IdToken(String tokenValue, Instant issuedAt, Instant expiresAt, Map<String, Object> claims) {
|
public IdToken(String tokenValue, Instant issuedAt, Instant expiresAt, Map<String, Object> claims) {
|
||||||
|
|
Loading…
Reference in New Issue