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; 014 015/** 016 * Represents a parsed <l>Authorization</l> HTTP request header. 017 * 018 * <p> 019 * Authentication credentials for HTTP authentication. 020 * 021 * <h5 class='figure'>Example</h5> 022 * <p class='bcode'> 023 * Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== 024 * </p> 025 * 026 * <h5 class='topic'>RFC2616 Specification</h5> 027 * 028 * A user agent that wishes to authenticate itself with a server--usually, but not necessarily, after receiving a 401 029 * response--does so by including an Authorization request-header field with the request. 030 * 031 * <p> 032 * The Authorization field value consists of credentials containing the authentication information of the user agent for 033 * the realm of the resource being requested. 034 * 035 * <p class='bcode'> 036 * Authorization = "Authorization" ":" credentials 037 * </p> 038 * 039 * <p> 040 * HTTP access authentication is described in "HTTP Authentication: Basic and Digest Access Authentication". 041 * 042 * <p> 043 * If a request is authenticated and a realm specified, the same credentials SHOULD be valid for all other requests 044 * within this realm (assuming that the authentication scheme itself does not require otherwise, such as credentials 045 * that vary according to a challenge value or using synchronized clocks). 046 * 047 * <p> 048 * When a shared cache (see section 13.7) receives a request containing an Authorization field, it MUST NOT return the 049 * corresponding response as a reply to any other request, unless one of the following specific exceptions holds: 050 * <ol> 051 * <li>If the response includes the "s-maxage" cache-control directive, the cache MAY use that response in replying 052 * to a subsequent request. 053 * But (if the specified maximum age has passed) a proxy cache MUST first revalidate it with the origin 054 * server, using the request-headers from the new request to allow the origin server to authenticate the new 055 * request. 056 * (This is the defined behavior for s-maxage.) 057 * If the response includes "s-maxage=0", the proxy MUST always revalidate it before re-using it. 058 * <li>If the response includes the "must-revalidate" cache-control directive, the cache MAY use that response in 059 * replying to a subsequent request. 060 * But if the response is stale, all caches MUST first revalidate it with the origin server, using the 061 * request-headers from the new request to allow the origin server to authenticate the new request. 062 * <li>If the response includes the "public" cache-control directive, it MAY be returned in reply to any subsequent 063 * request. 064 * </ol> 065 * 066 * <h5 class='section'>See Also:</h5> 067 * <ul class='doctree'> 068 * <li class='extlink'><a class='doclink' href='https://www.w3.org/Protocols/rfc2616/rfc2616.html'>Hypertext Transfer Protocol -- HTTP/1.1</a> 069 * </ul> 070 */ 071public final class Authorization extends HeaderString { 072 073 /** 074 * Returns a parsed <code>Authorization</code> header. 075 * 076 * @param value The <code>Authorization</code> header string. 077 * @return The parsed <code>Authorization</code> header, or <jk>null</jk> if the string was null. 078 */ 079 public static Authorization forString(String value) { 080 if (value == null) 081 return null; 082 return new Authorization(value); 083 } 084 085 private Authorization(String value) { 086 super(value); 087 } 088}