001package com.nimbusds.oauth2.sdk; 002 003 004import net.jcip.annotations.Immutable; 005 006import com.nimbusds.oauth2.sdk.id.Identifier; 007 008 009/** 010 * Authorisation code. A maximum authorization code lifetime of 10 minutes is 011 * recommended. 012 * 013 * <p>Related specifications: 014 * 015 * <ul> 016 * <li>OAuth 2.0 (RFC 6749), section 1.3.1. 017 * </ul> 018 */ 019@Immutable 020public final class AuthorizationCode extends Identifier { 021 022 023 /** 024 * Creates a new authorisation code with the specified value. 025 * 026 * @param value The code value. Must not be {@code null} or empty 027 * string. 028 */ 029 public AuthorizationCode(final String value) { 030 031 super(value); 032 } 033 034 035 /** 036 * Creates a new authorisation code with a randomly generated value of 037 * the specified byte length, Base64URL-encoded. 038 * 039 * @param byteLength The byte length of the value to generate. Must be 040 * greater than one. 041 */ 042 public AuthorizationCode(final int byteLength) { 043 044 super(byteLength); 045 } 046 047 048 /** 049 * Creates a new authorisation code with a randomly generated 256-bit 050 * (32-byte) value, Base64URL-encoded. 051 */ 052 public AuthorizationCode() { 053 054 super(); 055 } 056 057 058 @Override 059 public boolean equals(final Object object) { 060 061 return object instanceof AuthorizationCode && 062 this.toString().equals(object.toString()); 063 } 064}