use of com.sun.enterprise.deployment.SecurityPermission in project Payara by payara.
the class ConnectorConfigurationParserServiceImpl method getSecurityPermissionSpec.
/**
* Obtains the Permission string that needs to be added to the
* to the security policy files. These are the security permissions needed
* by the resource adapter implementation classes.
* These strings are obtained by parsing the ra.xml
*
* @param moduleName rar module Name
* @return Required policy permissions in server.policy file
* @throws ConnectorRuntimeException If rar.xml parsing fails.
*/
public String getSecurityPermissionSpec(String moduleName) throws ConnectorRuntimeException {
if (moduleName == null) {
return null;
}
String policyString = null;
// check whether the policy file already has required permissions.
String fileName = System.getProperty("java.security.policy");
if (fileName != null) {
File policyFile = new File(fileName);
String policyContent = getFileContent(policyFile);
ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(moduleName);
Set securityPermissions = connectorDescriptor.getSecurityPermissions();
Iterator it = securityPermissions.iterator();
SecurityPermission secPerm = null;
String permissionString = null;
while (it.hasNext()) {
secPerm = (SecurityPermission) it.next();
permissionString = secPerm.getPermission();
int intIndex = policyContent.indexOf(permissionString);
if (intIndex == -1) {
if (permissionString != null) {
if (policyString != null) {
policyString = policyString + "\n \n" + permissionString;
} else {
policyString = "\n\n" + permissionString;
}
}
}
}
// print the missing permissions
if (policyString != null) {
policyString = CAUTION_MESSAGE + policyString;
}
}
return policyString;
}
use of com.sun.enterprise.deployment.SecurityPermission in project Payara by payara.
the class SecurityPermissionNode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param the descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node parent, ConnectorDescriptor descriptor) {
Iterator secPerms = descriptor.getSecurityPermissions().iterator();
// auth mechanism info
for (; secPerms.hasNext(); ) {
// for (Iterator secPerms = ((OutboundResourceAdapter)descriptor).getSecurityPermissions().iterator(); secPerms.hasNext();) {
SecurityPermission secPerm = (SecurityPermission) secPerms.next();
Node secNode = appendChild(parent, ConnectorTagNames.SECURITY_PERMISSION);
writeLocalizedDescriptions(secNode, secPerm);
appendTextChild(secNode, ConnectorTagNames.SECURITY_PERMISSION_SPEC, secPerm.getPermission());
}
return null;
}
Aggregations