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'>
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'>
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 * <h5 class='section'>See Also:</h5><ul>
049 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
050 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
051 * </ul>
052 *
053 * @serial exclude
054 */
055@Header("Proxy-Authenticate")
056public class ProxyAuthenticate extends BasicStringHeader {
057
058   //-----------------------------------------------------------------------------------------------------------------
059   // Static
060   //-----------------------------------------------------------------------------------------------------------------
061
062   private static final long serialVersionUID = 1L;
063   private static final String NAME = "Proxy-Authenticate";
064
065   /**
066    * Static creator.
067    *
068    * @param value
069    *    The header value.
070    *    <br>Can be <jk>null</jk>.
071    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
072    */
073   public static ProxyAuthenticate of(String value) {
074      return value == null ? null : new ProxyAuthenticate(value);
075   }
076
077   /**
078    * Static creator with delayed value.
079    *
080    * <p>
081    * Header value is re-evaluated on each call to {@link #getValue()}.
082    *
083    * @param value
084    *    The supplier of the header value.
085    *    <br>Can be <jk>null</jk>.
086    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
087    */
088   public static ProxyAuthenticate of(Supplier<String> value) {
089      return value == null ? null : new ProxyAuthenticate(value);
090   }
091
092   //-----------------------------------------------------------------------------------------------------------------
093   // Instance
094   //-----------------------------------------------------------------------------------------------------------------
095
096   /**
097    * Constructor.
098    *
099    * @param value
100    *    The header value.
101    *    <br>Can be <jk>null</jk>.
102    */
103   public ProxyAuthenticate(String value) {
104      super(NAME, value);
105   }
106
107   /**
108    * Constructor with delayed value.
109    *
110    * <p>
111    * Header value is re-evaluated on each call to {@link #getValue()}.
112    *
113    * @param value
114    *    The supplier of the header value.
115    *    <br>Can be <jk>null</jk>.
116    */
117   public ProxyAuthenticate(Supplier<String> value) {
118      super(NAME, value);
119   }
120}