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