use of com.sun.enterprise.security.util.IASSecurityException in project Payara by payara.
the class SecurityUtil method linkPolicyFile.
/**
* This method obtains the policy configuration object corresponding to the name, and links it, for roleMapping purposes
* to another. If the pc is already InService when this method is called, this method does nothing.
*
* @param String name - the module id which serves to identify the corresponding policy context. The name shall not be
* null.
* @param String linkName - the module id of the module being linked to this context. This value may be null, in which
* case, no link is done, but the inService state of the named PC is returned.
* @param boolean lastInService - the inService state returned by the previous call to this method. The value of this
* argument is only significant when linkName is not null.
* @return boolean if linkName is null, returns the inService state of the PC identified in the name argument. Otherwise
* returns the value passed to lastInService.
*/
public static boolean linkPolicyFile(String name, String linkName, boolean lastInService) throws IASSecurityException {
boolean rvalue = lastInService;
assert name != null;
if (name == null) {
throw new IASSecurityException("Invalid Module Name");
}
try {
PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
boolean inService = pcf.inService(name);
if (linkName == null) {
rvalue = inService;
} else if (inService == lastInService) {
// only do the link if the named PC is not inService.
if (!inService) {
// find the PolicyConfigs using remove=false to ensure policy stmts
// are retained.
PolicyConfiguration pc = pcf.getPolicyConfiguration(name, false);
PolicyConfiguration linkPc = pcf.getPolicyConfiguration(linkName, false);
pc.linkConfiguration(linkPc);
}
} else {
throw new IASSecurityException("Inconsistent Module State");
}
} catch (java.lang.ClassNotFoundException cnfe) {
String msg = localStrings.getLocalString("enterprise.security.securityutil.classnotfound", "Could not find PolicyConfigurationFactory class. Check javax.security.jacc.PolicyConfigurationFactory.provider property");
throw new IASSecurityException(msg);
} catch (javax.security.jacc.PolicyContextException pce) {
throw new IASSecurityException(pce.toString());
}
return rvalue;
}
Aggregations