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.header; 018 019import java.util.function.*; 020 021import org.apache.juneau.http.annotation.*; 022 023/** 024 * Represents a parsed <l>WWW-Authenticate </l> HTTP response header. 025 * 026 * <p> 027 * Indicates the authentication scheme that should be used to access the requested entity. 028 * 029 * <h5 class='figure'>Example</h5> 030 * <p class='bcode'> 031 * WWW-Authenticate: Basic 032 * </p> 033 * 034 * <h5 class='topic'>RFC2616 Specification</h5> 035 * 036 * The WWW-Authenticate response-header field MUST be included in 401 (Unauthorized) response messages. 037 * The field value consists of at least one challenge that indicates the authentication scheme(s) and parameters 038 * applicable to the Request-URI. 039 * 040 * <p class='bcode'> 041 * WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge 042 * </p> 043 * 044 * <p> 045 * The HTTP access authentication process is described in "HTTP Authentication: Basic and Digest Access Authentication". 046 * User agents are advised to take special care in parsing the WWW-Authenticate field value as it might contain more 047 * than one challenge, or if more than one WWW-Authenticate header field is provided, the contents of a challenge 048 * itself can contain a comma-separated list of authentication parameters. 049 * 050 * <h5 class='section'>See Also:</h5><ul> 051 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</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("WWW-Authenticate") 058public class WwwAuthenticate extends BasicStringHeader { 059 060 //----------------------------------------------------------------------------------------------------------------- 061 // Static 062 //----------------------------------------------------------------------------------------------------------------- 063 064 private static final long serialVersionUID = 1L; 065 private static final String NAME = "WWW-Authenticate"; 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 WwwAuthenticate of(String value) { 076 return value == null ? null : new WwwAuthenticate(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 WwwAuthenticate of(Supplier<String> value) { 091 return value == null ? null : new WwwAuthenticate(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 WwwAuthenticate(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 WwwAuthenticate(Supplier<String> value) { 120 super(NAME, value); 121 } 122}