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 w800'> 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 w800'> 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 * <ul class='seealso'> 051 * <li class='extlink'>{@doc ExtRFC2616} 052 * </ul> 053 */ 054@Header("Proxy-Authorization") 055public class ProxyAuthorization extends BasicStringHeader { 056 057 private static final long serialVersionUID = 1L; 058 059 /** 060 * Convenience creator. 061 * 062 * @param value 063 * The header value. 064 * <br>Can be any of the following: 065 * <ul> 066 * <li>{@link String} 067 * <li>Anything else - Converted to <c>String</c> then parsed. 068 * </ul> 069 * @return A new {@link ProxyAuthorization} object. 070 */ 071 public static ProxyAuthorization of(Object value) { 072 if (value == null) 073 return null; 074 return new ProxyAuthorization(value); 075 } 076 077 /** 078 * Convenience creator using supplier. 079 * 080 * <p> 081 * Header value is re-evaluated on each call to {@link #getValue()}. 082 * 083 * @param value 084 * The header value supplier. 085 * <br>Can be any of the following: 086 * <ul> 087 * <li>{@link String} 088 * <li>Anything else - Converted to <c>String</c> then parsed. 089 * </ul> 090 * @return A new {@link ProxyAuthorization} object. 091 */ 092 public static ProxyAuthorization of(Supplier<?> value) { 093 if (value == null) 094 return null; 095 return new ProxyAuthorization(value); 096 } 097 098 /** 099 * Constructor. 100 * 101 * @param value 102 * The header value. 103 * <br>Can be any of the following: 104 * <ul> 105 * <li>{@link String} 106 * <li>Anything else - Converted to <c>String</c> then parsed. 107 * <li>A {@link Supplier} of anything on this list. 108 * </ul> 109 */ 110 public ProxyAuthorization(Object value) { 111 super("Proxy-Authorization", value); 112 } 113 114 /** 115 * Constructor 116 * 117 * @param value 118 * The header value. 119 */ 120 public ProxyAuthorization(String value) { 121 this((Object)value); 122 } 123}