001/*
002 * oauth2-oidc-sdk
003 *
004 * Copyright 2012-2016, Connect2id Ltd and contributors.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
007 * this file except in compliance with the License. You may obtain a copy of the
008 * License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed
013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
015 * specific language governing permissions and limitations under the License.
016 */
017
018package com.nimbusds.openid.connect.sdk.claims;
019
020
021import com.nimbusds.oauth2.sdk.ParseException;
022
023
024/**
025 * Enumeration of the claim types.
026 * 
027 * <p>Related specifications:
028 *
029 * <ul>
030 *     <li>OpenID Connect Core 1.0, section 5.6.
031 *     <li>OpenID Connect Discovery 1.0, section 3.
032 * </ul>
033 */
034public enum ClaimType {
035        
036        /**
037         * Claims that are directly asserted by the OpenID Connect provider. 
038         */
039        NORMAL,
040                
041        
042        /**
043         * Claims that are asserted by a claims provider other than the 
044         * OpenID Connect Provider but are returned by OpenID Connect provider. 
045         */
046        AGGREGATED,
047                
048        
049        /**
050         * Claims that are asserted by a claims provider other than the OpenID
051         * Connect provider but are returned as references by the OpenID 
052         * Connect provider. 
053         */
054        DISTRIBUTED;
055
056        
057        /**
058         * Returns the string identifier of this claim type.
059         *
060         * @return The string identifier.
061         */
062        @Override
063        public String toString() {
064                
065                return super.toString().toLowerCase();
066        }
067        
068        
069        /**
070         * Parses a claim type.
071         * 
072         * @param s The string to parse. Must not be {@code null}.
073         * 
074         * @return The claim type.
075         */
076        public static ClaimType parse(final String s)
077                throws ParseException {
078                
079                if (s.equals("normal"))
080                        return NORMAL;
081                
082                if (s.equals("aggregated"))
083                        return AGGREGATED;
084                
085                if (s.equals("distributed"))
086                        return DISTRIBUTED;
087                
088                throw new ParseException("Unknow claim type: " + s);
089        }
090}