use of org.glassfish.ejb.security.application.EJBSecurityManager in project Payara by payara.
the class EJBSecurityManagerFactory method createManager.
public EJBSecurityManager createManager(EjbDescriptor ejbDesc, boolean register) {
String ctxId = EJBSecurityManager.getContextID(ejbDesc);
String ejbName = ejbDesc.getName();
EJBSecurityManager manager = null;
if (register) {
manager = getManager(ctxId, ejbName, false);
}
if (manager == null || !register) {
try {
probeProvider.securityManagerCreationStartedEvent(ejbName);
manager = new EJBSecurityManager(ejbDesc, this.invMgr, this);
probeProvider.securityManagerCreationEndedEvent(ejbName);
if (register) {
String appName = ejbDesc.getApplication().getRegistrationName();
addManagerToApp(ctxId, ejbName, appName, manager);
probeProvider.securityManagerCreationEvent(ejbName);
}
} catch (Exception ex) {
_logger.log(Level.FINE, "[EJB-Security] FATAL Exception. Unable to create EJBSecurityManager: " + ex.getMessage());
throw new RuntimeException(ex);
}
}
return manager;
}
use of org.glassfish.ejb.security.application.EJBSecurityManager in project Payara by payara.
the class EjbDeployer method clean.
/**
* Clean any files and artifacts that were created during the execution
* of the prepare method.
*
* @param dc deployment context
*/
public void clean(DeploymentContext dc) {
// Both undeploy and shutdown scenarios are
// handled directly in EjbApplication.shutdown.
// But CMP drop tables should be handled here.
OpsParams params = dc.getCommandParameters(OpsParams.class);
if ((params.origin.isUndeploy() || params.origin.isDeploy()) && isDas()) {
// If CMP beans are present, cmpDeployer should've been initialized in unload()
if (cmpDeployer != null) {
cmpDeployer.clean(dc);
}
Properties appProps = dc.getAppProps();
String uniqueAppId = appProps.getProperty(APP_UNIQUE_ID_PROP);
try {
if (getTimeoutStatusFromApplicationInfo(params.name()) && uniqueAppId != null) {
String target = ((params.origin.isDeploy()) ? dc.getCommandParameters(DeployCommandParameters.class).target : dc.getCommandParameters(UndeployCommandParameters.class).target);
if (DeploymentUtils.isDomainTarget(target)) {
List<String> targets = (List<String>) dc.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class);
if (targets == null) {
targets = domain.getAllReferencedTargetsForApplication(params.name());
}
if (targets != null && targets.size() > 0) {
target = targets.get(0);
}
}
EJBTimerService timerService = null;
boolean tsInitialized = false;
ProgressTracker tracker = dc.getTransientAppMetaData(ExtendedDeploymentContext.TRACKER, ProgressTracker.class);
if (tracker == null || !tracker.get("initialized", EngineRef.class).isEmpty()) {
timerService = EJBTimerService.getEJBTimerService(target, false);
tsInitialized = true;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer APP ID of a Timeout App? " + uniqueAppId);
_logger.log(Level.FINE, "EjbDeployer TimerService: " + timerService);
}
if (tsInitialized) {
if (timerService == null) {
_logger.log(Level.WARNING, "EJB Timer Service is not available. Timers for application with id " + uniqueAppId + " will not be deleted");
} else {
if (getKeepStateFromApplicationInfo(params.name())) {
_logger.log(Level.INFO, "Timers will not be destroyed since keepstate is true for application {0}", params.name());
} else {
timerService.destroyAllTimers(Long.parseLong(uniqueAppId));
}
}
}
}
} catch (Exception e) {
_logger.log(Level.WARNING, "Failed to delete timers for application with id " + uniqueAppId, e);
}
}
// Security related cleanup is to be done for the undeploy event
if (params.origin.isUndeploy() || params.origin.isDeploy() || params.origin.isLoad()) {
// Removing EjbSecurityManager for undeploy case
String appName = params.name();
String[] contextIds = ejbSecManagerFactory.getContextsForApp(appName, false);
if (contextIds != null) {
for (String contextId : contextIds) {
try {
// TODO:appName is not correct, we need the module name
// from the descriptor.
probeProvider.policyDestructionStartedEvent(contextId);
SecurityUtil.removePolicy(contextId);
probeProvider.policyDestructionEndedEvent(contextId);
probeProvider.policyDestructionEvent(contextId);
} catch (IASSecurityException ex) {
_logger.log(Level.WARNING, "Error removing the policy file " + "for application " + appName + " " + ex);
}
ArrayList<EJBSecurityManager> managers = ejbSecManagerFactory.getManagers(contextId, false);
if (managers != null) {
for (EJBSecurityManager m : managers) {
m.destroy();
}
}
}
}
// Removing the RoleMapper
SecurityUtil.removeRoleMapper(dc);
}
}
use of org.glassfish.ejb.security.application.EJBSecurityManager in project Payara by payara.
the class BaseContainerFactory method getSecurityManager.
protected final SecurityManager getSecurityManager(EjbDescriptor ejbDescriptor) throws Exception {
String ctxId = EJBSecurityManager.getContextID(ejbDescriptor);
String ejbName = ejbDescriptor.getName();
EJBSecurityManager sm = securityManagerFactory.getManager(ctxId, ejbName, false);
if (sm == null) {
sm = securityManagerFactory.createManager(ejbDescriptor, true);
}
return sm;
}
Aggregations