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.http.header;
014
015import java.util.function.*;
016
017import org.apache.juneau.http.annotation.*;
018
019/**
020 * Represents a parsed <l> Proxy-Authenticate</l> HTTP response header.
021 *
022 * <p>
023 * Request authentication to access the proxy.
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode w800'>
027 *    Proxy-Authenticate: Basic
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Proxy-Authenticate response-header field MUST be included as part of a 407 (Proxy Authentication Required)
033 * response.
034 * The field value consists of a challenge that indicates the authentication scheme and parameters applicable to the
035 * proxy for this Request-URI.
036 *
037 * <p class='bcode w800'>
038 *    Proxy-Authenticate  = "Proxy-Authenticate" ":" 1#challenge
039 * </p>
040 *
041 * <p>
042 * The HTTP access authentication process is described in "HTTP Authentication: Basic and Digest Access Authentication".
043 * Unlike WWW-Authenticate, the Proxy-Authenticate header field applies only to the current connection and SHOULD NOT
044 * be passed on to downstream clients.
045 * However, an intermediate proxy might need to obtain its own credentials by requesting them from the downstream
046 * client, which in some circumstances will appear as if the proxy is forwarding the Proxy-Authenticate header field.
047 *
048 * <ul class='seealso'>
049 *    <li class='extlink'>{@doc ExtRFC2616}
050 * </ul>
051 */
052@Header("Proxy-Authenticate")
053public class ProxyAuthenticate extends BasicStringHeader {
054
055   private static final long serialVersionUID = 1L;
056
057   /**
058    * Convenience creator.
059    *
060    * @param value
061    *    The header value.
062    *    <br>Can be any of the following:
063    *    <ul>
064    *       <li>{@link String}
065    *       <li>Anything else - Converted to <c>String</c> then parsed.
066    *    </ul>
067    * @return A new {@link ProxyAuthenticate} object.
068    */
069   public static ProxyAuthenticate of(Object value) {
070      if (value == null)
071         return null;
072      return new ProxyAuthenticate(value);
073   }
074
075   /**
076    * Convenience creator using supplier.
077    *
078    * <p>
079    * Header value is re-evaluated on each call to {@link #getValue()}.
080    *
081    * @param value
082    *    The header value supplier.
083    *    <br>Can be any of the following:
084    *    <ul>
085    *       <li>{@link String}
086    *       <li>Anything else - Converted to <c>String</c> then parsed.
087    *    </ul>
088    * @return A new {@link ProxyAuthenticate} object.
089    */
090   public static ProxyAuthenticate of(Supplier<?> value) {
091      if (value == null)
092         return null;
093      return new ProxyAuthenticate(value);
094   }
095
096   /**
097    * Constructor.
098    *
099    * @param value
100    *    The header value.
101    *    <br>Can be any of the following:
102    *    <ul>
103    *       <li>{@link String}
104    *       <li>Anything else - Converted to <c>String</c> then parsed.
105    *       <li>A {@link Supplier} of anything on this list.
106    *    </ul>
107    */
108   public ProxyAuthenticate(Object value) {
109      super("Proxy-Authenticate", value);
110   }
111
112   /**
113    * Constructor
114    *
115    * @param value
116    *    The header value.
117    */
118   public ProxyAuthenticate(String value) {
119      this((Object)value);
120   }
121}