001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.http.classic.header;
018
019import java.util.function.*;
020
021import org.apache.juneau.http.*;
022
023/**
024 * Represents a parsed <l>Proxy-Authorization</l> HTTP request header.
025 *
026 * <p>
027 * Authorization credentials for connecting to a proxy.
028 *
029 * <h5 class='figure'>Example</h5>
030 * <p class='bcode'>
031 *    Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
032 * </p>
033 *
034 * <h5 class='topic'>RFC2616 Specification</h5>
035 *
036 * The Proxy-Authorization request-header field allows the client to identify itself (or its user) to a proxy which
037 * requires authentication.
038 * The Proxy-Authorization field value consists of credentials containing the authentication information of the user
039 * agent for the proxy and/or realm of the resource being requested.
040 *
041 * <p class='bcode'>
042 *    Proxy-Authorization     = "Proxy-Authorization" ":" credentials
043 * </p>
044 *
045 * <p>
046 * The HTTP access authentication process is described in "HTTP Authentication: Basic and Digest Access Authentication".
047 * Unlike Authorization, the Proxy-Authorization header field applies only to the next outbound proxy that demanded
048 * authentication using the Proxy-Authenticate field.
049 * When multiple proxies are used in a chain, the Proxy-Authorization header field is consumed by the first outbound
050 * proxy that was expecting to receive credentials.
051 * A proxy MAY relay the credentials from the client request to the next proxy if that is the mechanism by which the
052 * proxies cooperatively authenticate a given request.
053 *
054 * <h5 class='section'>See Also:</h5><ul>
055 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommon">juneau-rest-common</a>
056 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
057 * </ul>
058 *
059 * @serial exclude
060 */
061@Header("Proxy-Authorization")
062@SuppressWarnings({
063   "secrets:S8136" // HTTP Proxy-Authorization header parser, not a stored credential.
064})
065public class ProxyAuthorization extends BasicStringHeader {
066   private static final long serialVersionUID = 1L;
067   private static final String NAME = "Proxy-Authorization";
068
069   /**
070    * Static creator.
071    *
072    * @param value
073    *    The header value.
074    *    <br>Can be <jk>null</jk>.
075    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
076    */
077   public static ProxyAuthorization of(String value) {
078      return value == null ? null : new ProxyAuthorization(value);
079   }
080
081   /**
082    * Static creator with delayed value.
083    *
084    * <p>
085    * Header value is re-evaluated on each call to {@link #getValue()}.
086    *
087    * @param value
088    *    The supplier of the header value.
089    *    <br>Can be <jk>null</jk>.
090    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
091    */
092   public static ProxyAuthorization of(Supplier<String> value) {
093      return value == null ? null : new ProxyAuthorization(value);
094   }
095
096   /**
097    * Constructor.
098    *
099    * @param value
100    *    The header value.
101    *    <br>Can be <jk>null</jk> to create a header with no value.
102    */
103   public ProxyAuthorization(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> to create a header with no value.
116    */
117   public ProxyAuthorization(Supplier<String> value) {
118      super(NAME, value);
119   }
120}