/*
* Copyright 2015 Stormpath, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.stormpath.sdk.oauth;

import com.stormpath.sdk.account.Account;
import com.stormpath.sdk.application.Application;
import com.stormpath.sdk.resource.Deletable;
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.tenant.Tenant;

import java.util.Map;

/**
 * This is a base interface for those methods that Stormpath
 * {@link AccessToken}s and {@link RefreshToken}s have in common.
 *
 * @see AccessToken
 * @see RefreshToken
 *
 * @since 1.0.RC8.3
 */
public interface BaseOAuthToken extends Resource, Deletable {

    /**
     * Returns the String representation of the Json Web Token.
     *
     * @return a String value denoting a JWT.
     */
    String getJwt();

    /**
     * Returns the {@link Account} associated to this {@link AccessToken}.
     *
     * @return the {@link Account} associated to this {@link AccessToken}.
     */
    Account getAccount();

    /**
     * Returns the {@link Application} associated to this {@link AccessToken}.
     *
     * @return the {@link Application} associated to this {@link AccessToken}.
     */
    Application getApplication();

    /**
     * Returns the {@link Tenant} this {@link AccessToken} belongs to.
     *
     * @return the {@link Tenant} this {@link AccessToken} belongs to.
     */
    Tenant getTenant();

    /**
     * Returns the expanded (un-compacted) properties of this {@link AccessToken}'s JWT.
     *
     * @return the expanded (un-compacted) properties of this {@link AccessToken}'s JWT.
     *
     * @since 1.0.RC9
     */
    Map<String, Object> getExpandedJwt();

    /**
     * Revokes the current oauth token ({@link AccessToken} or {@link RefreshToken}) according to the
     * <a href="https://tools.ietf.org/html/rfc7009">OAuth 2.0 Token Revocation</a> spec.
     * <p>
     * Unlike {@link #delete()} method, the revocation propagates to all the tokens generated by the same {@link RefreshToken},
     * i.e. all the tokens associated to the same "refresh_token" will be revoked when either the {@link RefreshToken} or one
     * of the {@link AccessToken}'s generated with the "refresh_token" grant_type are revoked.
     * </p>
     *
     * @since 1.2.0
     */
    void revoke();

}
