Search in sources :

Example 1 with ProtocolManager

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;
}
Also used : ProtectionDomain(java.security.ProtectionDomain) ProtocolManager(org.glassfish.enterprise.iiop.api.ProtocolManager) CORBAObjectPermission(com.sun.enterprise.security.CORBAObjectPermission)

Example 2 with ProtocolManager

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;
}
Also used : ProtocolManager(org.glassfish.enterprise.iiop.api.ProtocolManager) GlassFishORBHelper(org.glassfish.enterprise.iiop.api.GlassFishORBHelper) IOException(java.io.IOException) IOException(java.io.IOException) NamingException(javax.naming.NamingException)

Example 3 with ProtocolManager

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;
}
Also used : RemoteBusinessWrapperBase(com.sun.ejb.containers.RemoteBusinessWrapperBase) ProtocolManager(org.glassfish.enterprise.iiop.api.ProtocolManager)

Aggregations

ProtocolManager (org.glassfish.enterprise.iiop.api.ProtocolManager)3 RemoteBusinessWrapperBase (com.sun.ejb.containers.RemoteBusinessWrapperBase)1 CORBAObjectPermission (com.sun.enterprise.security.CORBAObjectPermission)1 IOException (java.io.IOException)1 ProtectionDomain (java.security.ProtectionDomain)1 NamingException (javax.naming.NamingException)1 GlassFishORBHelper (org.glassfish.enterprise.iiop.api.GlassFishORBHelper)1