001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.exception;
014
015import static org.apache.juneau.rest.exception.NetworkAuthenticationRequired.*;
016
017import java.text.*;
018
019import org.apache.juneau.http.annotation.*;
020import org.apache.juneau.rest.*;
021
022/**
023 * Exception representing an HTTP 511 (Network Authentication Required).
024 *
025 * <div class='warn'>
026 *    <b>Deprecated</b> - Use {@link org.apache.juneau.http.exception.NetworkAuthenticationRequired}
027 * </div>
028 *
029 * <p>
030 * The client needs to authenticate to gain network access.
031 * <br>Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
032 */
033@Response(code=CODE, description=MESSAGE)
034@Deprecated
035public class NetworkAuthenticationRequired extends RestException {
036   private static final long serialVersionUID = 1L;
037
038   /** HTTP status code */
039   public static final int CODE = 511;
040
041   /** Default message */
042   public static final String MESSAGE = "Network Authentication Required";
043
044   /**
045    * Constructor.
046    *
047    * @param cause The cause.  Can be <jk>null</jk>.
048    * @param msg The message.  Can be <jk>null</jk>.
049    * @param args Optional {@link MessageFormat}-style arguments in the message.
050    */
051   public NetworkAuthenticationRequired(Throwable cause, String msg, Object...args) {
052      super(cause, CODE, msg, args);
053   }
054
055   /**
056    * Constructor.
057    *
058    * @param msg The message.  Can be <jk>null</jk>.
059    */
060   public NetworkAuthenticationRequired(String msg) {
061      super(msg);
062      setStatus(CODE);
063   }
064
065   /**
066    * Constructor.
067    */
068   public NetworkAuthenticationRequired() {
069      this((Throwable)null, MESSAGE);
070   }
071
072   /**
073    * Constructor.
074    *
075    * @param msg The message.  Can be <jk>null</jk>.
076    * @param args Optional {@link MessageFormat}-style arguments in the message.
077    */
078   public NetworkAuthenticationRequired(String msg, Object...args) {
079      this(null, msg, args);
080   }
081
082   /**
083    * Constructor.
084    *
085    * @param cause The cause.  Can be <jk>null</jk>.
086    */
087   public NetworkAuthenticationRequired(Throwable cause) {
088      this(cause, null);
089   }
090}