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

com.atlassian.usercontext.api.UserContext Maven / Gradle / Ivy

package com.atlassian.usercontext.api;

import com.atlassian.asap.api.Jwt;

/**
 * Represents the user-context token, which contains
 *
 * Reference: https://hello.atlassian.net/wiki/spaces/ARCH/pages/161912986/Specification+Standard+User+Context+Claims.
 */
public interface UserContext {

    /**
     * Get the user-context specific claims object, which contains accessors for all the
     * claims in the specification.
     *
     * @return {@link UserContextClaims}
     */
    UserContextClaims getUserContextClaims();

    /**
     * Get the account id for any user that is being impersonated within the context, or the account id claim if there is
     * no user being impersonated.
     *
     * Currently the only supported context restriction is the raw cloud id of a site.
     *
     * @return {@link AccountId}
     */
    AccountId resolveAccountId(String contextRestriction);

    /**
     * Get the underlying jwt deserialized from the signed token.
     *
     * @return {@link Jwt}
     */
    Jwt getUserContextJwt();

    /**
     * Get the original signed token.
     *
     * This is necessary for forwarding the token to other services, which will independently
     * verify the authenticity of the token.
     *
     * @return base64 encoded string representing original signed user-context jwt token
     */
    String getSignedJwt();

    /**
     * Two UserContexts are considered equal if all claims in {@link UserContextClaims.UserContextRegisteredClaim} are equal
     * as well as the iss claim.
     * (Note this specifically does not include expiry)
     * Does not check that the signature is equal
     * @param o the object to compare to
     * @return if they are equal
     */
    @Override
    boolean equals(Object o);

    /**
     * @return a hashCode based on the definition of {@link #equals(Object)}
     */
    @Override
    int hashCode();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy