Search in sources :

Example 1 with ClientMetaData

use of org.apache.openejb.client.ClientMetaData in project tomee by apache.

the class ClientObjectFactory method getEJBHome.

@Override
public javax.ejb.EJBHome getEJBHome(final ProxyInfo info) {
    final CallContext call = CallContext.getCallContext();
    final BeanContext beanContext = info.getBeanContext();
    final int idCode = -1;
    Object securityIdentity = null;
    try {
        securityIdentity = call.getEJBRequest().getClientIdentity();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final ClientMetaData cMetaData = new ClientMetaData(securityIdentity);
    final EJBMetaDataImpl eMetaData = buildEjbMetaData(info, beanContext, idCode);
    final EJBHomeHandler hanlder = EJBHomeHandler.createEJBHomeHandler(JNDIContext.globalExecutor(), eMetaData, getServerMetaData(), cMetaData, null);
    return hanlder.createEJBHomeProxy();
}
Also used : BeanContext(org.apache.openejb.BeanContext) EJBMetaDataImpl(org.apache.openejb.client.EJBMetaDataImpl) EJBHomeHandler(org.apache.openejb.client.EJBHomeHandler) ClientMetaData(org.apache.openejb.client.ClientMetaData)

Example 2 with ClientMetaData

use of org.apache.openejb.client.ClientMetaData in project tomee by apache.

the class ClientObjectFactory method getHandle.

@Override
public javax.ejb.Handle getHandle(final ProxyInfo info) {
    final CallContext call = CallContext.getCallContext();
    final BeanContext beanContext = info.getBeanContext();
    final int idCode = -1;
    Object securityIdentity = null;
    try {
        securityIdentity = call.getEJBRequest().getClientIdentity();
    } catch (Exception e) {
    //Ignore
    }
    final ClientMetaData cMetaData = new ClientMetaData(securityIdentity);
    final EJBMetaDataImpl eMetaData = buildEjbMetaData(info, beanContext, idCode);
    final Object primKey = info.getPrimaryKey();
    final EJBObjectHandler handler = EJBObjectHandler.createEJBObjectHandler(JNDIContext.globalExecutor(), eMetaData, getServerMetaData(), cMetaData, primKey, null);
    return new EJBObjectHandle(handler.createEJBObjectProxy());
}
Also used : BeanContext(org.apache.openejb.BeanContext) EJBMetaDataImpl(org.apache.openejb.client.EJBMetaDataImpl) EJBObjectHandler(org.apache.openejb.client.EJBObjectHandler) EJBObjectHandle(org.apache.openejb.client.EJBObjectHandle) ClientMetaData(org.apache.openejb.client.ClientMetaData)

Example 3 with ClientMetaData

use of org.apache.openejb.client.ClientMetaData in project tomee by apache.

the class ClientObjectFactory method getHomeHandle.

@Override
public javax.ejb.HomeHandle getHomeHandle(final ProxyInfo info) {
    final CallContext call = CallContext.getCallContext();
    final BeanContext beanContext = info.getBeanContext();
    final int idCode = -1;
    Object securityIdentity = null;
    try {
        securityIdentity = call.getEJBRequest().getClientIdentity();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final ClientMetaData cMetaData = new ClientMetaData(securityIdentity);
    final EJBMetaDataImpl eMetaData = buildEjbMetaData(info, beanContext, idCode);
    final EJBHomeHandler hanlder = EJBHomeHandler.createEJBHomeHandler(JNDIContext.globalExecutor(), eMetaData, getServerMetaData(), cMetaData, call.get(JNDIContext.AuthenticationInfo.class));
    return new EJBHomeHandle(hanlder.createEJBHomeProxy());
}
Also used : BeanContext(org.apache.openejb.BeanContext) EJBMetaDataImpl(org.apache.openejb.client.EJBMetaDataImpl) EJBHomeHandler(org.apache.openejb.client.EJBHomeHandler) EJBHomeHandle(org.apache.openejb.client.EJBHomeHandle) ClientMetaData(org.apache.openejb.client.ClientMetaData)

Example 4 with ClientMetaData

use of org.apache.openejb.client.ClientMetaData in project tomee by apache.

the class ClientObjectFactory method getEJBObject.

@Override
public javax.ejb.EJBObject getEJBObject(final ProxyInfo info) {
    final CallContext call = CallContext.getCallContext();
    final BeanContext beanContext = info.getBeanContext();
    final int idCode = -1;
    Object securityIdentity = null;
    try {
        securityIdentity = call.getEJBRequest().getClientIdentity();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final ClientMetaData cMetaData = new ClientMetaData(securityIdentity);
    final EJBMetaDataImpl eMetaData = buildEjbMetaData(info, beanContext, idCode);
    final Object primKey = info.getPrimaryKey();
    final EJBObjectHandler hanlder = EJBObjectHandler.createEJBObjectHandler(JNDIContext.globalExecutor(), eMetaData, getServerMetaData(), cMetaData, primKey, null);
    return (javax.ejb.EJBObject) hanlder.createEJBObjectProxy();
}
Also used : BeanContext(org.apache.openejb.BeanContext) EJBMetaDataImpl(org.apache.openejb.client.EJBMetaDataImpl) EJBObjectHandler(org.apache.openejb.client.EJBObjectHandler) ClientMetaData(org.apache.openejb.client.ClientMetaData)

Example 5 with ClientMetaData

use of org.apache.openejb.client.ClientMetaData in project tomee by apache.

the class AuthRequestHandler method processRequest.

@Override
public Response processRequest(final ObjectInputStream in, final ProtocolMetaData metaData) throws Exception {
    final AuthenticationRequest req = new AuthenticationRequest();
    req.setMetaData(metaData);
    final AuthenticationResponse res = new AuthenticationResponse();
    res.setMetaData(metaData);
    try {
        req.readExternal(in);
        final String securityRealm = req.getRealm();
        final String username = req.getUsername();
        final String password = req.getCredentials();
        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        final Object token = securityService.login(securityRealm, username, password);
        final ClientMetaData client = new ClientMetaData();
        client.setMetaData(metaData);
        client.setClientIdentity(token);
        res.setIdentity(client);
        res.setResponseCode(ResponseCodes.AUTH_GRANTED);
    } catch (Throwable t) {
        res.setResponseCode(ResponseCodes.AUTH_DENIED);
        res.setDeniedCause(t);
    } finally {
        if (debug) {
            try {
                logger.debug("AUTH REQUEST: " + req + " -- RESPONSE: " + res);
            } catch (Exception e) {
            //Ignore
            }
        }
    }
    return res;
}
Also used : SecurityService(org.apache.openejb.spi.SecurityService) AuthenticationRequest(org.apache.openejb.client.AuthenticationRequest) AuthenticationResponse(org.apache.openejb.client.AuthenticationResponse) ClientMetaData(org.apache.openejb.client.ClientMetaData)

Aggregations

ClientMetaData (org.apache.openejb.client.ClientMetaData)6 BeanContext (org.apache.openejb.BeanContext)5 EJBMetaDataImpl (org.apache.openejb.client.EJBMetaDataImpl)5 EJBObjectHandler (org.apache.openejb.client.EJBObjectHandler)3 EJBHomeHandler (org.apache.openejb.client.EJBHomeHandler)2 AuthenticationRequest (org.apache.openejb.client.AuthenticationRequest)1 AuthenticationResponse (org.apache.openejb.client.AuthenticationResponse)1 EJBHomeHandle (org.apache.openejb.client.EJBHomeHandle)1 EJBObjectHandle (org.apache.openejb.client.EJBObjectHandle)1 SecurityService (org.apache.openejb.spi.SecurityService)1