001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.oauth2.sdk; 019 020 021import net.jcip.annotations.Immutable; 022 023import com.nimbusds.oauth2.sdk.id.Identifier; 024 025 026/** 027 * Authorisation code. A maximum authorization code lifetime of 10 minutes is 028 * recommended. 029 * 030 * <p>Related specifications: 031 * 032 * <ul> 033 * <li>OAuth 2.0 (RFC 6749), section 1.3.1. 034 * </ul> 035 */ 036@Immutable 037public final class AuthorizationCode extends Identifier { 038 039 040 /** 041 * Creates a new authorisation code with the specified value. 042 * 043 * @param value The code value. Must not be {@code null} or empty 044 * string. 045 */ 046 public AuthorizationCode(final String value) { 047 048 super(value); 049 } 050 051 052 /** 053 * Creates a new authorisation code with a randomly generated value of 054 * the specified byte length, Base64URL-encoded. 055 * 056 * @param byteLength The byte length of the value to generate. Must be 057 * greater than one. 058 */ 059 public AuthorizationCode(final int byteLength) { 060 061 super(byteLength); 062 } 063 064 065 /** 066 * Creates a new authorisation code with a randomly generated 256-bit 067 * (32-byte) value, Base64URL-encoded. 068 */ 069 public AuthorizationCode() { 070 071 super(); 072 } 073 074 075 @Override 076 public boolean equals(final Object object) { 077 078 return object instanceof AuthorizationCode && 079 this.toString().equals(object.toString()); 080 } 081}