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>WWW-Authenticate </l> HTTP response header. 021 * 022 * <p> 023 * Indicates the authentication scheme that should be used to access the requested entity. 024 * 025 * <h5 class='figure'>Example</h5> 026 * <p class='bcode w800'> 027 * WWW-Authenticate: Basic 028 * </p> 029 * 030 * <h5 class='topic'>RFC2616 Specification</h5> 031 * 032 * The WWW-Authenticate response-header field MUST be included in 401 (Unauthorized) response messages. 033 * The field value consists of at least one challenge that indicates the authentication scheme(s) and parameters 034 * applicable to the Request-URI. 035 * 036 * <p class='bcode w800'> 037 * WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge 038 * </p> 039 * 040 * <p> 041 * The HTTP access authentication process is described in "HTTP Authentication: Basic and Digest Access Authentication". 042 * User agents are advised to take special care in parsing the WWW-Authenticate field value as it might contain more 043 * than one challenge, or if more than one WWW-Authenticate header field is provided, the contents of a challenge 044 * itself can contain a comma-separated list of authentication parameters. 045 * 046 * <ul class='seealso'> 047 * <li class='extlink'>{@doc ExtRFC2616} 048 * </ul> 049 */ 050@Header("WWW-Authenticate") 051public class WwwAuthenticate extends BasicStringHeader { 052 053 private static final long serialVersionUID = 1L; 054 055 /** 056 * Convenience creator. 057 * 058 * @param value 059 * The header value. 060 * <br>Can be any of the following: 061 * <ul> 062 * <li>{@link String} 063 * <li>Anything else - Converted to <c>String</c> then parsed. 064 * </ul> 065 * @return A new {@link WwwAuthenticate} object. 066 */ 067 public static WwwAuthenticate of(Object value) { 068 if (value == null) 069 return null; 070 return new WwwAuthenticate(value); 071 } 072 073 /** 074 * Convenience creator using supplier. 075 * 076 * <p> 077 * Header value is re-evaluated on each call to {@link #getValue()}. 078 * 079 * @param value 080 * The header value supplier. 081 * <br>Can be any of the following: 082 * <ul> 083 * <li>{@link String} 084 * <li>Anything else - Converted to <c>String</c> then parsed. 085 * </ul> 086 * @return A new {@link WwwAuthenticate} object. 087 */ 088 public static WwwAuthenticate of(Supplier<?> value) { 089 if (value == null) 090 return null; 091 return new WwwAuthenticate(value); 092 } 093 094 /** 095 * Constructor. 096 * 097 * @param value 098 * The header value. 099 * <br>Can be any of the following: 100 * <ul> 101 * <li>{@link String} 102 * <li>Anything else - Converted to <c>String</c> then parsed. 103 * <li>A {@link Supplier} of anything on this list. 104 * </ul> 105 */ 106 public WwwAuthenticate(Object value) { 107 super("WWW-Authenticate", value); 108 } 109 110 /** 111 * Constructor 112 * 113 * @param value 114 * The header value. 115 */ 116 public WwwAuthenticate(String value) { 117 this((Object)value); 118 } 119}