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

com.microsoft.aad.msal4j.RefreshTokenParameters Maven / Gradle / Ivy

Go to download

Microsoft Authentication Library for Java gives you the ability to obtain tokens from Azure AD v2 (work and school accounts, MSA) and Azure AD B2C, gaining access to Microsoft Cloud API and any other API secured by Microsoft identities

There is a newer version: 1.17.1
Show newest version
// Generated by delombok at Fri Feb 12 21:32:09 UTC 2021
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.aad.msal4j;

import lombok.*;
import java.util.Set;
import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotBlank;
import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotEmpty;

/**
 * Object containing parameters for refresh token request. Can be used as parameter to

 * {@link PublicClientApplication#acquireToken(RefreshTokenParameters)} or to

 * {@link ConfidentialClientApplication#acquireToken(RefreshTokenParameters)}

 *

 *  RefreshTokenParameters should only be used for migration scenarios (when moving from ADAL to

 *  MSAL). To acquire tokens silently, use {@link AbstractClientApplicationBase#acquireTokenSilently(SilentParameters)}
 */
public class RefreshTokenParameters implements IApiParameters {
    /**
     * Scopes the application is requesting access to
     */
    @NonNull
    private Set scopes;
    /**
     * Claims to be requested through the OIDC claims request parameter, allowing requests for standard and custom claims
     */
    private ClaimsRequest claims;
    /**
     * Refresh token received from the STS
     */
    @NonNull
    private String refreshToken;

    private static RefreshTokenParametersBuilder builder() {
        return new RefreshTokenParametersBuilder();
    }

    /**
     * Builder for {@link RefreshTokenParameters}

     * @param scopes scopes application is requesting access to

     * @param refreshToken refresh token received form the STS

     * @return builder object that can be used to construct {@link RefreshTokenParameters}
     */
    public static RefreshTokenParametersBuilder builder(Set scopes, String refreshToken) {
        validateNotBlank("refreshToken", refreshToken);
        return builder().scopes(scopes).refreshToken(refreshToken);
    }


    @java.lang.SuppressWarnings("all")
    public static class RefreshTokenParametersBuilder {
        @java.lang.SuppressWarnings("all")
        private Set scopes;
        @java.lang.SuppressWarnings("all")
        private ClaimsRequest claims;
        @java.lang.SuppressWarnings("all")
        private String refreshToken;

        @java.lang.SuppressWarnings("all")
        RefreshTokenParametersBuilder() {
        }

        @java.lang.SuppressWarnings("all")
        public RefreshTokenParametersBuilder scopes(final Set scopes) {
            this.scopes = scopes;
            return this;
        }

        @java.lang.SuppressWarnings("all")
        public RefreshTokenParametersBuilder claims(final ClaimsRequest claims) {
            this.claims = claims;
            return this;
        }

        @java.lang.SuppressWarnings("all")
        public RefreshTokenParametersBuilder refreshToken(final String refreshToken) {
            this.refreshToken = refreshToken;
            return this;
        }

        @java.lang.SuppressWarnings("all")
        public RefreshTokenParameters build() {
            return new RefreshTokenParameters(scopes, claims, refreshToken);
        }

        @java.lang.Override
        @java.lang.SuppressWarnings("all")
        public java.lang.String toString() {
            return "RefreshTokenParameters.RefreshTokenParametersBuilder(scopes=" + this.scopes + ", claims=" + this.claims + ", refreshToken=" + this.refreshToken + ")";
        }
    }

    /**
     * Scopes the application is requesting access to
     */
    @NonNull
    @java.lang.SuppressWarnings("all")
    public Set scopes() {
        return this.scopes;
    }

    /**
     * Claims to be requested through the OIDC claims request parameter, allowing requests for standard and custom claims
     */
    @java.lang.SuppressWarnings("all")
    public ClaimsRequest claims() {
        return this.claims;
    }

    /**
     * Refresh token received from the STS
     */
    @NonNull
    @java.lang.SuppressWarnings("all")
    public String refreshToken() {
        return this.refreshToken;
    }

    @java.lang.SuppressWarnings("all")
    private RefreshTokenParameters(@NonNull final Set scopes, final ClaimsRequest claims, @NonNull final String refreshToken) {
        if (scopes == null) {
            throw new java.lang.NullPointerException("scopes is marked @NonNull but is null");
        }
        if (refreshToken == null) {
            throw new java.lang.NullPointerException("refreshToken is marked @NonNull but is null");
        }
        this.scopes = scopes;
        this.claims = claims;
        this.refreshToken = refreshToken;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy