001    package com.nimbusds.oauth2.sdk.id;
002    
003    
004    import 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
025    public 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 length. The value will be made up of mixed-case 
043             * alphanumeric ASCII characters.
044             *
045             * @param length The number of characters. Must be a positive integer.
046             */
047            public ClientID(final int length) {
048            
049                    super(length);
050            }
051            
052            
053            /**
054             * Creates a new client identifier with a randomly generated value. The
055             * value will be made up of 32 mixed-case alphanumeric ASCII 
056             * characters.
057             */
058            public ClientID() {
059    
060                    super();
061            }
062    
063    
064            @Override
065            public boolean equals(final Object object) {
066            
067                    return object != null && 
068                           object instanceof ClientID && 
069                           this.toString().equals(object.toString());
070            }
071    }