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.oauth2.sdk.ciba; 019 020import com.nimbusds.oauth2.sdk.ParseException; 021import com.nimbusds.oauth2.sdk.id.Identifier; 022import net.jcip.annotations.Immutable; 023 024 025/** 026 * CIBA token delivery mode. 027 * 028 * <ul> 029 * <li>OpenID Connect CIBA Flow - Core 1.0 030 * </ul> 031 */ 032@Immutable 033public final class BackChannelTokenDeliveryMode extends Identifier { 034 035 036 private static final long serialVersionUID = -7661605920720830935L; 037 038 039 /** 040 * Push delivery mode. The OP / AS the tokens to a client callback URI. 041 */ 042 public static final BackChannelTokenDeliveryMode PUSH = new BackChannelTokenDeliveryMode("push"); 043 044 045 /** 046 * Poll delivery mode. The client polls the OP / AS token endpoint to 047 * obtain the tokens. 048 */ 049 public static final BackChannelTokenDeliveryMode POLL = new BackChannelTokenDeliveryMode("poll"); 050 051 052 /** 053 * Ping delivery mode. The OP / AS sends a notification to a client 054 * endpoint that the tokens are available at the token endpoint. 055 */ 056 public static final BackChannelTokenDeliveryMode PING = new BackChannelTokenDeliveryMode("ping"); 057 058 059 /** 060 * Creates a new CIBA token delivery mode with the specified value. 061 * 062 * @param value The CIBA token delivery mode value. Must not be 063 * {@code null}. 064 */ 065 public BackChannelTokenDeliveryMode(final String value) { 066 super(value); 067 } 068 069 070 @Override 071 public boolean equals(final Object object) { 072 073 return object instanceof BackChannelTokenDeliveryMode && this.toString().equals(object.toString()); 074 } 075 076 077 /** 078 * Parses a CIBA token delivery mode from the specified string. 079 * 080 * @param value The string value. 081 * 082 * @return The CIBA token delivery mode. 083 * 084 * @throws ParseException On a illegal CIBA token delivery mode. 085 */ 086 public static BackChannelTokenDeliveryMode parse(final String value) 087 throws ParseException { 088 089 if (PING.getValue().equals(value)) { 090 return PING; 091 } else if (POLL.getValue().equals(value)) { 092 return POLL; 093 } else if (PUSH.getValue().equals(value)) { 094 return PUSH; 095 } else { 096 throw new ParseException("Invalid CIBA token delivery mode: " + value); 097 } 098 } 099}