How to allow 'UniversalXPConnect' privilege dynamically

guido <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xpfe
Message-ID <[email protected]>
Hi All,

I'm working on a XUL application that displays remote xul pages from a 
server.

In order to avoid prompting a warning alert to the user,
I'm giving UniversalXPConnect privilege to the default server by setting 
the following prefs on the client-side application:

user_pref("capability.principal.codebase.p1.granted", "UniversalXPConnect");
user_pref("capability.principal.codebase.p1.id", 
"http://defaultServer.com");
user_pref("capability.principal.codebase.p1.subjectName", "");

This is done at installation time by the installer and it works just fine.

Now I also want to write a configuration tool (that it's again a XUL 
application) to edit the server URL. The user is asked to enter the new 
URL in a form and
I want to give UniversalXPConnect privilege to this server as well.

Here comes the issue.
I didn't find a way to allow the privilege and the user is prompted with 
the warning dialog the first time he tries to access the new server

Things I tried :

1) Using the nsIPrincipal interface but I didn't find much documentation 
about it.
Can you provide an example of using it?

2) Editing the prefs file from my script (by using nsIPrefBranch) and 
adding the following lines

user_pref("capability.principal.codebase.p2.granted", "UniversalXPConnect");
user_pref("capability.principal.codebase.p2.id", "http://newServer.com");
user_pref("capability.principal.codebase.p2.subjectName", "");

but the "id" preference gets never written. Do you know why?


Any idea how can this be solved?

Many thanks,

Guido.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.