001package com.nimbusds.oauth2.sdk.token;
002
003
004import net.minidev.json.JSONObject;
005
006import net.jcip.annotations.Immutable;
007
008
009/**
010 * Typeless access token, cannot be serialised. Intended to represent parsed
011 * access tokens which type cannot be inferred. This class is immutable.
012 *
013 * <p>Related specifications:
014 *
015 * <ul>
016 *     <li>OAuth 2.0 (RFC 6749), sections 1.4 and 5.1.
017 * </ul>
018 *
019 * @author Vladimir Dzhuvinov
020 */
021@Immutable
022public class TypelessAccessToken extends AccessToken {
023
024        
025        /**
026         * Creates a new minimal typeless access token with the specified 
027         * value. The optional lifetime and scope are left undefined.
028         *
029         * @param value The access token value. Must not be {@code null} or
030         *              empty string.
031         */
032        public TypelessAccessToken(final String value) {
033        
034                super(AccessTokenType.UNKNOWN, value);
035        }
036
037
038        /**
039         * Operation not supported.
040         * 
041         * @throws UnsupportedOperationException Serialisation is not 
042         *                                       supported.
043         */
044        @Override
045        public JSONObject toJSONObject() {
046
047                throw new UnsupportedOperationException("Serialization not supported");
048        }
049        
050        
051        /**
052         * Operation not supported.
053         * 
054         * @throws UnsupportedOperationException Serialisation is not 
055         *                                       supported.
056         */
057        @Override
058        public String toAuthorizationHeader() {
059
060                throw new UnsupportedOperationException("Serialization not supported");
061        }
062        
063        
064        @Override
065        public boolean equals(final Object object) {
066        
067                return object instanceof AccessToken &&
068                       this.toString().equals(object.toString());
069        }
070}