package com.atlassian.bitbucket.mesh.auth;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Callback provided to callers of {@link AuthenticationManager#withPrincipal}.
 *
 * @param <T> the type returned by the callback
 */
@FunctionalInterface
public interface PrincipalCallback<T> {

    /**
     * @param principal the authenticated principal which is active during the callback
     * @return the return value for {@link AuthenticationManager#withPrincipal}
     */
    @Nullable
    T callWithPrincipal(@Nonnull Principal principal);
}
