michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIAuthPromptCallback; michael@0: interface nsIChannel; michael@0: interface nsICancelable; michael@0: interface nsIAuthInformation; michael@0: michael@0: /** michael@0: * An interface allowing to prompt for a username and password. This interface michael@0: * is usually acquired using getInterface on notification callbacks or similar. michael@0: * It can be used to prompt users for authentication information, either michael@0: * synchronously or asynchronously. michael@0: */ michael@0: [scriptable, uuid(651395EB-8612-4876-8AC0-A88D4DCE9E1E)] michael@0: interface nsIAuthPrompt2 : nsISupports michael@0: { michael@0: /** @name Security Levels */ michael@0: /* @{ */ michael@0: /** michael@0: * The password will be sent unencrypted. No security provided. michael@0: */ michael@0: const uint32_t LEVEL_NONE = 0; michael@0: /** michael@0: * Password will be sent encrypted, but the connection is otherwise michael@0: * insecure. michael@0: */ michael@0: const uint32_t LEVEL_PW_ENCRYPTED = 1; michael@0: /** michael@0: * The connection, both for password and data, is secure. michael@0: */ michael@0: const uint32_t LEVEL_SECURE = 2; michael@0: /* @} */ michael@0: michael@0: /** michael@0: * Requests a username and a password. Implementations will commonly show a michael@0: * dialog with a username and password field, depending on flags also a michael@0: * domain field. michael@0: * michael@0: * @param aChannel michael@0: * The channel that requires authentication. michael@0: * @param level michael@0: * One of the level constants from above. See there for descriptions michael@0: * of the levels. michael@0: * @param authInfo michael@0: * Authentication information object. The implementation should fill in michael@0: * this object with the information entered by the user before michael@0: * returning. michael@0: * michael@0: * @retval true michael@0: * Authentication can proceed using the values in the authInfo michael@0: * object. michael@0: * @retval false michael@0: * Authentication should be cancelled, usually because the user did michael@0: * not provide username/password. michael@0: * michael@0: * @note Exceptions thrown from this function will be treated like a michael@0: * return value of false. michael@0: */ michael@0: boolean promptAuth(in nsIChannel aChannel, michael@0: in uint32_t level, michael@0: in nsIAuthInformation authInfo); michael@0: michael@0: /** michael@0: * Asynchronously prompt the user for a username and password. michael@0: * This has largely the same semantics as promptUsernameAndPassword(), michael@0: * but must return immediately after calling and return the entered michael@0: * data in a callback. michael@0: * michael@0: * If the user closes the dialog using a cancel button or similar, michael@0: * the callback's nsIAuthPromptCallback::onAuthCancelled method must be michael@0: * called. michael@0: * Calling nsICancelable::cancel on the returned object SHOULD close the michael@0: * dialog and MUST call nsIAuthPromptCallback::onAuthCancelled on the provided michael@0: * callback. michael@0: * michael@0: * This implementation may: michael@0: * michael@0: * 1) Coalesce identical prompts. This means prompts that are guaranteed to michael@0: * want the same auth information from the user. A single prompt will be michael@0: * shown; then the callbacks for all the coalesced prompts will be notified michael@0: * with the resulting auth information. michael@0: * 2) Serialize prompts that are all in the same "context" (this might mean michael@0: * application-wide, for a given window, or something else depending on michael@0: * the user interface) so that the user is not deluged with prompts. michael@0: * michael@0: * @throw michael@0: * This method may throw any exception when the prompt fails to queue e.g michael@0: * because of out-of-memory error. It must not throw when the prompt michael@0: * could already be potentially shown to the user. In that case information michael@0: * about the failure has to come through the callback. This way we michael@0: * prevent multiple dialogs shown to the user because consumer may fall michael@0: * back to synchronous prompt on synchronous failure of this method. michael@0: */ michael@0: nsICancelable asyncPromptAuth(in nsIChannel aChannel, michael@0: in nsIAuthPromptCallback aCallback, michael@0: in nsISupports aContext, michael@0: in uint32_t level, michael@0: in nsIAuthInformation authInfo); michael@0: };