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 private static final long serialVersionUID = 1L; 060 private static final String NAME = "WWW-Authenticate"; 061 062 /** 063 * Static creator. 064 * 065 * @param value 066 * The header value. 067 * <br>Can be <jk>null</jk>. 068 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 069 */ 070 public static WwwAuthenticate of(String value) { 071 return value == null ? null : new WwwAuthenticate(value); 072 } 073 074 /** 075 * Static creator with delayed value. 076 * 077 * <p> 078 * Header value is re-evaluated on each call to {@link #getValue()}. 079 * 080 * @param value 081 * The supplier of the header value. 082 * <br>Can be <jk>null</jk>. 083 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 084 */ 085 public static WwwAuthenticate of(Supplier<String> value) { 086 return value == null ? null : new WwwAuthenticate(value); 087 } 088 089 /** 090 * Constructor. 091 * 092 * @param value 093 * The header value. 094 * <br>Can be <jk>null</jk>. 095 */ 096 public WwwAuthenticate(String value) { 097 super(NAME, value); 098 } 099 100 /** 101 * Constructor with delayed value. 102 * 103 * <p> 104 * Header value is re-evaluated on each call to {@link #getValue()}. 105 * 106 * @param value 107 * The supplier of the header value. 108 * <br>Can be <jk>null</jk>. 109 */ 110 public WwwAuthenticate(Supplier<String> value) { 111 super(NAME, value); 112 } 113}