Skip to content
Snippets Groups Projects
Commit 60c9b382 authored by Aleksei Voitylov's avatar Aleksei Voitylov Committed by Christoph Langer
Browse files

8285662: Better permission resolution

Reviewed-by: mbalao
Backport-of: 431802c54df9caaa00ba79f3713861005d06ee62
parent 009488ee
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -153,7 +153,7 @@ implements java.io.Serializable
* Each chain is ordered bottom-to-top (i.e., with the signer certificate
* first and the (root) certificate authority last). The signer
* certificates are copied from the array. Subsequent changes to
* the array will not affect this UnsolvedPermission.
* the array will not affect this UnresolvedPermission.
*/
public UnresolvedPermission(String type,
String name,
......@@ -165,21 +165,27 @@ implements java.io.Serializable
if (type == null)
throw new NullPointerException("type can't be null");
// Perform a defensive copy and reassign certs if we have a non-null
// reference
if (certs != null) {
certs = certs.clone();
}
this.type = type;
this.name = name;
this.actions = actions;
if (certs != null) {
// Extract the signer certs from the list of certificates.
for (int i = 0; i < certs.length; i++) {
if (!(certs[i] instanceof X509Certificate)) {
// there is no concept of signer certs, so we store the
// entire cert array
this.certs = certs.clone();
break;
// entire cert array. No further processing is necessary.
this.certs = certs;
return;
}
}
if (this.certs == null) {
// Go through the list of certs and see if all the certs are
// signer certs.
int i = 0;
......@@ -195,11 +201,11 @@ implements java.io.Serializable
}
if (count == certs.length) {
// All the certs are signer certs, so we store the entire
// array
this.certs = certs.clone();
// array. No further processing is needed.
this.certs = certs;
return;
}
if (this.certs == null) {
// extract the signer certs
ArrayList<java.security.cert.Certificate> signerCerts =
new ArrayList<>();
......@@ -218,8 +224,6 @@ implements java.io.Serializable
signerCerts.toArray(this.certs);
}
}
}
}
private static final Class<?>[] PARAMS0 = { };
......@@ -310,6 +314,7 @@ implements java.io.Serializable
*
* @return false.
*/
@Override
public boolean implies(Permission p) {
return false;
}
......@@ -330,6 +335,7 @@ implements java.io.Serializable
* type (class) name, permission name, actions, and
* certificates as this object.
*/
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
......@@ -402,7 +408,7 @@ implements java.io.Serializable
*
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
int hash = type.hashCode();
if (name != null)
......@@ -422,6 +428,7 @@ implements java.io.Serializable
*
* @return the empty string "".
*/
@Override
public String getActions()
{
return "";
......@@ -489,6 +496,7 @@ implements java.io.Serializable
*
* @return information about this UnresolvedPermission.
*/
@Override
public String toString() {
return "(unresolved " + type + " " + name + " " + actions + ")";
}
......@@ -500,7 +508,7 @@ implements java.io.Serializable
* @return a new PermissionCollection object suitable for
* storing UnresolvedPermissions.
*/
@Override
public PermissionCollection newPermissionCollection() {
return new UnresolvedPermissionCollection();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment