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