001package com.nimbusds.openid.connect.provider.spi.claims; 002 003 004import java.util.List; 005import java.util.Set; 006 007import com.nimbusds.langtag.LangTag; 008 009import com.nimbusds.oauth2.sdk.id.Subject; 010import com.nimbusds.openid.connect.sdk.claims.UserInfo; 011 012import com.nimbusds.openid.connect.provider.spi.Lifecycle; 013 014 015/** 016 * Service Provider Interface (SPI) for sourcing OpenID Connect UserInfo and 017 * other claims about a subject. 018 */ 019public interface ClaimsSource extends Lifecycle { 020 021 022 /** 023 * Returns the names of the supported OpenID Connect claims. 024 * 025 * <p>Example: 026 * 027 * <pre> 028 * name 029 * email 030 * email_verified 031 * </pre> 032 * 033 * @return The supported claim names. Should not include the reserved 034 * {@code sub} (subject) claim name. 035 */ 036 public Set<String> supportedClaims(); 037 038 039 /** 040 * Requests claims for the specified subject. 041 * 042 * @param subject The subject. Must not be {@code null}. 043 * @param claims The names of the requested claims, with 044 * optional language tags. Must not be 045 * {@code null}. 046 * @param claimsLocales The preferred languages and scripts for the 047 * claims to return, {@code null} if not 048 * specified. 049 * 050 * @return The claims, {@code null} if the subject wasn't found or the 051 * claims source is {@link #isEnabled disabled}. 052 * 053 * @throws Exception If retrieval of the claims failed. 054 */ 055 public UserInfo getClaims(final Subject subject, 056 final Set<String> claims, 057 final List<LangTag> claimsLocales) 058 throws Exception; 059} 060