[jboss-cvs] JBossAS SVN: r95568 - branches/Branch_4_2/system/src/main/org/jboss/deployment.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 26 11:09:11 EDT 2009
Author: Robert.Panzer
Date: 2009-10-26 11:09:11 -0400 (Mon, 26 Oct 2009)
New Revision: 95568
Modified:
branches/Branch_4_2/system/src/main/org/jboss/deployment/DeploymentInfo.java
Log:
JBAS6660: Grant Java2 Security permissions in a policy file only to certain components of an ear file
Modified: branches/Branch_4_2/system/src/main/org/jboss/deployment/DeploymentInfo.java
===================================================================
--- branches/Branch_4_2/system/src/main/org/jboss/deployment/DeploymentInfo.java 2009-10-26 14:59:42 UTC (rev 95567)
+++ branches/Branch_4_2/system/src/main/org/jboss/deployment/DeploymentInfo.java 2009-10-26 15:09:11 UTC (rev 95568)
@@ -287,6 +287,9 @@
// Add the deployment URL to the parent UCL
ucl = parent.ucl;
ucl.addURL(localUrl);
+ URL policyCodeSourceUrl = getPolicyCodeSourceUrl();
+ log.trace("Map Policy CodeSource for "+localUrl+" to "+policyCodeSourceUrl);
+ ucl.setPolicyCodeSourceUrl(localUrl, policyCodeSourceUrl);
}
// Add any library jars seen before the UCL was created
if( classpath.size() > 0 )
@@ -300,6 +303,37 @@
}
}
+ /**
+ * This method creates a URL that can be used for codeBase matching in policy files.
+ * While the real URL contains temporary names, this URL is created from the short names
+ * of the deployment infos and the external name of the root deployment info.
+ *
+ * <p>So instead of file:/.../jboss/server/default/tmp/deploy/MyEar.ear/MyEjb78945.jar
+ * this method will create the URL file:/.../jboss/server/default/deploy/MyEar.ear/MyEjb.jar
+ * @return The URL that should be used for matching codeBases in policy files.
+ * @throws Exception
+ */
+ private URL getPolicyCodeSourceUrl() throws Exception {
+ DeploymentInfo current = this;
+ StringBuffer sOrigURL = new StringBuffer();
+ while (current.parent != null)
+ {
+ sOrigURL.insert(0, "/"+current.shortName);
+ current = current.parent;
+ }
+ String currentUrl = current.url.toExternalForm();
+ if (currentUrl.endsWith("/"))
+ {
+ sOrigURL.insert(0, currentUrl.substring(0, currentUrl.length()-1));
+ }
+ else
+ {
+ sOrigURL.insert(0, currentUrl);
+ }
+ URL policyCodeSourceUrl = new URL(sOrigURL.toString());
+ return policyCodeSourceUrl;
+ }
+
/** Set the UnifiedLoaderRepository info for the deployment. This can only
* be called for the parent deployment, and must be done early in the
* Subdeployer init(DeploymentInfo) method prior to any class loading.
More information about the jboss-cvs-commits
mailing list