Necko:nsIAuthPrompt2: Difference between revisions

Jump to navigation Jump to search
authinformation object
(killing savePassword, seems essentially unused)
(authinformation object)
Line 14: Line 14:
This suggestion is based on https://bugzilla.mozilla.org/attachment.cgi?id=163161 but slightly modified, and async calls added.
This suggestion is based on https://bugzilla.mozilla.org/attachment.cgi?id=163161 but slightly modified, and async calls added.


  interface nsIAuthPromptCallback : nsISupports {
  /**
  /**
* A object that hold authentication information. The caller of
    * Authentication information is available.
* promptUsernameAndPassword or promptPasswordAsync provides an object
    *
* implementing this interface; the prompt implementation can then read the
    * @param aContext
* values here to prefill the dialog. After the user entered the authentication
    *       The context as passed to promptPasswordAsync
* information, it should set the attributes of this object to indicate to the
    * @param user
* caller what was entered by the user.
    *       The username the user entered (or, if ONLY_PASSWORD was set,
*/
    *        that was passed to the nsIAuthPrompt2)
[scriptable, uuid(0d73639c-2a92-4518-9f92-28f71fea5f20)]
    * @param password
interface nsIAuthInformation : nsISupports
    *        The password the user entered.
{
    * @param domain
  /** @name Flags */
    *       The domain name the user entered, if NEED_DOMAIN was set.
  /* @{ */
    * @param flags
  /**
    *       Flags as passed to promptPasswordAsync
  * This dialog belongs to a network host.
    *
  */
    * @note  Any exceptions thrown from this method should be ignored.
  const PRUint32 AUTH_HOST = 1;
    */
  void onAuthAvailable(in nsISupports aContext,
                        in AString user,
                        in AString password,
                        in AString domain,
                        in unsigned long flags);


   /**
  /**
    * Notification that the prompt was cancelled.
  * This dialog belongs to a proxy.
    * @param userCancel
   */
    *       If false, this prompt was cancelled by calling the
  const PRUint32 AUTH_PROXY = 2;
    *       the cancel method on the nsICancelable; otherwise,
 
    *       it was cancelled by the user.
  /**
    */
  * This dialog needs domain information. The user interface should show a
   void onAuthCancelled(in nsISupports aContext,
  * domain field, prefilled with the domain attribute's value.
                        in boolean userCancel);
  */
  const PRUint32 NEED_DOMAIN = 4;
 
  /**
  * This dialog only asks for password information. The implementation SHOULD
  * NOT show a username field. It MUST NOT modify the user attribute,
  * although it should show its initial value to the user in some form. For
  * example, a paragraph in the dialog might say "Please enter your password
  * for user jsmith at server intranet".
  *
  * This flag is mutually exclusive with NEED_DOMAIN.
  */
  const PRUint32 ONLY_PASSWORD = 8;
  /* @} */
 
  /**
  * Flags describing this dialog. A bitwise OR of the flag values
  * above.
  *
  * It is possible that neither AUTH_HOST nor AUTH_PROXY are set.
  *
  * Implementations should ignore flags they don't understand; especially, they
  * should not throw an exception because of an unsupported flag.
  */
  readonly attribute unsigned long flags;
 
  /**
  * The initial value should be used to prefill the dialog.
  * Implementations should not show the password in clear.
  * On return, this parameter should contain the username entered by
  * the user.
  */
  attribute AString userName;
 
  /**
  * The initial value should be used to prefill the dialog or show it
  * in some other way to the user.
  * On return, this parameter should contain the username entered by
  * the user.
  */
  attribute AString password;
 
  /**
  * The initial value should be used to prefill the dialog or show it
   * in some other way to the user.
  * On return, this parameter should contain the domain entered by
  * the user.
  * This attribute is only used if flags include AUTH_DOMAIN.
  */
  attribute AString domain;
  };
  };


[scriptable, uuid(bdc387d7-2d29-4cac-92f1-dd75d786631d)]
interface nsIAuthPromptCallback : nsISupports
{
  /**
  * Authentication information is available.
  *
  * @param aContext
  *        The context as passed to promptPasswordAsync
  * @param aAuthInfo
  *        Authentication information. Must be the same object that was passed
  *        to promptPasswordAsync.
  *
  * @note  Any exceptions thrown from this method should be ignored.
  */
  void onAuthAvailable(in nsISupports aContext,
                      in nsIAuthInformation aAuthInfo);
  /**
  * Notification that the prompt was cancelled.
  *
  * @param aContext
  *        The context that was passed to promptPasswordAsync.
  * @param userCancel
  *        If false, this prompt was cancelled by calling the
  *        the cancel method on the nsICancelable; otherwise,
  *        it was cancelled by the user.
  */
  void onAuthCancelled(in nsISupports aContext, in boolean userCancel);
};
/**
* An interface allowing to prompt for a username and password. This interface
* is usually acquired using getInterface on notification callbacks or similar.
* It can be used to prompt users for authentication information, either
* synchronously or asynchronously.
*/
[scriptable, uuid(447fc780-1d28-412a-91a1-466d48129c65)]
  interface nsIAuthPrompt2 : nsISupports
  interface nsIAuthPrompt2 : nsISupports
  {         
  {         
    /** @name Security Levels */
  /** @name Security Levels */
    /* @{ */
  /* @{ */
    /**
  /**
    * The password will be sent unencrypted. No security provided.
  * The password will be sent unencrypted. No security provided.
    */
  */
    const PRUint32 LEVEL_NONE = 0;
  const PRUint32 LEVEL_NONE = 0;
    /**
  /**
    * Password will be sent encrypted, but the connection is otherwise
  * Password will be sent encrypted, but the connection is otherwise
    * insecure.
  * insecure.
    */
  */
    const PRUint32 LEVEL_PW_ENCRYPTED = 1;
  const PRUint32 LEVEL_PW_ENCRYPTED = 1;
    /**
  /**
    * The connection, both for password and data, is secure.
  * The connection, both for password and data, is secure.
    */
  */
    const PRUint32 LEVEL_SECURE = 2;
  const PRUint32 LEVEL_SECURE = 2;
    /* @} */
  /* @} */


    /** @name Flags */
  /**
    /* @{ */
  * Requests a username and a password. Implementations will commonly show a
    /**
  * dialog with a username and password field, depending on flags also a
    * This dialog belongs to a network host.
  * domain field.
    */
  *
    const PRUint32 AUTH_HOST = 0;
  * @param aChannel
    /**
  *        The channel that requires authentication.
    * This dialog belongs to a proxy.
  * @param passwordRealm
    */
  *        The server-supplied realm for the password. This is a
    const PRUint32 AUTH_PROXY = 1;
  *        human-readable string like "Secret files".
  * @param level
  *        One of the level constants from above. See there for descriptions
  *       of the levels.
  * @param authInfo
  *        Authentication information object. The implementation should fill in
  *        this object with the information entered by the user before
  *        returning.
  *
  * @retval true
  *         Authentication can proceed using the values in the authInfo
  *         object.
  * @retval false
  *        Authentication should be cancelled, usually because the user did
  *        not provide username/password.
  *
  * @note  Exceptions thrown from this function will be treated like a
  *         return value of false.
  */
  boolean promptUsernameAndPassword(in nsIChannel aChannel,
                                    in AString passwordRealm,
                                    in PRUint32 level,
                                    in nsIAuthInformation authInfo);


    /**
  /**
    * This dialog needs domain information. The user interface should show a
  * Asynchronously prompt the user for a username and password.
    * domain field, prefilled with the aDomain paramter's value.
  * This has largely the same semantics as promptUsernameAndPassword,
    */
  * but must return immediately after calling and return the entered
    const PRUint32 NEED_DOMAIN = 2;
  * data in a callback.
 
  *
    /**
  * If the user closes the dialog using a cancel button or similar,
    * This dialog only asks for password information. The implementation SHOULD
  * the callback's onAuthCancelled method must be called.
    * NOT show a username field. It MUST NOT modify the user inout parameter,
  * Calling cancel on the returned object SHOULD close the dialog
    * although it should show its initial value to the user in some form. For
  * and MUST call onAuthCancelled on the provided callback.
    * example, a paragraph in the dialog might say "Please enter your password
  *
    * for user jsmith at server intranet".
  * @throw NS_ERROR_NOT_IMPLEMENTED
    *
  *       Asynchronous authentication prompts are not supported;
    * This flag is mutually exclusive with NEED_DOMAIN.
  *       the caller should fall back to promptUsernameAndPassword
    */
  */
    const PRUint32 ONLY_PASSWORD = 4;
  nsICancelable promptPasswordAsync(in nsIChannel aChannel,
    /* @} */
                                    in nsIAuthPromptCallback aCallback,
                                    in nsISupports aContext,
                                    in AString passwordRealm,
                                    in PRUint32 level,
                                    in nsIAuthInformation authInfo);
};


    /**
    * Requests a username and a password. Implementations will commonly show a
    * dialog with a username and password field, depending on flags also a
    * domain field.
    *
    * @param aChannel
    *        The channel that requires authentication.
    * @param passwordRealm
    *        The server-supplied realm for the password. This is a
    *        human-readable string like "Secret files".
    * @param level
    *        One of the level constants from above. See there for descriptions
    *        of the levels.
    * @param flags
    *        Flags describing this dialog. A bitwise OR of the flag values
    *        above.
    * @param user
    *        The initial value should be used to prefill the dialog.
    *        Implementations should not show the password in clear.
    *        On return, this parameter should contain the username entered by
    *        the user.
    * @param pwd
    *        The initial value should be used to prefill the dialog or show it
    *        in some other way to the user.
    *        On return, this parameter should contain the username entered by
    *        the user.
    * @param domain
    *        The initial value should be used to prefill the dialog or show it
    *        in some other way to the user.
    *        On return, this parameter should contain the domain entered by
    *        the user.
    *        This parameter is only used if flags include AUTH_DOMAIN.
    *
    * @retval true
    *        Authentication can proceed using the values of the out
    *        parameters.
    * @retval false
    *        Authentication should be cancelled, usually because the user did
    *        not provide username/password.
    *
    * @note  Exceptions thrown from this function will be treated like a
    *        return value of false.
    */
    boolean promptUsernameAndPassword(in nsIChannel aChannel,
                                      in AString passwordRealm,
                                      in PRUint32 level,
                                      in PRUint32 flags,
                                      inout AString user,
                                      inout AString pwd,
                                      inout AString domain);


    /**
    * Asynchronously prompt the user for a username and password.
    * This has largely the same semantics as promptUsernameAndPassword,
    * but must return immediately after calling and return the entered
    * data in a callback.
    *
    * If the user closes the dialog using a cancel button or similar,
    * the callback's onAuthCancelled method must be called.
    * Calling cancel on the returned object SHOULD close the dialog
    * and MUST call onAuthCancelled on the provided callback.
    *
    * @throw NS_ERROR_NOT_IMPLEMENTED
    *        Asynchronous authentication prompts are not supported;
    *        the caller should fall back to promptUsernameAndPassword
    */
    nsICancelable promptPasswordAsync(in nsIChannel aChannel,
                                      in nsIAuthPromptCallback aCallback,
                                      in nsISupports aContext,
                                      in PRUint32 level,
                                      in PRUint32 flags,
                                      in AString user,
                                      in AString pwd,
                                      in AString domain);
};


== Issues ==
== Issues ==
Line 182: Line 214:
* The parameter lists are quite long; group some of the info together on an object? This object could be passed to both functions.
* The parameter lists are quite long; group some of the info together on an object? This object could be passed to both functions.
** It would fix this error: ../../../../../mozilla/netwerk/base/public/nsIAuthPrompt2.idl:106: Error: [domstring], [utf8string], [cstring], [astring] types cannot be used as inout parameters
** It would fix this error: ../../../../../mozilla/netwerk/base/public/nsIAuthPrompt2.idl:106: Error: [domstring], [utf8string], [cstring], [astring] types cannot be used as inout parameters
** switched to that in the interfaces above
Confirmed users
195

edits

Navigation menu