Bug 340949: saving insecure login confirmation, minor string review

This commit is contained in:
daniel.boelzle%sun.com 2006-08-04 10:27:13 +00:00
Родитель e2f791fe98
Коммит 3ec7df67da
4 изменённых файлов: 86 добавлений и 37 удалений

Просмотреть файл

@ -44,7 +44,8 @@ accessingServerFailedError.text=Cannot access server %1$S!
mandatoryHttpsError.text=Server %1$S needs to support HTTPS!
# 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!
# 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.label=Sun Java System Calendar Server WCAP login
privateItem.title=Private/Confidential
privateItem.title=Private
confidentialItem.title=Confidential
busyItem.title=Busy

Просмотреть файл

@ -787,12 +787,17 @@ calWcapCalendar.prototype.parseItems = function(
excItems.push( item );
}
if (item.title == null &&
(item.privacy == "PRIVATE" ||
item.privacy == "CONFIDENTIAL")) {
if (item.title == null) {
// assumed to look at a subscribed calendar,
// so patch title for private items:
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 = [];
for each ( var entry in entries ) {
var item = new CalEvent();
item.id = (g_busyItemUuidPrefix +
item.id = (g_busyPhantomItemUuidPrefix +
entry.dtRangeStart.icalString);
item.calendar = this_.superCalendar;
item.title = g_busyItemTitle;

Просмотреть файл

@ -364,6 +364,7 @@ calWcapSession.prototype = {
if (!this_.m_bNoLoginsAnymore)
this_.getSessionId_();
if (this_.m_sessionId != null) {
this_.getSupportedTimezones(true /* refresh */);
this_.getServerTimeDiff(true /* refresh */);
// preread calprops for subscribed calendars:
@ -373,6 +374,7 @@ calWcapSession.prototype = {
}
}
}
}
},
Components.interfaces.nsIProxyObjectManager.INVOKE_SYNC );
// xxx todo: are rc/exceptions forwarded to current thread?
@ -421,7 +423,7 @@ calWcapSession.prototype = {
else {
// user has specified a specific port, but no https:
// => leave it to her whether to connect...
if (!confirmUnsecureLogin( loginUri )) {
if (!confirmInsecureLogin( loginUri )) {
this.m_bNoLoginsAnymore = true;
this.log( "user rejected unsecure login." );
return null;
@ -468,7 +470,7 @@ calWcapSession.prototype = {
[loginUri.hostPort], 1 ) );
}
// http possible, ask for it:
if (confirmUnsecureLogin( loginUri )) {
if (confirmInsecureLogin( loginUri )) {
if (outPW.value != null) {
// user/pw has been found previously,
// but no login was possible,
@ -760,14 +762,7 @@ calWcapSession.prototype = {
this.m_sessionId = null;
}
this.m_userId = null;
// ask next time we log in:
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:
@ -1032,23 +1027,47 @@ calWcapSession.prototype = {
}
};
var g_httpHosts = [];
function confirmUnsecureLogin( uri )
var g_confirmedHttpLogins = null;
function confirmInsecureLogin( uri )
{
if (g_confirmedHttpLogins == null) {
g_confirmedHttpLogins = {};
var confirmedHttpLogins = getPref(
"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;
for each ( var hostEntry in g_httpHosts ) {
if (hostEntry.m_host == host) {
return hostEntry.m_bConfirmed;
}
}
var encodedHost = encodeURIComponent(host);
var confirmedEntry = g_confirmedHttpLogins[encodedHost];
if (confirmedEntry)
return (confirmedEntry == "1" ? true : false);
var prompt = getWindowWatcher().getNewPrompter(null);
var bundle = getWcapBundle();
var bConfirmed = prompt.confirm(
var dontAskAgain = { value: false };
var bConfirmed = prompt.confirmCheck(
bundle.GetStringFromName("noHttpsConfirmation.label"),
bundle.formatStringFromName("noHttpsConfirmation.text", [host], 1) );
// save decision for all calendars:
g_httpHosts.push(
{ m_host: host, m_bConfirmed: bConfirmed } );
bundle.formatStringFromName("noHttpsConfirmation.text", [host], 1),
bundle.GetStringFromName("noHttpsConfirmation.check"),
dontAskAgain );
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;
}

Просмотреть файл

@ -213,10 +213,10 @@ function getDatetimeFromIcalProp( prop )
function getPref(prefName, defaultValue)
{
try {
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(nsIPrefBranch);
try {
switch (prefBranch.getPrefType(prefName)) {
case nsIPrefBranch.PREF_BOOL:
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:
//
@ -327,6 +348,8 @@ catch (exc) {
// some string resources:
var g_privateItemTitle = getWcapBundle().GetStringFromName("privateItem.title");
var g_confidentialItemTitle = getWcapBundle().GetStringFromName(
"confidentialItem.title");
var g_busyItemTitle = getWcapBundle().GetStringFromName("busyItem.title");
var g_busyItemUuidPrefix = ("uuid" + getTime().icalString);
var g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid" + getTime().icalString);