001    package com.nimbusds.oauth2.sdk;
002    
003    
004    import net.jcip.annotations.Immutable;
005    
006    import com.nimbusds.oauth2.sdk.id.Identifier;
007    
008    
009    /**
010     * Authorisation code. A maximum authorization code lifetime of 10 minutes is 
011     * recommended. This class is immutable.
012     *
013     * <p>Related specifications:
014     *
015     * <ul>
016     *     <li>OAuth 2.0 (RFC 6749), section 1.3.1.
017     * </ul>
018     *
019     * @author Vladimir Dzhuvinov
020     * @version $version$ (2013-01-15)
021     */
022    @Immutable
023    public final class AuthorizationCode extends Identifier {
024    
025    
026            /**
027             * Creates a new authorisation code with the specified value.
028             *
029             * @param value The code value. Must not be {@code null} or empty 
030             *              string.
031             */
032            public AuthorizationCode(final String value) {
033            
034                    super(value);
035            }
036    
037    
038            /**
039             * Creates a new authorisation code with a randomly generated value of 
040             * the specified length. The value will be made up of mixed-case 
041             * alphanumeric ASCII characters.
042             *
043             * @param length The number of characters. Must be a positive integer.
044             */
045            public AuthorizationCode(final int length) {
046            
047                    super(length);
048            }
049            
050            
051            /**
052             * Creates a new authorisation code with a randomly generated value. 
053             * The value will be made up of 32 mixed-case alphanumeric ASCII 
054             * characters.
055             */
056            public AuthorizationCode() {
057    
058                    super();
059            }
060            
061            
062            @Override
063            public boolean equals(final Object object) {
064            
065                    return object != null && 
066                           object instanceof AuthorizationCode && 
067                           this.toString().equals(object.toString());
068            }
069    }