001package com.nimbusds.oauth2.sdk.id;
002
003
004import java.util.ArrayList;
005import java.util.List;
006
007import net.jcip.annotations.Immutable;
008
009
010/**
011 * Audience identifier. This class is immutable.
012 *
013 * @author Vladimir Dzhuvinov
014 */
015@Immutable
016public final class Audience extends Identifier {
017
018
019        /**
020         * Creates a new audience identifier with the specified value.
021         *
022         * @param value The audience identifier value. Must not be {@code null}
023         *              or empty string.
024         */
025        public Audience(final String value) {
026
027                super(value);
028        }
029
030
031        /**
032         * Creates a new audience identifier with a randomly generated value of 
033         * the specified byte length, Base64URL-encoded.
034         *
035         * @param byteLength The byte length of the value to generate. Must be
036         *                   greater than one.
037         */
038        public Audience(final int byteLength) {
039        
040                super(byteLength);
041        }
042        
043        
044        /**
045         * Creates a new audience identifier with a randomly generated 256-bit 
046         * (32-byte) value, Base64URL-encoded.
047         */
048        public Audience() {
049
050                super();
051        }
052
053
054        /**
055         * Returns a list consisting of this audience only.
056         *
057         * @return A list consisting of this audience only.
058         */
059        public List<Audience> toSingleAudienceList() {
060
061                List<Audience> audienceList = new ArrayList<Audience>(1);
062                audienceList.add(this);
063                return audienceList;
064        }
065
066
067        @Override
068        public boolean equals(final Object object) {
069        
070                return object instanceof Audience &&
071                       this.toString().equals(object.toString());
072        }
073}