parent
511d702ee0
commit
d435f149eb
|
@ -26,7 +26,7 @@ package org.springframework.security.oauth2.jose.jws;
|
||||||
* @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/rfc7518#section-3">Cryptographic Algorithms for Digital Signatures and MACs</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7518#section-3">Cryptographic Algorithms for Digital Signatures and MACs</a>
|
||||||
*/
|
*/
|
||||||
public interface JwsAlgorithm {
|
public interface JwsAlgorithms {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HMAC using SHA-256 (Required)
|
* HMAC using SHA-256 (Required)
|
|
@ -28,37 +28,37 @@ import java.util.List;
|
||||||
* @author Joe Grandja
|
* @author Joe Grandja
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @see ClaimAccessor
|
* @see ClaimAccessor
|
||||||
* @see JwtClaim
|
* @see JwtClaimNames
|
||||||
* @see Jwt
|
* @see Jwt
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519#section-4.1">Registered Claim Names</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519#section-4.1">Registered Claim Names</a>
|
||||||
*/
|
*/
|
||||||
public interface JwtClaimAccessor extends ClaimAccessor {
|
public interface JwtClaimAccessor extends ClaimAccessor {
|
||||||
|
|
||||||
default URL getIssuer() {
|
default URL getIssuer() {
|
||||||
return this.getClaimAsURL(JwtClaim.ISS);
|
return this.getClaimAsURL(JwtClaimNames.ISS);
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getSubject() {
|
default String getSubject() {
|
||||||
return this.getClaimAsString(JwtClaim.SUB);
|
return this.getClaimAsString(JwtClaimNames.SUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<String> getAudience() {
|
default List<String> getAudience() {
|
||||||
return this.getClaimAsStringList(JwtClaim.AUD);
|
return this.getClaimAsStringList(JwtClaimNames.AUD);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Instant getExpiresAt() {
|
default Instant getExpiresAt() {
|
||||||
return this.getClaimAsInstant(JwtClaim.EXP);
|
return this.getClaimAsInstant(JwtClaimNames.EXP);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Instant getNotBefore() {
|
default Instant getNotBefore() {
|
||||||
return this.getClaimAsInstant(JwtClaim.NBF);
|
return this.getClaimAsInstant(JwtClaimNames.NBF);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Instant getIssuedAt() {
|
default Instant getIssuedAt() {
|
||||||
return this.getClaimAsInstant(JwtClaim.IAT);
|
return this.getClaimAsInstant(JwtClaimNames.IAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getId() {
|
default String getId() {
|
||||||
return this.getClaimAsString(JwtClaim.JTI);
|
return this.getClaimAsString(JwtClaimNames.JTI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ package org.springframework.security.oauth2.jwt;
|
||||||
* @see JwtClaimAccessor
|
* @see JwtClaimAccessor
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519#section-4">JWT Claims</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7519#section-4">JWT Claims</a>
|
||||||
*/
|
*/
|
||||||
public interface JwtClaim {
|
public interface JwtClaimNames {
|
||||||
|
|
||||||
String ISS = "iss";
|
String ISS = "iss";
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.nimbusds.jwt.JWTClaimsSet;
|
||||||
import com.nimbusds.jwt.JWTParser;
|
import com.nimbusds.jwt.JWTParser;
|
||||||
import com.nimbusds.jwt.proc.ConfigurableJWTProcessor;
|
import com.nimbusds.jwt.proc.ConfigurableJWTProcessor;
|
||||||
import com.nimbusds.jwt.proc.DefaultJWTProcessor;
|
import com.nimbusds.jwt.proc.DefaultJWTProcessor;
|
||||||
import org.springframework.security.oauth2.jose.jws.JwsAlgorithm;
|
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
@ -54,13 +54,13 @@ import java.util.Map;
|
||||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7517">JSON Web Key (JWK)</a>
|
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc7517">JSON Web Key (JWK)</a>
|
||||||
* @see <a target="_blank" href="https://connect2id.com/products/nimbus-jose-jwt">Nimbus JOSE + JWT SDK</a>
|
* @see <a target="_blank" href="https://connect2id.com/products/nimbus-jose-jwt">Nimbus JOSE + JWT SDK</a>
|
||||||
*/
|
*/
|
||||||
public class NimbusJwtDecoderJwkSupport implements JwtDecoder {
|
public final class NimbusJwtDecoderJwkSupport implements JwtDecoder {
|
||||||
private final URL jwkSetUrl;
|
private final URL jwkSetUrl;
|
||||||
private final JWSAlgorithm jwsAlgorithm;
|
private final JWSAlgorithm jwsAlgorithm;
|
||||||
private final ConfigurableJWTProcessor<SecurityContext> jwtProcessor;
|
private final ConfigurableJWTProcessor<SecurityContext> jwtProcessor;
|
||||||
|
|
||||||
public NimbusJwtDecoderJwkSupport(String jwkSetUrl) {
|
public NimbusJwtDecoderJwkSupport(String jwkSetUrl) {
|
||||||
this(jwkSetUrl, JwsAlgorithm.RS256);
|
this(jwkSetUrl, JwsAlgorithms.RS256);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NimbusJwtDecoderJwkSupport(String jwkSetUrl, String jwsAlgorithm) {
|
public NimbusJwtDecoderJwkSupport(String jwkSetUrl, String jwsAlgorithm) {
|
||||||
|
|
Loading…
Reference in New Issue