use of org.glassfish.enterprise.iiop.api.ProtocolManager in project Payara by payara.
the class SecurityContextUtil method authorizeCORBA.
// return true if authorization succeeds, false otherwise.
private boolean authorizeCORBA(byte[] objectId, String method) throws Exception {
ProtocolManager protocolManager = orbHelper.getProtocolManager();
// is on a callback object in the client VM.
if (protocolManager == null) {
return true;
}
// Check if target is an EJB
if (protocolManager.getEjbDescriptor(objectId) != null) {
// an EJB object
return true;
}
// Create a ProtectionDomain for principal on current thread.
ProtectionDomain principalsDomain = createPrincipalDomain(getPrincipalArray(com.sun.enterprise.security.SecurityContext.getCurrent()));
// Create the permission we want to check for
CORBAObjectPermission permission = new CORBAObjectPermission("*", method);
// Check if policy gives principal the permissions
boolean result = policy.implies(principalsDomain, permission);
if (_logger.isLoggable(FINE)) {
_logger.log(FINE, "CORBA Object permission evaluation result=" + result + " for method=" + method);
}
return result;
}
use of org.glassfish.enterprise.iiop.api.ProtocolManager in project Payara by payara.
the class SerializableS1ASEJBObjectReference method doRemoteRefClassLoaderConversion.
protected static java.rmi.Remote doRemoteRefClassLoaderConversion(java.rmi.Remote reference) throws IOException {
Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
java.rmi.Remote returnReference = reference;
if (reference.getClass().getClassLoader() != contextClassLoader) {
try {
byte[] serializedRef = EJBObjectOutputStreamHandler._javaEEIOUtils.serializeObject(reference, false);
returnReference = (java.rmi.Remote) EJBObjectOutputStreamHandler._javaEEIOUtils.deserializeObject(serializedRef, false, contextClassLoader);
GlassFishORBHelper orbHelper = EjbContainerUtilImpl.getInstance().getORBHelper();
ProtocolManager protocolMgr = orbHelper.getProtocolManager();
protocolMgr.connectObject(returnReference);
} catch (IOException ioe) {
throw ioe;
} catch (Exception e) {
IOException ioEx = new IOException(e.getMessage());
ioEx.initCause(e);
throw ioEx;
}
}
return returnReference;
}
use of org.glassfish.enterprise.iiop.api.ProtocolManager in project Payara by payara.
the class SerializableS1ASEJBObjectReference method replaceObject.
/**
* This code is needed to serialize non-Serializable objects that
* can be part of a bean's state. See EJB2.0 section 7.4.1.
*/
public Object replaceObject(Object obj) throws IOException {
Object result = obj;
// Until we've identified a remote object, we can't assume the orb is
// available in the container. If the orb is not present, this will be null.
ProtocolManager protocolMgr = getProtocolManager();
if (obj instanceof RemoteBusinessWrapperBase) {
result = getRemoteBusinessObjectFactory((RemoteBusinessWrapperBase) obj);
} else if ((protocolMgr != null) && protocolMgr.isStub(obj) && protocolMgr.isLocal(obj)) {
org.omg.CORBA.Object target = (org.omg.CORBA.Object) obj;
// If we're here, it's always for the 2.x RemoteHome view.
// There is no remote business wrapper class.
result = getSerializableEJBReference(target, protocolMgr, null);
}
return result;
}
Aggregations