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-Authorization</l> HTTP request header.
021 *
022 * <p>
023 * Authorization credentials for connecting to a proxy.
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode'>
027 *    Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Proxy-Authorization request-header field allows the client to identify itself (or its user) to a proxy which
033 * requires authentication.
034 * The Proxy-Authorization field value consists of credentials containing the authentication information of the user
035 * agent for the proxy and/or realm of the resource being requested.
036 *
037 * <p class='bcode'>
038 *    Proxy-Authorization     = "Proxy-Authorization" ":" credentials
039 * </p>
040 *
041 * <p>
042 * The HTTP access authentication process is described in "HTTP Authentication: Basic and Digest Access Authentication".
043 * Unlike Authorization, the Proxy-Authorization header field applies only to the next outbound proxy that demanded
044 * authentication using the Proxy-Authenticate field.
045 * When multiple proxies are used in a chain, the Proxy-Authorization header field is consumed by the first outbound
046 * proxy that was expecting to receive credentials.
047 * A proxy MAY relay the credentials from the client request to the next proxy if that is the mechanism by which the
048 * proxies cooperatively authenticate a given request.
049 *
050 * <h5 class='section'>See Also:</h5><ul>
051 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
052 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
053 * </ul>
054 *
055 * @serial exclude
056 */
057@Header("Proxy-Authorization")
058public class ProxyAuthorization extends BasicStringHeader {
059
060   //-----------------------------------------------------------------------------------------------------------------
061   // Static
062   //-----------------------------------------------------------------------------------------------------------------
063
064   private static final long serialVersionUID = 1L;
065   private static final String NAME = "Proxy-Authorization";
066
067   /**
068    * Static creator.
069    *
070    * @param value
071    *    The header value.
072    *    <br>Can be <jk>null</jk>.
073    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
074    */
075   public static ProxyAuthorization of(String value) {
076      return value == null ? null : new ProxyAuthorization(value);
077   }
078
079   /**
080    * Static creator with delayed value.
081    *
082    * <p>
083    * Header value is re-evaluated on each call to {@link #getValue()}.
084    *
085    * @param value
086    *    The supplier of the header value.
087    *    <br>Can be <jk>null</jk>.
088    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
089    */
090   public static ProxyAuthorization of(Supplier<String> value) {
091      return value == null ? null : new ProxyAuthorization(value);
092   }
093
094   //-----------------------------------------------------------------------------------------------------------------
095   // Instance
096   //-----------------------------------------------------------------------------------------------------------------
097
098   /**
099    * Constructor.
100    *
101    * @param value
102    *    The header value.
103    *    <br>Can be <jk>null</jk>.
104    */
105   public ProxyAuthorization(String value) {
106      super(NAME, value);
107   }
108
109   /**
110    * Constructor with delayed value.
111    *
112    * <p>
113    * Header value is re-evaluated on each call to {@link #getValue()}.
114    *
115    * @param value
116    *    The supplier of the header value.
117    *    <br>Can be <jk>null</jk>.
118    */
119   public ProxyAuthorization(Supplier<String> value) {
120      super(NAME, value);
121   }
122}