зеркало из https://github.com/mozilla/pjs.git
Bug 340949: saving insecure login confirmation, minor string review
This commit is contained in:
Родитель
e2f791fe98
Коммит
3ec7df67da
|
@ -44,7 +44,8 @@ accessingServerFailedError.text=Cannot access server %1$S!
|
||||||
mandatoryHttpsError.text=Server %1$S needs to support HTTPS!
|
mandatoryHttpsError.text=Server %1$S needs to support HTTPS!
|
||||||
|
|
||||||
# args: host
|
# args: host
|
||||||
noHttpsConfirmation.text=Insecure login on %1$S. Continue?
|
noHttpsConfirmation.text=Insecure login on %1$S! Server does not support HTTPS. Continue?
|
||||||
|
noHttpsConfirmation.check=Don't ask again.
|
||||||
noHttpsConfirmation.label=Warning!
|
noHttpsConfirmation.label=Warning!
|
||||||
|
|
||||||
# args: host
|
# args: host
|
||||||
|
@ -59,5 +60,6 @@ loginDialog.text=Server: %1$S (%2$S, v%3$S, WCAP v%4$S)
|
||||||
loginDialog.savePW.label=Save Password
|
loginDialog.savePW.label=Save Password
|
||||||
loginDialog.label=Sun Java System Calendar Server WCAP login
|
loginDialog.label=Sun Java System Calendar Server WCAP login
|
||||||
|
|
||||||
privateItem.title=Private/Confidential
|
privateItem.title=Private
|
||||||
|
confidentialItem.title=Confidential
|
||||||
busyItem.title=Busy
|
busyItem.title=Busy
|
||||||
|
|
|
@ -787,12 +787,17 @@ calWcapCalendar.prototype.parseItems = function(
|
||||||
excItems.push( item );
|
excItems.push( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.title == null &&
|
if (item.title == null) {
|
||||||
(item.privacy == "PRIVATE" ||
|
|
||||||
item.privacy == "CONFIDENTIAL")) {
|
|
||||||
// assumed to look at a subscribed calendar,
|
// assumed to look at a subscribed calendar,
|
||||||
// so patch title for private items:
|
// so patch title for private items:
|
||||||
item.title = g_privateItemTitle;
|
switch (item.privacy) {
|
||||||
|
case "PRIVATE":
|
||||||
|
item.title = g_privateItemTitle;
|
||||||
|
break;
|
||||||
|
case "CONFIDENTIAL":
|
||||||
|
item.title = g_confidentialItemTitle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -936,7 +941,7 @@ calWcapCalendar.prototype.getItems_resp = function(
|
||||||
var items = [];
|
var items = [];
|
||||||
for each ( var entry in entries ) {
|
for each ( var entry in entries ) {
|
||||||
var item = new CalEvent();
|
var item = new CalEvent();
|
||||||
item.id = (g_busyItemUuidPrefix +
|
item.id = (g_busyPhantomItemUuidPrefix +
|
||||||
entry.dtRangeStart.icalString);
|
entry.dtRangeStart.icalString);
|
||||||
item.calendar = this_.superCalendar;
|
item.calendar = this_.superCalendar;
|
||||||
item.title = g_busyItemTitle;
|
item.title = g_busyItemTitle;
|
||||||
|
|
|
@ -364,12 +364,14 @@ calWcapSession.prototype = {
|
||||||
if (!this_.m_bNoLoginsAnymore)
|
if (!this_.m_bNoLoginsAnymore)
|
||||||
this_.getSessionId_();
|
this_.getSessionId_();
|
||||||
|
|
||||||
this_.getSupportedTimezones(true /* refresh */);
|
if (this_.m_sessionId != null) {
|
||||||
this_.getServerTimeDiff(true /* refresh */);
|
this_.getSupportedTimezones(true /* refresh */);
|
||||||
// preread calprops for subscribed calendars:
|
this_.getServerTimeDiff(true /* refresh */);
|
||||||
var cals = this_.getSubscribedCalendars({});
|
// preread calprops for subscribed calendars:
|
||||||
for each ( cal in cals ) {
|
var cals = this_.getSubscribedCalendars({});
|
||||||
cal.getCalProps_(true /* async */);
|
for each ( cal in cals ) {
|
||||||
|
cal.getCalProps_(true /* async */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +423,7 @@ calWcapSession.prototype = {
|
||||||
else {
|
else {
|
||||||
// user has specified a specific port, but no https:
|
// user has specified a specific port, but no https:
|
||||||
// => leave it to her whether to connect...
|
// => leave it to her whether to connect...
|
||||||
if (!confirmUnsecureLogin( loginUri )) {
|
if (!confirmInsecureLogin( loginUri )) {
|
||||||
this.m_bNoLoginsAnymore = true;
|
this.m_bNoLoginsAnymore = true;
|
||||||
this.log( "user rejected unsecure login." );
|
this.log( "user rejected unsecure login." );
|
||||||
return null;
|
return null;
|
||||||
|
@ -468,7 +470,7 @@ calWcapSession.prototype = {
|
||||||
[loginUri.hostPort], 1 ) );
|
[loginUri.hostPort], 1 ) );
|
||||||
}
|
}
|
||||||
// http possible, ask for it:
|
// http possible, ask for it:
|
||||||
if (confirmUnsecureLogin( loginUri )) {
|
if (confirmInsecureLogin( loginUri )) {
|
||||||
if (outPW.value != null) {
|
if (outPW.value != null) {
|
||||||
// user/pw has been found previously,
|
// user/pw has been found previously,
|
||||||
// but no login was possible,
|
// but no login was possible,
|
||||||
|
@ -760,14 +762,7 @@ calWcapSession.prototype = {
|
||||||
this.m_sessionId = null;
|
this.m_sessionId = null;
|
||||||
}
|
}
|
||||||
this.m_userId = null;
|
this.m_userId = null;
|
||||||
// ask next time we log in:
|
|
||||||
this.m_bNoLoginsAnymore = false;
|
this.m_bNoLoginsAnymore = false;
|
||||||
if (this.uri != null) {
|
|
||||||
var this_ = this;
|
|
||||||
g_httpHosts = g_httpHosts.filter(
|
|
||||||
function(hostEntry) {
|
|
||||||
return (hostEntry.m_host != this_.uri.hostPort); } );
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getWcapErrorString:
|
getWcapErrorString:
|
||||||
|
@ -1032,23 +1027,47 @@ calWcapSession.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var g_httpHosts = [];
|
var g_confirmedHttpLogins = null;
|
||||||
function confirmUnsecureLogin( uri )
|
function confirmInsecureLogin( uri )
|
||||||
{
|
{
|
||||||
var host = uri.hostPort;
|
if (g_confirmedHttpLogins == null) {
|
||||||
for each ( var hostEntry in g_httpHosts ) {
|
g_confirmedHttpLogins = {};
|
||||||
if (hostEntry.m_host == host) {
|
var confirmedHttpLogins = getPref(
|
||||||
return hostEntry.m_bConfirmed;
|
"calendar.wcap.confirmedHttpLogins", "");
|
||||||
|
var tuples = confirmedHttpLogins.split(',');
|
||||||
|
for each ( var tuple in tuples ) {
|
||||||
|
var ar = tuple.split(':');
|
||||||
|
g_confirmedHttpLogins[ar[0]] = ar[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var host = uri.hostPort;
|
||||||
|
var encodedHost = encodeURIComponent(host);
|
||||||
|
var confirmedEntry = g_confirmedHttpLogins[encodedHost];
|
||||||
|
if (confirmedEntry)
|
||||||
|
return (confirmedEntry == "1" ? true : false);
|
||||||
|
|
||||||
var prompt = getWindowWatcher().getNewPrompter(null);
|
var prompt = getWindowWatcher().getNewPrompter(null);
|
||||||
var bundle = getWcapBundle();
|
var bundle = getWcapBundle();
|
||||||
var bConfirmed = prompt.confirm(
|
var dontAskAgain = { value: false };
|
||||||
|
var bConfirmed = prompt.confirmCheck(
|
||||||
bundle.GetStringFromName("noHttpsConfirmation.label"),
|
bundle.GetStringFromName("noHttpsConfirmation.label"),
|
||||||
bundle.formatStringFromName("noHttpsConfirmation.text", [host], 1) );
|
bundle.formatStringFromName("noHttpsConfirmation.text", [host], 1),
|
||||||
// save decision for all calendars:
|
bundle.GetStringFromName("noHttpsConfirmation.check"),
|
||||||
g_httpHosts.push(
|
dontAskAgain );
|
||||||
{ m_host: host, m_bConfirmed: bConfirmed } );
|
|
||||||
|
if (dontAskAgain.value) {
|
||||||
|
// save decision for all running calendars and all future confirmations:
|
||||||
|
var confirmedHttpLogins = getPref(
|
||||||
|
"calendar.wcap.confirmedHttpLogins", "");
|
||||||
|
if (confirmedHttpLogins.length > 0)
|
||||||
|
confirmedHttpLogins += ",";
|
||||||
|
confirmedEntry = (bConfirmed ? "1" : "0");
|
||||||
|
confirmedHttpLogins += (encodedHost + ":" + confirmedEntry);
|
||||||
|
setPref("calendar.wcap.confirmedHttpLogins", confirmedHttpLogins);
|
||||||
|
g_confirmedHttpLogins[encodedHost] = confirmedEntry;
|
||||||
|
}
|
||||||
|
|
||||||
return bConfirmed;
|
return bConfirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,10 +213,10 @@ function getDatetimeFromIcalProp( prop )
|
||||||
|
|
||||||
function getPref(prefName, defaultValue)
|
function getPref(prefName, defaultValue)
|
||||||
{
|
{
|
||||||
|
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
||||||
|
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
|
.getService(nsIPrefBranch);
|
||||||
try {
|
try {
|
||||||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
|
||||||
var prefBranch =Components.classes["@mozilla.org/preferences-service;1"]
|
|
||||||
.getService(nsIPrefBranch);
|
|
||||||
switch (prefBranch.getPrefType(prefName)) {
|
switch (prefBranch.getPrefType(prefName)) {
|
||||||
case nsIPrefBranch.PREF_BOOL:
|
case nsIPrefBranch.PREF_BOOL:
|
||||||
return prefBranch.getBoolPref(prefName);
|
return prefBranch.getBoolPref(prefName);
|
||||||
|
@ -233,6 +233,27 @@ function getPref(prefName, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPref(prefName, value)
|
||||||
|
{
|
||||||
|
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
||||||
|
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
|
.getService(nsIPrefBranch);
|
||||||
|
switch (typeof(value)) {
|
||||||
|
case "boolean":
|
||||||
|
prefBranch.setBoolPref(prefName, value);
|
||||||
|
break;
|
||||||
|
case "number":
|
||||||
|
prefBranch.setIntPref(prefName, value);
|
||||||
|
break;
|
||||||
|
case "string":
|
||||||
|
prefBranch.setCharPref(prefName, value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("unsupported pref value: " + typeof(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// init code for globals, prefs:
|
// init code for globals, prefs:
|
||||||
//
|
//
|
||||||
|
@ -327,6 +348,8 @@ catch (exc) {
|
||||||
|
|
||||||
// some string resources:
|
// some string resources:
|
||||||
var g_privateItemTitle = getWcapBundle().GetStringFromName("privateItem.title");
|
var g_privateItemTitle = getWcapBundle().GetStringFromName("privateItem.title");
|
||||||
|
var g_confidentialItemTitle = getWcapBundle().GetStringFromName(
|
||||||
|
"confidentialItem.title");
|
||||||
var g_busyItemTitle = getWcapBundle().GetStringFromName("busyItem.title");
|
var g_busyItemTitle = getWcapBundle().GetStringFromName("busyItem.title");
|
||||||
var g_busyItemUuidPrefix = ("uuid" + getTime().icalString);
|
var g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid" + getTime().icalString);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче