001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014-2016 ForgeRock AS.
015 */
016
017package org.forgerock.oauth2.core;
018
019import org.forgerock.json.JsonValue;
020import org.forgerock.oauth2.core.exceptions.ServerException;
021import org.forgerock.openam.audit.AuditConstants;
022
023import java.util.Map;
024
025/**
026 * Models a OAuth2 token.
027 *
028 * @since 12.0.0
029 * @supported.all.api
030 */
031public interface Token {
032
033    /**
034     * Gets the token's identifier.
035     *
036     * @return The token's id.
037     * @throws ServerException If any internal server error occurs.
038     */
039    String getTokenId() throws ServerException;
040
041    /**
042     * Gets the token's name.
043     *
044     * @return The token's name.
045     */
046    String getTokenName();
047
048    /**
049     * Converts the token into a {@code Map} of its key data.
050     *
051     * @return A {@code Map} of the token's key data.
052     * @throws ServerException If any internal server error occurs.
053     */
054    Map<String, Object> toMap() throws ServerException;
055
056    /**
057     * Gets the token's information.
058     *
059     * @return A {@code Map} of the token's information.
060     */
061    Map<String, Object> getTokenInfo();
062
063    /**
064     * Gets the {@link JsonValue} representation of the token.
065     *
066     * @return The {@link JsonValue} representation of the token.
067     */
068    JsonValue toJsonValue();
069
070    /**
071     * Get the audit tracking ID for this token.
072     * @return The tracking ID.
073     */
074    String getAuditTrackingId();
075
076    /**
077     * Get the audit tracking ID key for this token.
078     * @return The tracking ID key.
079     */
080    AuditConstants.TrackingIdKey getAuditTrackingIdKey();
081}