io.quarkus.oidc.runtime.OidcJwtCallerPrincipal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-oidc Show documentation
Show all versions of quarkus-oidc Show documentation
Secure your applications with OpenID Connect Adapter and IDP such as Keycloak
package io.quarkus.oidc.runtime;
import java.util.Optional;
import org.jose4j.jwt.JwtClaims;
import io.quarkus.security.credential.TokenCredential;
import io.smallrye.jwt.auth.principal.DefaultJWTCallerPrincipal;
/**
* An implementation of JWTCallerPrincipal
*/
public class OidcJwtCallerPrincipal extends DefaultJWTCallerPrincipal {
private JwtClaims claims;
private String principalClaim;
private TokenCredential credential;
public OidcJwtCallerPrincipal(final JwtClaims claims, TokenCredential credential) {
this(claims, credential, null);
}
public OidcJwtCallerPrincipal(final JwtClaims claims, TokenCredential credential, String principalClaim) {
super(claims);
this.claims = claims;
this.credential = credential;
this.principalClaim = principalClaim;
}
public JwtClaims getClaims() {
return claims;
}
public TokenCredential getCredential() {
return credential;
}
@Override
public String getName() {
if (principalClaim != null) {
Optional claim = super.claim(principalClaim);
return claim.orElse(null);
} else {
return super.getName();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy