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

com.microsoft.aad.msal4j.UserAssertion 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

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.aad.msal4j;

/***
 * Credential type containing an assertion representing a delegated user identity.
 * Used as a parameter in {@link OnBehalfOfParameters}
 */
public class UserAssertion implements IUserAssertion {

    private final String assertion;
    private final String assertionHash;

    /**
     * Constructor to create credential with a jwt token encoded as a base64 url
     * encoded string.
     *
     * @param assertion The jwt used as credential.
     */
    public UserAssertion(final String assertion) {
        if (StringHelper.isBlank(assertion)) {
            throw new NullPointerException("assertion");
        }

        this.assertion = assertion;
        this.assertionHash = StringHelper.createBase64EncodedSha256Hash(this.assertion);
    }

    /**
     * Gets the assertion.
     *
     * @return assertion
     */
    @Override
    public String getAssertion() {
        return assertion;
    }

    /**
     * @return Base64 encoded SHA256 hash of the assertion
     */
    public String getAssertionHash() {
        return this.assertionHash;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy