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

com.nimbusds.openid.connect.provider.spi.claims.ClaimUtils Maven / Gradle / Ivy

Go to download

SDK for Connect2id Server extensions, such as OpenID Connect claims sources and OAuth 2.0 grant handlers

There is a newer version: 5.8
Show newest version
package com.nimbusds.openid.connect.provider.spi.claims;


import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.checkerframework.checker.nullness.qual.Nullable;

import com.nimbusds.langtag.LangTag;


/**
 * Claim utilities.
 */
public class ClaimUtils {


	/**
	 * Applies the specified language tags to a set of claims.
	 *
	 * 

Example: * *

	 * Claims: "name", "given_name", "family_name"
	 * Language tags: "bg-BG", "en-US"
	 * Result: "name#bg-BG", "name#en-US",
	 *         "given_name#bg-BG", "given_name#en-US",
	 *         "family_name#bg-BG", "family_name#en-US"
	 * 
* * @param claims The claims to apply the language tags to. Claims * that already have a language will be returned * unmodified. Must not be {@code null}. * @param langTags The language tags to apply, {@code null} if not * specified. * * @return The claims with applied language tags, or the original * claims if no language tags are specified. */ public static Set applyLangTags(final Set claims, final @Nullable List langTags) { if (langTags == null || langTags.isEmpty()) return claims; Set out = new HashSet<>(); for (String claim: claims) { for (LangTag tag: langTags) { if (claim.contains("#")) { out.add(claim); } else { out.add(claim + "#" + tag); } } } return out; } /** * Prevents public instantiation. */ private ClaimUtils() {} }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy