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. 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@Immutable 020public class TypelessAccessToken extends AccessToken { 021 022 023 /** 024 * Creates a new minimal typeless access token with the specified 025 * value. The optional lifetime and scope are left undefined. 026 * 027 * @param value The access token value. Must not be {@code null} or 028 * empty string. 029 */ 030 public TypelessAccessToken(final String value) { 031 032 super(AccessTokenType.UNKNOWN, value); 033 } 034 035 036 /** 037 * Operation not supported. 038 * 039 * @throws UnsupportedOperationException Serialisation is not 040 * supported. 041 */ 042 @Override 043 public JSONObject toJSONObject() { 044 045 throw new UnsupportedOperationException("Serialization not supported"); 046 } 047 048 049 /** 050 * Operation not supported. 051 * 052 * @throws UnsupportedOperationException Serialisation is not 053 * supported. 054 */ 055 @Override 056 public String toAuthorizationHeader() { 057 058 throw new UnsupportedOperationException("Serialization not supported"); 059 } 060 061 062 @Override 063 public boolean equals(final Object object) { 064 065 return object instanceof AccessToken && 066 this.toString().equals(object.toString()); 067 } 068}