// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.videoanalyzer.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.List;

/** Properties for access validation based on JSON Web Tokens (JWT). */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonTypeName("#Microsoft.VideoAnalyzer.JwtAuthentication")
@Fluent
public final class JwtAuthentication extends AuthenticationBase {
    /*
     * List of expected token issuers. Token issuer is valid if it matches at
     * least one of the given values.
     */
    @JsonProperty(value = "issuers")
    private List<String> issuers;

    /*
     * List of expected token audiences. Token audience is valid if it matches
     * at least one of the given values.
     */
    @JsonProperty(value = "audiences")
    private List<String> audiences;

    /*
     * List of additional token claims to be validated. Token must contains all
     * claims and respective values for it to be valid.
     */
    @JsonProperty(value = "claims")
    private List<TokenClaim> claims;

    /*
     * List of keys which can be used to validate access tokens. Having
     * multiple keys allow for seamless key rotation of the token signing key.
     * Token signature must match exactly one key.
     */
    @JsonProperty(value = "keys")
    private List<TokenKey> keys;

    /**
     * Get the issuers property: List of expected token issuers. Token issuer is valid if it matches at least one of the
     * given values.
     *
     * @return the issuers value.
     */
    public List<String> issuers() {
        return this.issuers;
    }

    /**
     * Set the issuers property: List of expected token issuers. Token issuer is valid if it matches at least one of the
     * given values.
     *
     * @param issuers the issuers value to set.
     * @return the JwtAuthentication object itself.
     */
    public JwtAuthentication withIssuers(List<String> issuers) {
        this.issuers = issuers;
        return this;
    }

    /**
     * Get the audiences property: List of expected token audiences. Token audience is valid if it matches at least one
     * of the given values.
     *
     * @return the audiences value.
     */
    public List<String> audiences() {
        return this.audiences;
    }

    /**
     * Set the audiences property: List of expected token audiences. Token audience is valid if it matches at least one
     * of the given values.
     *
     * @param audiences the audiences value to set.
     * @return the JwtAuthentication object itself.
     */
    public JwtAuthentication withAudiences(List<String> audiences) {
        this.audiences = audiences;
        return this;
    }

    /**
     * Get the claims property: List of additional token claims to be validated. Token must contains all claims and
     * respective values for it to be valid.
     *
     * @return the claims value.
     */
    public List<TokenClaim> claims() {
        return this.claims;
    }

    /**
     * Set the claims property: List of additional token claims to be validated. Token must contains all claims and
     * respective values for it to be valid.
     *
     * @param claims the claims value to set.
     * @return the JwtAuthentication object itself.
     */
    public JwtAuthentication withClaims(List<TokenClaim> claims) {
        this.claims = claims;
        return this;
    }

    /**
     * Get the keys property: List of keys which can be used to validate access tokens. Having multiple keys allow for
     * seamless key rotation of the token signing key. Token signature must match exactly one key.
     *
     * @return the keys value.
     */
    public List<TokenKey> keys() {
        return this.keys;
    }

    /**
     * Set the keys property: List of keys which can be used to validate access tokens. Having multiple keys allow for
     * seamless key rotation of the token signing key. Token signature must match exactly one key.
     *
     * @param keys the keys value to set.
     * @return the JwtAuthentication object itself.
     */
    public JwtAuthentication withKeys(List<TokenKey> keys) {
        this.keys = keys;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (claims() != null) {
            claims().forEach(e -> e.validate());
        }
        if (keys() != null) {
            keys().forEach(e -> e.validate());
        }
    }
}
