001package com.nimbusds.oauth2.sdk.id; 002 003 004import net.jcip.annotations.Immutable; 005 006 007/** 008 * Client identifier. 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@Immutable 023public final class ClientID extends Identifier { 024 025 026 /** 027 * Creates a new client identifier with the specified value. 028 * 029 * @param value The client identifier value. Must not be {@code null} 030 * or empty string. 031 */ 032 public ClientID(final String value) { 033 034 super(value); 035 } 036 037 038 /** 039 * Creates a new client identifier with a randomly generated value of 040 * the specified byte length, Base64URL-encoded. 041 * 042 * @param byteLength The byte length of the value to generate. Must be 043 * greater than one. 044 */ 045 public ClientID(final int byteLength) { 046 047 super(byteLength); 048 } 049 050 051 /** 052 * Creates a new client identifier with a randomly generated 256-bit 053 * (32-byte) value, Base64URL-encoded. 054 */ 055 public ClientID() { 056 057 super(); 058 } 059 060 061 @Override 062 public boolean equals(final Object object) { 063 064 return object instanceof ClientID && 065 this.toString().equals(object.toString()); 066 } 067}