Set additional claims which will be embedded in the ID token.

<p>
The argument is converted into a JSON string and passed to
{@link #setClaims(String)} method.
</p>

@param claims
Additional claims. Keys are claim names.

@return
{@code this} object.
7245
public BackchannelAuthenticationCompleteRequest setClaims(Map<String, Object> claims)
    {
        if (claims == null || claims.size() == 0)
        {
            this.claims = null;
        }
        else
        {
            setClaims(Utils.toJson(claims));
        }

        return this;
    }
540835
public function issue(Authenticatable $user, array $additionalCustomClaims = [])
    {
        // gets a new builder instance.
        $builder = $this->builder();

        // set the issued
        $builder->setIssuer($this->issuer);

        // set the subject.
        $builder->setSubject($user->getAuthIdentifier());

        // generate a unique id for the token, and set it to replicate as a header.
        $builder->setId($this->generateId(), true);

        // detect what time is it.
        $now = $this->now();

        // set issue date.
        $builder->setIssuedAt($now->timestamp);

        // set the token cannot be used before now.
        $builder->setNotBefore($now->timestamp);

        // calculate and set the expiration date for the token.
        $expiresAt = (clone $now)->addMinutes($this->ttl);
        $builder->setExpiration($expiresAt->timestamp);

        // created a custom claim that informs the limit time
        // for the token to be renewed.
        // the refresh limit is based on ttl + limit (grace period).
        $refreshLimit = (clone $now)->addMinutes($this->ttl + $this->refreshLimit);
        $builder->set('rli', $refreshLimit->timestamp);

        // loop through custom claims.
        foreach($additionalCustomClaims as $claim => $value) {
            // set custom claim.
            $builder->set($claim, $value);
        }

        // set user object default custom claims.
        if (method_exists($user, 'customJWTClaims')) {
            // call the methods.
            try {
                // call the custom claims method.
                $customClaims = (array) $user->customJWTClaims();

                // if the custom claims method returns a array.
                foreach($customClaims as $claim => $value) {
                    $builder->set($claim, $value);
                }
            } catch(\Exception $e) {
                // just continue since the custom claims should
                // not prevent the token of being issued.
            }
        }

        // get the signer.
        $signer = $this->signer();

        // sign the configure token.
        $builder->sign($signer, $this->secret);

        // gets the actual signed token as string.
        $token = (string) $builder->getToken();

        // returns the token.
        return $token;
    }
419815
public void setAdditionalArtifacts(java.util.Collection<String> additionalArtifacts) {
        if (additionalArtifacts == null) {
            this.additionalArtifacts = null;
            return;
        }

        this.additionalArtifacts = new java.util.ArrayList<String>(additionalArtifacts);
    }
59974
protected static Map<String, List<Statement>> addStatementToGroups(Statement statement, Map<String, List<Statement>> claims) {
		Map<String, List<Statement>> newGroups = new HashMap<>(claims);
		String pid = statement.getMainSnak().getPropertyId().getId();
		if(newGroups.containsKey(pid)) {
			List<Statement> newGroup = new ArrayList<>(newGroups.get(pid).size());
			boolean statementReplaced = false;
			for(Statement existingStatement : newGroups.get(pid)) {
				if(existingStatement.getStatementId().equals(statement.getStatementId()) &&
						!existingStatement.getStatementId().isEmpty()) {
					statementReplaced = true;
					newGroup.add(statement);
				} else {
					newGroup.add(existingStatement);
				}
			}
			if(!statementReplaced) {
				newGroup.add(statement);
			}
			newGroups.put(pid, newGroup);
		} else {
			newGroups.put(pid, Collections.singletonList(statement));
		}
		return newGroups;
	}
1196193
@Override
    public Builder expirationTime(long exp) throws InvalidClaimException {

        long currTime = System.currentTimeMillis() / 1000;
        if (exp >= currTime) {
            // if (exp > (new Date()).getTime()) {
            claims.put(Claims.EXPIRATION, Long.valueOf(exp));
        } else {
            // Expiration must be greater than the current time
            String err = Tr.formatMessage(tc, "JWT_INVALID_EXP_CLAIM_ERR", new Object[] { Claims.EXPIRATION, exp, JwtUtils.getDate(exp), JwtUtils.getDate(currTime) });
            throw new InvalidClaimException(err);
        }
        return this;
    }
692197
public function setClaim($claim, $value)
    {
        $context = $this->_context;

        $context->claims[$claim] = $value;

        return $this;
    }
617830
@Override
    public Builder audience(List<String> newaudiences) throws InvalidClaimException {
        // this.AUDIENCE
        if (newaudiences != null && !newaudiences.isEmpty()) {

            ArrayList<String> audiences = new ArrayList<String>();
            for (String aud : newaudiences) {
                if (aud != null && !aud.trim().isEmpty() && !audiences.contains(aud)) {
                    audiences.add(aud);
                }
            }
            if (audiences.isEmpty()) {
                String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { Claims.AUDIENCE, newaudiences });
                throw new InvalidClaimException(err);
            }
            // this.audiences = new ArrayList<String>(audiences);
            claims.put(Claims.AUDIENCE, audiences);
        } else {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { Claims.AUDIENCE, newaudiences });
            throw new InvalidClaimException(err);
        }
        return this;
    }
589756
public JsonAssert and(JsonAssertion... assertions) {
        Arrays.stream(assertions).forEach(a -> a.doAssert(this));
        return this;
    }
1312157
protected ProcessedClaim createProcessedClaim(final Claim requestClaim, final ClaimsParameters parameters) {
        val claim = new ProcessedClaim();
        claim.setClaimType(createProcessedClaimType(requestClaim, parameters));
        claim.setIssuer(this.issuer);
        claim.setOriginalIssuer(this.issuer);
        claim.setValues(requestClaim.getValues());
        return claim;
    }
1129963
private void convertJoseTypes(JwtClaims claimsSet) {
        //        if (claimsSet.hasClaim(Claims.address.name())) {
        //            replaceMap(Claims.address.name());
        //        }
        //        if (claimsSet.hasClaim(Claims.jwk.name())) {
        //            replaceMap(Claims.jwk.name());
        //        }
        //        if (claimsSet.hasClaim(Claims.sub_jwk.name())) {
        //            replaceMap(Claims.sub_jwk.name());
        //        }
        if (claimsSet.hasClaim("address")) {
            replaceMapWithJsonObject("address", claimsSet);
        }
        if (claimsSet.hasClaim("jwk")) {
            replaceMapWithJsonObject("jwk", claimsSet);
        }
        if (claimsSet.hasClaim("sub_jwk")) {
            replaceMapWithJsonObject("sub_jwk", claimsSet);
        }
        if (claimsSet.hasClaim("aud")) {
            convertToList("aud", claimsSet);
        }
        if (claimsSet.hasClaim("groups")) {
            convertToList("groups", claimsSet);
        }
    }
148710
def _marshal_claims(self, query_claims):
        
        claims = reduce_claims(query_claims)
        # self.data['claimq'] = query_claims
        self.data['claims'] = claims

        entities = set()
        for eid in claims:
            if self.user_labels:
                if eid in self.user_labels or eid == 'P31':
                    entities.add(eid)  # P (property)
                else:
                    continue  # get only wanted entities
            else:
                entities.add(eid)  # P (property)

            for val in claims[eid]:
                if utils.is_text(val) and re.match(r'^Q\d+$', val):
                    entities.add(val)  # Q (item)

        self.data['entities'] = list(entities)
1342284
public void addAndOverwriteProperties(Map<String, String> additionalProperties) {
        additionalProperties.values().removeAll(Collections.singleton(null));
        for (Map.Entry<String, String> additionalPropertiesMap : additionalProperties.entrySet()) {
            if (!additionalPropertiesMap.getValue().trim().isEmpty()) {
                properties.setProperty(additionalPropertiesMap.getKey(), additionalPropertiesMap.getValue());
                warnUserOfPossibleErrors(additionalPropertiesMap.getKey(), properties);
            }
        }
    }
1216365
public void setPolicies(java.util.Collection<String> policies) {
        if (policies == null) {
            this.policies = null;
            return;
        }

        this.policies = new java.util.ArrayList<String>(policies);
    }
226454
public OTAUpdateInfo withAdditionalParameters(java.util.Map<String, String> additionalParameters) {
        setAdditionalParameters(additionalParameters);
        return this;
    }
501746
@Override
    public Builder claimFrom(String jsonOrJwt, String claim) throws InvalidClaimException, InvalidTokenException {
        if (JwtUtils.isNullEmpty(claim)) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_ERR", new Object[] { claim });
            throw new InvalidClaimException(err);
        }
        if (isValidToken(jsonOrJwt)) {
            String decoded = jsonOrJwt;
            if (JwtUtils.isBase64Encoded(jsonOrJwt)) {
                decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);
            }
            boolean isJson = JwtUtils.isJson(decoded);

            if (!isJson) {
                String jwtPayload = JwtUtils.getPayload(jsonOrJwt);
                decoded = JwtUtils.decodeFromBase64String(jwtPayload);
            }

            // } else {
            // // either decoded payload from jwt or encoded/decoded json string
            // if (JwtUtils.isBase64Encoded(jsonOrJwt)) {
            // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);
            // }
            // }

            if (decoded != null) {
                Object claimValue = null;
                try {
                    if ((claimValue = JwtUtils.claimFromJsonObject(decoded, claim)) != null) {
                        claims.put(claim, claimValue);
                    }
                } catch (JoseException e) {
                    String err = Tr.formatMessage(tc, "JWT_INVALID_TOKEN_ERR");
                    throw new InvalidTokenException(err);
                }
            }
        }

        return this;
    }
230448
public Map<String, Object> validateTokenAndGetClaims(final String token) {
        final CommonProfile profile = validateToken(token);

        final Map<String, Object> claims = new HashMap<>(profile.getAttributes());
        claims.put(JwtClaims.SUBJECT, profile.getId());

        return claims;
    }
1290996
public void setAdditionalAttributes(java.util.Collection<AdditionalAttribute> additionalAttributes) {
        if (additionalAttributes == null) {
            this.additionalAttributes = null;
            return;
        }

        this.additionalAttributes = new com.amazonaws.internal.SdkInternalList<AdditionalAttribute>(additionalAttributes);
    }