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.id; 019 020 021import net.jcip.annotations.Immutable; 022 023 024/** 025 * Client identifier. 026 * 027 * <p>Example of a client identifier created from string: 028 * 029 * <pre> 030 * ClientID clientID = new ClientID("client-12345678"); 031 * </pre> 032 * 033 * <p>Related specifications: 034 * 035 * <ul> 036 * <li>OAuth 2.0 (RFC 6749), section 2.2. 037 * </ul> 038 */ 039@Immutable 040public final class ClientID extends Identifier { 041 042 043 private static final long serialVersionUID = 8098426263125084877L; 044 045 046 /** 047 * Creates a new client identifier with the specified value. 048 * 049 * @param value The client identifier value. Must not be {@code null} 050 * or empty string. 051 */ 052 public ClientID(final String value) { 053 054 super(value); 055 } 056 057 058 /** 059 * Creates a new client identifier with the specified value. 060 * 061 * @param value The value. Must not be {@code null}. 062 */ 063 public ClientID(final Identifier value) { 064 065 super(value.getValue()); 066 } 067 068 069 /** 070 * Creates a new client identifier with a randomly generated value of 071 * the specified byte length, Base64URL-encoded. 072 * 073 * @param byteLength The byte length of the value to generate. Must be 074 * greater than one. 075 */ 076 public ClientID(final int byteLength) { 077 078 super(byteLength); 079 } 080 081 082 /** 083 * Creates a new client identifier with a randomly generated 256-bit 084 * (32-byte) value, Base64URL-encoded. 085 */ 086 public ClientID() { 087 088 super(); 089 } 090 091 092 @Override 093 public boolean equals(final Object object) { 094 095 return object instanceof ClientID && 096 this.toString().equals(object.toString()); 097 } 098}