mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1352576 - Removed all instances of NPN_GetAuthenticationInfo from the codebase r=bsmedberg
NPN_GetAuthenticationInfo is an NPAPI API we implemented for Java and since we only support Flash we no longer need it. MozReview-Commit-ID: HxNn91QeaMB --HG-- extra : rebase_source : 016320ce93bde525dbf1b74f50f8b60d141d31cd
This commit is contained in:
parent
415ebfe75e
commit
b4261cfb61
@ -163,7 +163,7 @@ static NPNetscapeFuncs sBrowserFuncs = {
|
||||
_construct,
|
||||
_getvalueforurl,
|
||||
_setvalueforurl,
|
||||
_getauthenticationinfo,
|
||||
nullptr, //NPN GetAuthenticationInfo, not supported
|
||||
_scheduletimer,
|
||||
_unscheduletimer,
|
||||
_popupcontextmenu,
|
||||
@ -2486,70 +2486,6 @@ _setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
NPError
|
||||
_getauthenticationinfo(NPP instance, const char *protocol, const char *host,
|
||||
int32_t port, const char *scheme, const char *realm,
|
||||
char **username, uint32_t *ulen, char **password,
|
||||
uint32_t *plen)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getauthenticationinfo called from the wrong thread\n"));
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if (!instance || !protocol || !host || !scheme || !realm || !username ||
|
||||
!ulen || !password || !plen)
|
||||
return NPERR_INVALID_PARAM;
|
||||
|
||||
*username = nullptr;
|
||||
*password = nullptr;
|
||||
*ulen = 0;
|
||||
*plen = 0;
|
||||
|
||||
nsDependentCString proto(protocol);
|
||||
|
||||
if (!proto.LowerCaseEqualsLiteral("http") &&
|
||||
!proto.LowerCaseEqualsLiteral("https"))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsCOMPtr<nsIHttpAuthManager> authManager =
|
||||
do_GetService("@mozilla.org/network/http-auth-manager;1");
|
||||
if (!authManager)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
||||
if (!inst)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
bool authPrivate = false;
|
||||
if (NS_FAILED(inst->IsPrivateBrowsing(&authPrivate)))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
nsIDocument *doc = GetDocumentFromNPP(instance);
|
||||
NS_ENSURE_TRUE(doc, NPERR_GENERIC_ERROR);
|
||||
nsIPrincipal *principal = doc->NodePrincipal();
|
||||
|
||||
nsAutoString unused, uname16, pwd16;
|
||||
if (NS_FAILED(authManager->GetAuthIdentity(proto, nsDependentCString(host),
|
||||
port, nsDependentCString(scheme),
|
||||
nsDependentCString(realm),
|
||||
EmptyCString(), unused, uname16,
|
||||
pwd16, authPrivate, principal))) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 uname8(uname16);
|
||||
NS_ConvertUTF16toUTF8 pwd8(pwd16);
|
||||
|
||||
*username = ToNewCString(uname8);
|
||||
*ulen = *username ? uname8.Length() : 0;
|
||||
|
||||
*password = ToNewCString(pwd8);
|
||||
*plen = *password ? pwd8.Length() : 0;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_scheduletimer(NPP instance, uint32_t interval, NPBool repeat, PluginTimerFunc timerFunc)
|
||||
{
|
||||
|
@ -233,12 +233,6 @@ NPError
|
||||
_setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
||||
const char *value, uint32_t len);
|
||||
|
||||
NPError
|
||||
_getauthenticationinfo(NPP instance, const char *protocol, const char *host,
|
||||
int32_t port, const char *scheme, const char *realm,
|
||||
char **username, uint32_t *ulen, char **password,
|
||||
uint32_t *plen);
|
||||
|
||||
typedef void(*PluginTimerFunc)(NPP npp, uint32_t timerID);
|
||||
|
||||
uint32_t
|
||||
|
@ -247,11 +247,6 @@ parent:
|
||||
nsCString value)
|
||||
returns (NPError result);
|
||||
|
||||
intr NPN_GetAuthenticationInfo(nsCString protocol_, nsCString host,
|
||||
int32_t port, nsCString scheme,
|
||||
nsCString realm)
|
||||
returns (nsCString username, nsCString password, NPError result);
|
||||
|
||||
intr NPN_ConvertPoint(double sourceX, bool ignoreDestX, double sourceY, bool ignoreDestY, NPCoordinateSpace sourceSpace,
|
||||
NPCoordinateSpace destSpace)
|
||||
returns (double destX, double destY, bool result);
|
||||
|
@ -2011,32 +2011,6 @@ PluginInstanceParent::AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
PluginInstanceParent::AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
|
||||
const nsCString& host,
|
||||
const int32_t& port,
|
||||
const nsCString& scheme,
|
||||
const nsCString& realm,
|
||||
nsCString* username,
|
||||
nsCString* password,
|
||||
NPError* result)
|
||||
{
|
||||
char* u;
|
||||
uint32_t ulen;
|
||||
char* p;
|
||||
uint32_t plen;
|
||||
|
||||
*result = mNPNIface->getauthenticationinfo(mNPP, protocol.get(),
|
||||
host.get(), port,
|
||||
scheme.get(), realm.get(),
|
||||
&u, &ulen, &p, &plen);
|
||||
if (NPERR_NO_ERROR == *result) {
|
||||
username->Adopt(u, ulen);
|
||||
password->Adopt(p, plen);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
PluginInstanceParent::AnswerNPN_ConvertPoint(const double& sourceX,
|
||||
const bool& ignoreDestX,
|
||||
|
@ -227,16 +227,6 @@ public:
|
||||
const nsCString& url,
|
||||
const nsCString& value, NPError* result) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
|
||||
const nsCString& host,
|
||||
const int32_t& port,
|
||||
const nsCString& scheme,
|
||||
const nsCString& realm,
|
||||
nsCString* username,
|
||||
nsCString* password,
|
||||
NPError* result) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
AnswerNPN_ConvertPoint(const double& sourceX,
|
||||
const bool& ignoreDestX,
|
||||
|
@ -923,13 +923,6 @@ static NPError
|
||||
_setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
||||
const char *value, uint32_t len);
|
||||
|
||||
static NPError
|
||||
_getauthenticationinfo(NPP npp, const char *protocol,
|
||||
const char *host, int32_t port,
|
||||
const char *scheme, const char *realm,
|
||||
char **username, uint32_t *ulen,
|
||||
char **password, uint32_t *plen);
|
||||
|
||||
static uint32_t
|
||||
_scheduletimer(NPP instance, uint32_t interval, NPBool repeat,
|
||||
void (*timerFunc)(NPP npp, uint32_t timerID));
|
||||
@ -1013,7 +1006,7 @@ const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
|
||||
mozilla::plugins::child::_construct,
|
||||
mozilla::plugins::child::_getvalueforurl,
|
||||
mozilla::plugins::child::_setvalueforurl,
|
||||
mozilla::plugins::child::_getauthenticationinfo,
|
||||
nullptr, //NPN GetAuthenticationInfo, not supported
|
||||
mozilla::plugins::child::_scheduletimer,
|
||||
mozilla::plugins::child::_unscheduletimer,
|
||||
mozilla::plugins::child::_popupcontextmenu,
|
||||
@ -1646,38 +1639,6 @@ _setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
||||
return NPERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
NPError
|
||||
_getauthenticationinfo(NPP npp, const char *protocol,
|
||||
const char *host, int32_t port,
|
||||
const char *scheme, const char *realm,
|
||||
char **username, uint32_t *ulen,
|
||||
char **password, uint32_t *plen)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
if (!protocol || !host || !scheme || !realm || !username || !ulen ||
|
||||
!password || !plen)
|
||||
return NPERR_INVALID_PARAM;
|
||||
|
||||
nsCString u;
|
||||
nsCString p;
|
||||
NPError result;
|
||||
InstCast(npp)->
|
||||
CallNPN_GetAuthenticationInfo(nsDependentCString(protocol),
|
||||
nsDependentCString(host),
|
||||
port,
|
||||
nsDependentCString(scheme),
|
||||
nsDependentCString(realm),
|
||||
&u, &p, &result);
|
||||
if (NPERR_NO_ERROR == result) {
|
||||
*username = ToNewCString(u);
|
||||
*ulen = u.Length();
|
||||
*password = ToNewCString(p);
|
||||
*plen = p.Length();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_scheduletimer(NPP npp, uint32_t interval, NPBool repeat,
|
||||
|
@ -87,7 +87,6 @@ skip-if = !crashreporter || e10s
|
||||
[test_enumerate.html]
|
||||
[test_fullpage.html]
|
||||
[test_GCrace.html]
|
||||
[test_getauthenticationinfo.html]
|
||||
[test_hanging.html]
|
||||
skip-if = !crashreporter || e10s
|
||||
[test_hidden_plugin.html]
|
||||
|
@ -1,81 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Login Manager</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="plugin-utils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
Test for NPN_GetAuthenticationInfo
|
||||
<p id="display"></p>
|
||||
|
||||
<div id="content">
|
||||
<iframe id="iframe"></iframe>
|
||||
</div>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
const Ci = SpecialPowers.Ci;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
|
||||
function iframeLoad() {
|
||||
var plugin = iframe.contentDocument.getElementById("embedtest");
|
||||
// valid request
|
||||
is(plugin.getAuthInfo("http", "mochi.test", 8888, "basic", "testrealm"),
|
||||
"user1|password1",
|
||||
"correct user/pass retrieved");
|
||||
try {
|
||||
// invalid request -- wrong host
|
||||
is(plugin.getAuthInfo("http", "example.com", 8888, "basic", "testrealm"),
|
||||
"user1|password1",
|
||||
"correct user/pass retrieved");
|
||||
ok(false, "no exception was thrown");
|
||||
}
|
||||
catch (err) {
|
||||
ok(true, "expected exception caught");
|
||||
}
|
||||
try {
|
||||
// invalid request -- wrong port
|
||||
is(plugin.getAuthInfo("http", "mochi.test", 90, "basic", "testrealm"),
|
||||
"user1|password1",
|
||||
"correct user/pass retrieved");
|
||||
ok(false, "no exception was thrown");
|
||||
}
|
||||
catch (err) {
|
||||
ok(true, "expected exception caught");
|
||||
}
|
||||
try {
|
||||
// invalid request -- wrong realm
|
||||
is(plugin.getAuthInfo("http", "mochi.test", 8888, "basic", "wrongrealm"),
|
||||
"user1|password1",
|
||||
"correct user/pass retrieved");
|
||||
ok(false, "no exception was thrown");
|
||||
}
|
||||
catch (err) {
|
||||
ok(true, "expected exception caught");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
|
||||
// Authentication info is added twice here. In the non-e10s case, this does
|
||||
// nothing. In the e10s case, we need to add auth info in both the child process,
|
||||
// which the plugin checks for auth validity, and the parent process, which the
|
||||
// http network objects use.
|
||||
// TODO: Clean this up once HTTPAuthManager is made e10s compliant in bug 1249172
|
||||
var iframe = document.getElementById("iframe");
|
||||
var am = Cc["@mozilla.org/network/http-auth-manager;1"].
|
||||
getService(Ci.nsIHttpAuthManager);
|
||||
am.setAuthIdentity("http", "mochi.test", 8888, "basic", "testrealm", "",
|
||||
"mochi.test", "user1", "password1");
|
||||
SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("file_authident.js"));
|
||||
iframe.onload = iframeLoad;
|
||||
iframe.src = "http://mochi.test:8888/tests/toolkit/components/passwordmgr/" +
|
||||
"test/authenticate.sjs?user=user1&pass=password1&realm=testrealm&plugin=1";
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -140,7 +140,6 @@ static bool getObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argC
|
||||
static bool getJavaCodebase(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool checkObjectValue(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool enableFPExceptions(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool asyncCallbackTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool checkGCRace(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool hangPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
@ -214,7 +213,6 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"getJavaCodebase",
|
||||
"checkObjectValue",
|
||||
"enableFPExceptions",
|
||||
"getAuthInfo",
|
||||
"asyncCallbackTest",
|
||||
"checkGCRace",
|
||||
"hang",
|
||||
@ -289,7 +287,6 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
|
||||
getJavaCodebase,
|
||||
checkObjectValue,
|
||||
enableFPExceptions,
|
||||
getAuthInfo,
|
||||
asyncCallbackTest,
|
||||
checkGCRace,
|
||||
hangPlugin,
|
||||
@ -1982,20 +1979,6 @@ NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char *url, char
|
||||
return sBrowserFuncs->getvalueforurl(instance, variable, url, value, len);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetAuthenticationInfo(NPP instance,
|
||||
const char *protocol,
|
||||
const char *host, int32_t port,
|
||||
const char *scheme,
|
||||
const char *realm,
|
||||
char **username, uint32_t *ulen,
|
||||
char **password,
|
||||
uint32_t *plen)
|
||||
{
|
||||
return sBrowserFuncs->getauthenticationinfo(instance, protocol, host, port, scheme, realm,
|
||||
username, ulen, password, plen);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_PluginThreadAsyncCall(NPP plugin, void (*func)(void*), void* userdata)
|
||||
{
|
||||
@ -3012,58 +2995,6 @@ static bool enableFPExceptions(NPObject* npobj, const NPVariant* args, uint32_t
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (argCount != 5)
|
||||
return false;
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
|
||||
if (!NPVARIANT_IS_STRING(args[0]) || !NPVARIANT_IS_STRING(args[1]) ||
|
||||
!NPVARIANT_IS_INT32(args[2]) || !NPVARIANT_IS_STRING(args[3]) ||
|
||||
!NPVARIANT_IS_STRING(args[4]))
|
||||
return false;
|
||||
|
||||
const NPString* protocol = &NPVARIANT_TO_STRING(args[0]);
|
||||
const NPString* host = &NPVARIANT_TO_STRING(args[1]);
|
||||
uint32_t port = NPVARIANT_TO_INT32(args[2]);
|
||||
const NPString* scheme = &NPVARIANT_TO_STRING(args[3]);
|
||||
const NPString* realm = &NPVARIANT_TO_STRING(args[4]);
|
||||
|
||||
char* username = nullptr;
|
||||
char* password = nullptr;
|
||||
uint32_t ulen = 0, plen = 0;
|
||||
|
||||
NPError err = NPN_GetAuthenticationInfo(npp,
|
||||
protocol->UTF8Characters,
|
||||
host->UTF8Characters,
|
||||
port,
|
||||
scheme->UTF8Characters,
|
||||
realm->UTF8Characters,
|
||||
&username,
|
||||
&ulen,
|
||||
&password,
|
||||
&plen);
|
||||
|
||||
if (err != NPERR_NO_ERROR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* outstring = (char*)NPN_MemAlloc(ulen + plen + 2);
|
||||
memset(outstring, 0, ulen + plen + 2);
|
||||
strncpy(outstring, username, ulen);
|
||||
strcat(outstring, "|");
|
||||
strncat(outstring, password, plen);
|
||||
|
||||
STRINGZ_TO_NPVARIANT(outstring, *result);
|
||||
|
||||
NPN_MemFree(username);
|
||||
NPN_MemFree(password);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void timerCallback(NPP npp, uint32_t timerID)
|
||||
{
|
||||
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
||||
|
@ -734,8 +734,6 @@ description =
|
||||
description =
|
||||
[PPluginInstance::NPN_SetValueForURL]
|
||||
description =
|
||||
[PPluginInstance::NPN_GetAuthenticationInfo]
|
||||
description =
|
||||
[PPluginInstance::NPN_ConvertPoint]
|
||||
description =
|
||||
[PPluginInstance::GetCompositionString]
|
||||
|
Loading…
Reference in New Issue
Block a user