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.
012 */
013@Immutable
014public final class Audience extends Identifier {
015
016
017        /**
018         * Creates a new audience identifier with the specified value.
019         *
020         * @param value The audience identifier value. Must not be {@code null}
021         *              or empty string.
022         */
023        public Audience(final String value) {
024
025                super(value);
026        }
027
028
029        /**
030         * Creates a new audience identifier with a randomly generated value of 
031         * the specified byte length, Base64URL-encoded.
032         *
033         * @param byteLength The byte length of the value to generate. Must be
034         *                   greater than one.
035         */
036        public Audience(final int byteLength) {
037        
038                super(byteLength);
039        }
040        
041        
042        /**
043         * Creates a new audience identifier with a randomly generated 256-bit 
044         * (32-byte) value, Base64URL-encoded.
045         */
046        public Audience() {
047
048                super();
049        }
050
051
052        /**
053         * Returns a list consisting of this audience only.
054         *
055         * @return A list consisting of this audience only.
056         */
057        public List<Audience> toSingleAudienceList() {
058
059                List<Audience> audienceList = new ArrayList<Audience>(1);
060                audienceList.add(this);
061                return audienceList;
062        }
063
064
065        @Override
066        public boolean equals(final Object object) {
067        
068                return object instanceof Audience &&
069                       this.toString().equals(object.toString());
070        }
071}