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 the specified value. 040 * 041 * @param value The value. Must not be {@code null}. 042 */ 043 public ClientID(final Identifier value) { 044 045 super(value.getValue()); 046 } 047 048 049 /** 050 * Creates a new client identifier with a randomly generated value of 051 * the specified byte length, Base64URL-encoded. 052 * 053 * @param byteLength The byte length of the value to generate. Must be 054 * greater than one. 055 */ 056 public ClientID(final int byteLength) { 057 058 super(byteLength); 059 } 060 061 062 /** 063 * Creates a new client identifier with a randomly generated 256-bit 064 * (32-byte) value, Base64URL-encoded. 065 */ 066 public ClientID() { 067 068 super(); 069 } 070 071 072 @Override 073 public boolean equals(final Object object) { 074 075 return object instanceof ClientID && 076 this.toString().equals(object.toString()); 077 } 078}