1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/http/nsIHttpChannelAuthProvider.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et tw=80 : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsICancelable.idl" 1.11 + 1.12 +interface nsIHttpChannel; 1.13 +interface nsIHttpAuthenticableChannel; 1.14 + 1.15 +/** 1.16 + * nsIHttpChannelAuthProvider 1.17 + * 1.18 + * This interface is intended for providing authentication for http-style 1.19 + * channels, like nsIHttpChannel and nsIWebSocket, which implement the 1.20 + * nsIHttpAuthenticableChannel interface. 1.21 + * 1.22 + * When requesting pages AddAuthorizationHeaders MUST be called 1.23 + * in order to get the http cached headers credentials. When the request is 1.24 + * unsuccessful because of receiving either a 401 or 407 http response code 1.25 + * ProcessAuthentication MUST be called and the page MUST be requested again 1.26 + * with the new credentials that the user has provided. After a successful 1.27 + * request, checkForSuperfluousAuth MAY be called, and disconnect MUST be 1.28 + * called. 1.29 + */ 1.30 + 1.31 +[scriptable, uuid(c68f3def-c7c8-4ee8-861c-eef49a48b702)] 1.32 +interface nsIHttpChannelAuthProvider : nsICancelable 1.33 +{ 1.34 + /** 1.35 + * Initializes the http authentication support for the channel. 1.36 + * Implementations must hold a weak reference of the channel. 1.37 + */ 1.38 + void init(in nsIHttpAuthenticableChannel channel); 1.39 + 1.40 + /** 1.41 + * Upon receipt of a server challenge, this function is called to determine 1.42 + * the credentials to send. 1.43 + * 1.44 + * @param httpStatus 1.45 + * the http status received. 1.46 + * @param sslConnectFailed 1.47 + * if the last ssl tunnel connection attempt was or not successful. 1.48 + * @param callback 1.49 + * the callback to be called when it returns NS_ERROR_IN_PROGRESS. 1.50 + * The implementation must hold a weak reference. 1.51 + * 1.52 + * @returns NS_OK if the credentials were got and set successfully. 1.53 + * NS_ERROR_IN_PROGRESS if the credentials are going to be asked to 1.54 + * the user. The channel reference must be 1.55 + * alive until the feedback from 1.56 + * nsIHttpAuthenticableChannel's methods or 1.57 + * until disconnect be called. 1.58 + */ 1.59 + void processAuthentication(in unsigned long httpStatus, 1.60 + in boolean sslConnectFailed); 1.61 + 1.62 + /** 1.63 + * Add credentials from the http auth cache. 1.64 + */ 1.65 + void addAuthorizationHeaders(); 1.66 + 1.67 + /** 1.68 + * Check if an unnecessary(and maybe malicious) url authentication has been 1.69 + * provided. 1.70 + */ 1.71 + void checkForSuperfluousAuth(); 1.72 + 1.73 + /** 1.74 + * Cancel pending user auth prompts and release the callback and channel 1.75 + * weak references. 1.76 + */ 1.77 + void disconnect(in nsresult status); 1.78 +};