use of sun.security.provider.PolicyParser.PermissionEntry in project jdk8u_jdk by JetBrains.
the class PolicyPermissions method addGrantEntry.
/**
* Add one policy entry to the vector.
*/
private void addGrantEntry(GrantEntry ge, KeyStore keyStore) {
if (debug != null) {
debug.println("Adding policy entry: ");
debug.println(" signedBy " + ge.signedBy);
debug.println(" codeBase " + ge.codeBase);
if (ge.principals != null) {
for (PrincipalEntry pppe : ge.principals) {
debug.println(" " + pppe.getPrincipalClass() + " " + pppe.getPrincipalName());
}
}
debug.println();
}
try {
CodeSource codesource = getCodeSource(ge, keyStore);
// skip if signedBy alias was unknown...
if (codesource == null)
return;
PolicyEntry entry = new PolicyEntry(codesource);
Enumeration<PermissionEntry> enum_ = ge.permissionElements();
while (enum_.hasMoreElements()) {
PermissionEntry pe = enum_.nextElement();
try {
// XXX special case PrivateCredentialPermission-SELF
Permission perm;
if (pe.permission.equals("javax.security.auth.PrivateCredentialPermission") && pe.name.endsWith(" self")) {
perm = getInstance(pe.permission, pe.name + " \"self\"", pe.action);
} else {
perm = getInstance(pe.permission, pe.name, pe.action);
}
entry.add(perm);
if (debug != null) {
debug.println(" " + perm);
}
} catch (ClassNotFoundException cnfe) {
Certificate[] certs;
if (pe.signedBy != null) {
certs = getCertificates(keyStore, pe.signedBy);
} else {
certs = null;
}
// a signer and found the keys for it.
if (certs != null || pe.signedBy == null) {
Permission perm = new UnresolvedPermission(pe.permission, pe.name, pe.action, certs);
entry.add(perm);
if (debug != null) {
debug.println(" " + perm);
}
}
} catch (java.lang.reflect.InvocationTargetException ite) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Permission.") + pe.permission + rb.getString("SPACE") + ite.getTargetException());
} catch (Exception e) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Permission.") + pe.permission + rb.getString("SPACE") + e);
}
}
policyEntries.addElement(entry);
} catch (Exception e) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Entry.") + ge + rb.getString("SPACE") + e);
}
if (debug != null) {
debug.println();
}
}
use of sun.security.provider.PolicyParser.PermissionEntry in project Bytecoder by mirkosertic.
the class PolicyPermissions method addGrantEntry.
/**
* Add one policy entry to the vector.
*/
private void addGrantEntry(GrantEntry ge, KeyStore keyStore) {
if (debug != null) {
debug.println("Adding policy entry: ");
debug.println(" signedBy " + ge.signedBy);
debug.println(" codeBase " + ge.codeBase);
if (ge.principals != null) {
for (PrincipalEntry pppe : ge.principals) {
debug.println(" " + pppe.getPrincipalClass() + " " + pppe.getPrincipalName());
}
}
debug.println();
}
try {
CodeSource codesource = getCodeSource(ge, keyStore);
// skip if signedBy alias was unknown...
if (codesource == null)
return;
PolicyEntry entry = new PolicyEntry(codesource);
Enumeration<PermissionEntry> enum_ = ge.permissionElements();
while (enum_.hasMoreElements()) {
PermissionEntry pe = enum_.nextElement();
try {
// XXX special case PrivateCredentialPermission-SELF
Permission perm;
if (pe.permission.equals("javax.security.auth.PrivateCredentialPermission") && pe.name.endsWith(" self")) {
perm = getInstance(pe.permission, pe.name + " \"self\"", pe.action);
} else {
perm = getInstance(pe.permission, pe.name, pe.action);
}
entry.add(perm);
if (debug != null) {
debug.println(" " + perm);
}
} catch (ClassNotFoundException cnfe) {
Certificate[] certs;
if (pe.signedBy != null) {
certs = getCertificates(keyStore, pe.signedBy);
} else {
certs = null;
}
// a signer and found the keys for it.
if (certs != null || pe.signedBy == null) {
Permission perm = new UnresolvedPermission(pe.permission, pe.name, pe.action, certs);
entry.add(perm);
if (debug != null) {
debug.println(" " + perm);
}
}
} catch (java.lang.reflect.InvocationTargetException ite) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Permission.") + pe.permission + rb.getString("SPACE") + ite.getTargetException());
} catch (Exception e) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Permission.") + pe.permission + rb.getString("SPACE") + e);
}
}
policyEntries.addElement(entry);
} catch (Exception e) {
System.err.println(AUTH_POLICY + rb.getString(".error.adding.Entry.") + ge + rb.getString("SPACE") + e);
}
if (debug != null) {
debug.println();
}
}
Aggregations