All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.oidc.runtime.OidcJwtCallerPrincipal Maven / Gradle / Ivy

Go to download

Secure your applications with OpenID Connect Adapter and IDP such as Keycloak

There is a newer version: 3.17.5
Show newest version
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