001package com.nimbusds.openid.connect.sdk.claims;
002
003
004import com.nimbusds.oauth2.sdk.ParseException;
005
006
007/**
008 * Enumeration of the claim types. This class is immutable.
009 * 
010 * <p>Related specifications:
011 *
012 * <ul>
013 *     <li>OpenID Connect Messages 1.0, section 2.7.
014 *     <li>OpenID Connect Discovery, section 3.
015 * </ul>
016 * 
017 * @author Vladimir Dzhuvinov
018 */
019public enum ClaimType {
020        
021        /**
022         * Claims that are directly asserted by the OpenID Connect provider. 
023         */
024        NORMAL,
025                
026        
027        /**
028         * Claims that are asserted by a claims provider other than the 
029         * OpenID Connect Provider but are returned by OpenID Connect provider. 
030         */
031        AGGREGATED,
032                
033        
034        /**
035         * Claims that are asserted by a claims provider other than the OpenID
036         * Connect provider but are returned as references by the OpenID 
037         * Connect provider. 
038         */
039        DISTRIBUTED;
040
041        
042        /**
043         * Returns the string identifier of this claim type.
044         *
045         * @return The string identifier.
046         */
047        @Override
048        public String toString() {
049                
050                return super.toString().toLowerCase();
051        }
052        
053        
054        /**
055         * Parses a claim type.
056         * 
057         * @param s The string to parse. Must not be {@code null}.
058         * 
059         * @return The claim type.
060         */
061        public static ClaimType parse(final String s)
062                throws ParseException {
063                
064                if (s.equals("normal"))
065                        return NORMAL;
066                
067                if (s.equals("aggregated"))
068                        return AGGREGATED;
069                
070                if (s.equals("distributed"))
071                        return DISTRIBUTED;
072                
073                throw new ParseException("Unknow claim type: " + s);
074        }
075}