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