// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AccessToken.java
// public interface OAuth2AccessToken
// {
//     /**
//      * Returns the actual access token String.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public CharSequence accessToken() throws ProtocolException;
// 
//     /**
//      * Returns the access token type.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public CharSequence tokenType() throws ProtocolException;
// 
//     /**
//      * Returns whether the response also contained a refresh token.
//      *
//      * @return
//      */
//     public boolean hasRefreshToken();
// 
//     /**
//      * Returns the refresh token. Before calling this use {@link #hasRefreshToken()} to check if there actually is a refresh token.
//      *
//      * @return
//      *
//      * @throws NoSuchElementException
//      *         If the token doesn't contain a refresh token.
//      * @throws ProtocolException
//      */
//     public CharSequence refreshToken() throws ProtocolException;
// 
//     /**
//      * Returns the expected expiration date of the access token.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public DateTime expirationDate() throws ProtocolException;
// 
//     /**
//      * The scope this {@link OAuth2AccessToken} was issued for. May be an empty scope if the scope is not known.
//      *
//      * @return An {@link OAuth2Scope}.
//      *
//      * @throws ProtocolException
//      */
//     public OAuth2Scope scope() throws ProtocolException;
// 
//     /**
//      * Returns a value stored in the token response under the {@code parameterName}.
//      *
//      * @param parameterName
//      *         the key under which the value is stored in the response
//      */
//     public Optional<CharSequence> extraParameter(final String parameterName);
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> ACCESS_TOKEN = new BasicParameterType<>("access_token", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<Duration> EXPIRES_IN = new BasicParameterType<>("expires_in", new DurationValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<OAuth2Scope> SCOPE = new BasicParameterType<OAuth2Scope>("scope", new OAuth2ScopeValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> STATE = new BasicParameterType<>("state", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> TOKEN_TYPE = new BasicParameterType<>("token_type", TextValueType.INSTANCE);


import org.dmfs.httpessentials.exceptions.ProtocolException;
import org.dmfs.jems.optional.Optional;
import org.dmfs.oauth2.client.OAuth2AccessToken;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.rfc3986.Uri;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.adapters.OptionalParameter;
import org.dmfs.rfc3986.parameters.adapters.TextParameter;
import org.dmfs.rfc3986.parameters.adapters.XwfueParameterList;
import org.dmfs.rfc3986.parameters.parametertypes.BasicParameterType;
import org.dmfs.rfc3986.parameters.valuetypes.TextValueType;
import org.dmfs.rfc5545.DateTime;
import org.dmfs.rfc5545.Duration;
import java.util.NoSuchElementException;
import static org.dmfs.oauth2.client.utils.Parameters.ACCESS_TOKEN;
import static org.dmfs.oauth2.client.utils.Parameters.EXPIRES_IN;
import static org.dmfs.oauth2.client.utils.Parameters.SCOPE;
import static org.dmfs.oauth2.client.utils.Parameters.STATE;
import static org.dmfs.oauth2.client.utils.Parameters.TOKEN_TYPE;
/*
 * Copyright 2016 dmfs GmbH
 *
 * 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 org.dmfs.oauth2.client.tokens;





/**
 * Represents an {@link OAuth2AccessToken} received from an Implicit Grant.
 *
 * @author Marten Gajda
 */
public final class ImplicitGrantAccessToken implements OAuth2AccessToken
{
    private final Uri mRedirectUri;
    private final ParameterList mRedirectUriParameters;
    private final DateTime mIssueDate;
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AccessToken.java
// public interface OAuth2AccessToken
// {
//     /**
//      * Returns the actual access token String.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public CharSequence accessToken() throws ProtocolException;
// 
//     /**
//      * Returns the access token type.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public CharSequence tokenType() throws ProtocolException;
// 
//     /**
//      * Returns whether the response also contained a refresh token.
//      *
//      * @return
//      */
//     public boolean hasRefreshToken();
// 
//     /**
//      * Returns the refresh token. Before calling this use {@link #hasRefreshToken()} to check if there actually is a refresh token.
//      *
//      * @return
//      *
//      * @throws NoSuchElementException
//      *         If the token doesn't contain a refresh token.
//      * @throws ProtocolException
//      */
//     public CharSequence refreshToken() throws ProtocolException;
// 
//     /**
//      * Returns the expected expiration date of the access token.
//      *
//      * @return
//      *
//      * @throws ProtocolException
//      */
//     public DateTime expirationDate() throws ProtocolException;
// 
//     /**
//      * The scope this {@link OAuth2AccessToken} was issued for. May be an empty scope if the scope is not known.
//      *
//      * @return An {@link OAuth2Scope}.
//      *
//      * @throws ProtocolException
//      */
//     public OAuth2Scope scope() throws ProtocolException;
// 
//     /**
//      * Returns a value stored in the token response under the {@code parameterName}.
//      *
//      * @param parameterName
//      *         the key under which the value is stored in the response
//      */
//     public Optional<CharSequence> extraParameter(final String parameterName);
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> ACCESS_TOKEN = new BasicParameterType<>("access_token", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<Duration> EXPIRES_IN = new BasicParameterType<>("expires_in", new DurationValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<OAuth2Scope> SCOPE = new BasicParameterType<OAuth2Scope>("scope", new OAuth2ScopeValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> STATE = new BasicParameterType<>("state", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> TOKEN_TYPE = new BasicParameterType<>("token_type", TextValueType.INSTANCE);


// Path: src/main/java/org/dmfs/oauth2/client/tokens/ImplicitGrantAccessToken.java
import org.dmfs.httpessentials.exceptions.ProtocolException;
import org.dmfs.jems.optional.Optional;
import org.dmfs.oauth2.client.OAuth2AccessToken;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.rfc3986.Uri;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.adapters.OptionalParameter;
import org.dmfs.rfc3986.parameters.adapters.TextParameter;
import org.dmfs.rfc3986.parameters.adapters.XwfueParameterList;
import org.dmfs.rfc3986.parameters.parametertypes.BasicParameterType;
import org.dmfs.rfc3986.parameters.valuetypes.TextValueType;
import org.dmfs.rfc5545.DateTime;
import org.dmfs.rfc5545.Duration;
import java.util.NoSuchElementException;
import static org.dmfs.oauth2.client.utils.Parameters.ACCESS_TOKEN;
import static org.dmfs.oauth2.client.utils.Parameters.EXPIRES_IN;
import static org.dmfs.oauth2.client.utils.Parameters.SCOPE;
import static org.dmfs.oauth2.client.utils.Parameters.STATE;
import static org.dmfs.oauth2.client.utils.Parameters.TOKEN_TYPE;

/*
 * Copyright 2016 dmfs GmbH
 *
 * 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 org.dmfs.oauth2.client.tokens;





/**
 * Represents an {@link OAuth2AccessToken} received from an Implicit Grant.
 *
 * @author Marten Gajda
 */
public final class ImplicitGrantAccessToken implements OAuth2AccessToken
{
    private final Uri mRedirectUri;
    private final ParameterList mRedirectUriParameters;
    private final DateTime mIssueDate;
    private final OAuth2Scope mScope;