home *** CD-ROM | disk | FTP | other *** search
- package netscape.softupdate;
-
- import java.util.Enumeration;
- import netscape.security.Principal;
- import netscape.security.PrivilegeManager;
-
- public final class Registry implements RegistryErrors {
- protected static final int ROOTKEY_USERS = 1;
- protected static final int ROOTKEY_COMMON = 2;
- protected static final int ROOTKEY_CURRENT_USER = 3;
- protected static final int ROOTKEY_PRIVATE = 4;
- protected static final int ROOTKEY = 32;
- protected static final int ROOTKEY_VERSIONS = 33;
- protected static final int PRIVATE_KEY_COMMON = -2;
- protected static final int PRIVATE_KEY_USER = -3;
- protected static final int ENUM_NORMAL = 0;
- protected static final int ENUM_DESCEND = 1;
- public static final int TYPE_STRING = 17;
- public static final int TYPE_INT_ARRAY = 18;
- public static final int TYPE_BYTES = 19;
- private static final String PRIVATE = "PrivateRegistryAccess";
- private static final String STANDARD = "StandardRegistryAccess";
- private static final String ADMIN = "AdministratorRegistryAccess";
- private int hReg;
- private String regName;
- private String username;
-
- public Registry() throws RegistryException {
- this("");
- }
-
- private Registry(String var1) throws RegistryException {
- this.regName = var1;
- PrivilegeManager.checkPrivilegeEnabled("PrivateRegistryAccess");
- int var2 = this.nOpen();
- if (var2 != 0) {
- throw new RegistryException(var2);
- }
- }
-
- public RegistryNode addNode(RegistryNode var1, String var2) throws RegistryException {
- int var3;
- String var4;
- if (var1 == null) {
- var4 = "AdministratorRegistryAccess";
- var3 = 32;
- } else {
- var4 = var1.getTarget();
- var3 = var1.getKey();
- }
-
- PrivilegeManager.checkPrivilegeEnabled(var4);
- int var5 = this.nAddKey(var3, var2);
- if (var5 != 0) {
- throw new RegistryException(var5);
- } else {
- return this.nGetKey(var3, var2, var4);
- }
- }
-
- public void deleteNode(RegistryNode var1, String var2) throws RegistryException {
- int var3;
- String var4;
- if (var1 == null) {
- var4 = "AdministratorRegistryAccess";
- var3 = 32;
- } else {
- var4 = var1.getTarget();
- var3 = var1.getKey();
- }
-
- PrivilegeManager.checkPrivilegeEnabled(var4);
- int var5 = this.nDeleteKey(var3, var2);
- if (var5 != 0) {
- throw new RegistryException(var5);
- }
- }
-
- public RegistryNode getNode(RegistryNode var1, String var2) throws RegistryException {
- int var3;
- String var4;
- if (var1 == null) {
- var4 = "AdministratorRegistryAccess";
- var3 = 32;
- } else {
- var4 = var1.getTarget();
- var3 = var1.getKey();
- }
-
- PrivilegeManager.checkPrivilegeEnabled(var4);
- return this.nGetKey(var3, var2, var4);
- }
-
- public Enumeration children(RegistryNode var1, String var2) throws RegistryException {
- RegistryNode var3 = this.getNode(var1, var2);
- return new RegKeyEnumerator(this, var3.getKey(), 0, var3.getTarget());
- }
-
- public Enumeration subtree(RegistryNode var1, String var2) throws RegistryException {
- RegistryNode var3 = this.getNode(var1, var2);
- return new RegKeyEnumerator(this, var3.getKey(), 1, var3.getTarget());
- }
-
- public RegistryNode getSharedNode() throws RegistryException {
- PrivilegeManager.checkPrivilegeEnabled("StandardRegistryAccess");
- return this.nGetKey(2, "", "StandardRegistryAccess");
- }
-
- public RegistryNode getSharedUserNode() throws RegistryException {
- PrivilegeManager.checkPrivilegeEnabled("StandardRegistryAccess");
- return this.nGetKey(3, "", "StandardRegistryAccess");
- }
-
- public RegistryNode getPrivateNode() throws RegistryException {
- PrivilegeManager.checkPrivilegeEnabled("PrivateRegistryAccess");
- Principal[] var1 = PrivilegeManager.getPrivilegeManager().getClassPrincipalsFromStack(1);
- if (var1 == null) {
- System.out.println("Registry called without principals");
- throw new NullPointerException("Registry called without principals");
- } else {
- String var2 = "/" + var1[0].getFingerPrint() + "/Common";
- int var3 = this.nAddKey(4, var2);
- if (var3 != 0) {
- throw new RegistryException(var3);
- } else {
- return this.nGetKey(4, var2, "PrivateRegistryAccess");
- }
- }
- }
-
- public RegistryNode getPrivateUserNode() throws RegistryException {
- PrivilegeManager.checkPrivilegeEnabled("PrivateRegistryAccess");
- Principal[] var1 = PrivilegeManager.getPrivilegeManager().getClassPrincipalsFromStack(1);
- if (var1 == null) {
- System.out.println("Registry called without principals");
- throw new NullPointerException("Registry called without principals");
- } else {
- String var2 = "/" + var1[0].getFingerPrint() + "/Users/" + this.userName();
- int var3 = this.nAddKey(4, var2);
- if (var3 != 0) {
- throw new RegistryException(var3);
- } else {
- return this.nGetKey(4, var2, "PrivateRegistryAccess");
- }
- }
- }
-
- protected void finalize() throws Throwable {
- if (this.hReg != 0) {
- this.nClose();
- }
-
- }
-
- private String userName() {
- if (this.username == null) {
- this.username = this.nUserName();
- }
-
- return this.username;
- }
-
- private native int nOpen();
-
- private native int nClose();
-
- private native int nAddKey(int var1, String var2);
-
- private native int nDeleteKey(int var1, String var2);
-
- private native RegistryNode nGetKey(int var1, String var2, String var3);
-
- private native String nUserName();
- }
-