示例#1
0
  /** Call the required method. */
  public final OutputStream _invoke(String method, InputStream input, ResponseHandler rh) {
    OutputStream output = null;

    if (method.equals("destroy")) {
      // The "destroy" has been invoked.
      destroy();
      output = rh.createReply();
    } else if (method.equals("copy")) {
      // The "copy" has been invoked.
      org.omg.CORBA.Object returns = copy();
      output = rh.createReply();
      output.write_Object(this);
    } else if (method.equals("policy_type")) {
      // The "policy_type" has been invoked.
      int returns = policy_type();
      output = rh.createReply();
      output.write_long(returns);
    } else if (method.equals("value")) {
      // The "value" can be invoked on the children types
      // and must return an integer, representing the policy value
      // (CORBA enumeration).
      output = rh.createReply();
      output.write_long(policyCode);
    } else throw new BAD_OPERATION(method, Minor.Method, CompletionStatus.COMPLETED_MAYBE);

    return output;
  }
 private OutputStream remove(org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply)
     throws Throwable {
   try {
     target.remove();
   } catch (RemoveException ex) {
     String id = "IDL:javax/ejb/RemoveEx:1.0";
     org.omg.CORBA_2_3.portable.OutputStream out =
         (org.omg.CORBA_2_3.portable.OutputStream) reply.createExceptionReply();
     out.write_string(id);
     out.write_value(ex, RemoveException.class);
     return out;
   }
   OutputStream out = reply.createReply();
   return out;
 }
 private OutputStream _get_homeHandle(
     org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply) throws Throwable {
   HomeHandle result = target.getHomeHandle();
   OutputStream out = reply.createReply();
   Util.writeAbstractObject(out, result);
   return out;
 }
 private OutputStream _get_primaryKey(
     org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply) throws Throwable {
   Object result = target.getPrimaryKey();
   OutputStream out = reply.createReply();
   Util.writeAny(out, result);
   return out;
 }
 private OutputStream create(org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply)
     throws Throwable {
   IcpOperation result;
   try {
     result = target.create();
   } catch (CreateException ex) {
     String id = "IDL:javax/ejb/CreateEx:1.0";
     org.omg.CORBA_2_3.portable.OutputStream out =
         (org.omg.CORBA_2_3.portable.OutputStream) reply.createExceptionReply();
     out.write_string(id);
     out.write_value(ex, CreateException.class);
     return out;
   }
   OutputStream out = reply.createReply();
   Util.writeRemoteObject(out, result);
   return out;
 }
 private OutputStream _get_EJBMetaData(
     org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply) throws Throwable {
   EJBMetaData result = target.getEJBMetaData();
   org.omg.CORBA_2_3.portable.OutputStream out =
       (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply();
   out.write_value((Serializable) result, EJBMetaData.class);
   return out;
 }
 private OutputStream isIdentical(org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply)
     throws Throwable {
   EJBObject arg0 = (EJBObject) in.read_Object(EJBObject.class);
   boolean result = target.isIdentical(arg0);
   OutputStream out = reply.createReply();
   out.write_boolean(result);
   return out;
 }
 private OutputStream getSeqNextVal(
     org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply) throws Throwable {
   String arg0 = (String) in.read_value(String.class);
   String result = target.getSeqNextVal(arg0);
   org.omg.CORBA_2_3.portable.OutputStream out =
       (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply();
   out.write_value(result, String.class);
   return out;
 }
 private OutputStream perform(org.omg.CORBA_2_3.portable.InputStream in, ResponseHandler reply)
     throws Throwable {
   BTXDetails arg0 = (BTXDetails) in.read_value(BTXDetails.class);
   BTXDetails result = target.perform(arg0);
   org.omg.CORBA_2_3.portable.OutputStream out =
       (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply();
   out.write_value(result, BTXDetails.class);
   return out;
 }
 public OutputStream _invoke(String method, InputStream _in, ResponseHandler reply)
     throws SystemException {
   try {
     org.omg.CORBA_2_3.portable.InputStream in = (org.omg.CORBA_2_3.portable.InputStream) _in;
     if (method.equals("executeCommand")) {
       Command arg0 = (Command) in.read_value(Command.class);
       Object result = target.executeCommand(arg0);
       OutputStream out = reply.createReply();
       Util.writeAny(out, result);
       return out;
     }
     throw new BAD_OPERATION();
   } catch (SystemException ex) {
     throw ex;
   } catch (Throwable ex) {
     throw new UnknownException(ex);
   }
 }
示例#11
0
  /**
   * Receives IIOP requests to this servant's <code>EJBObject</code>s and forwards them to the bean
   * container, through the JBoss <code>MBean</code> server.
   */
  public OutputStream _invoke(
      final String opName, final InputStream in, final ResponseHandler handler) {

    if (logger.isTraceEnabled()) {
      logger.trace("EJBObject invocation: " + opName);
    }

    SkeletonStrategy op = methodInvokerMap.get(opName);
    if (op == null) {
      logger.debugf(
          "Unable to find opname '%s' valid operations:%s", opName, methodInvokerMap.keySet());
      throw new BAD_OPERATION(opName);
    }
    final NamespaceContextSelector selector =
        componentView.getComponent().getNamespaceContextSelector();
    final ClassLoader oldCl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    NamespaceContextSelector.pushCurrentSelector(selector);
    try {
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
      SecurityContext sc = null;
      org.omg.CORBA_2_3.portable.OutputStream out;
      try {
        Object retVal;

        if (!home && opName.equals("_get_handle")) {
          retVal = new HandleImplIIOP(orb.object_to_string(_this_object()));
        } else if (home && opName.equals("_get_homeHandle")) {
          retVal = homeHandle;
        } else if (home && opName.equals("_get_EJBMetaData")) {
          retVal = ejbMetaData;
        } else {
          Transaction tx = null;
          if (inboundTxCurrent != null) tx = inboundTxCurrent.getCurrentTransaction();
          if (tx != null) {
            transactionManager.resume(tx);
          }
          try {
            SimplePrincipal principal = null;
            Object credential = null;

            if (sasCurrent != null) {
              final byte[] incomingName = sasCurrent.get_incoming_principal_name();

              if (incomingName != null && incomingName.length > 0) {
                // we have an identity token, which is a trust based mechanism
                if (incomingName.length > 0) {
                  String name = new String(incomingName, StandardCharsets.UTF_8);
                  int domainIndex = name.indexOf('@');
                  if (domainIndex > 0) name = name.substring(0, domainIndex);
                  principal = new SimplePrincipal(name);
                  // we don't have any real way to establish trust here
                  // we just use the SASCurrent as a credential, and a custom login
                  // module can make a decision for us.
                  credential = sasCurrent;
                }
              } else {
                // the client has just sent a username and password
                final byte[] username = sasCurrent.get_incoming_username();
                final byte[] incomingPassword = sasCurrent.get_incoming_password();
                if (username.length > 0) {
                  String name = new String(username, StandardCharsets.UTF_8);
                  int domainIndex = name.indexOf('@');
                  if (domainIndex > 0) {
                    name = name.substring(0, domainIndex);
                  }
                  principal = new SimplePrincipal(name);
                  credential = new String(incomingPassword, StandardCharsets.UTF_8).toCharArray();
                }
              }

              if (securityDomain != null) {
                sc = SecurityContextFactory.createSecurityContext(securityDomain);
                sc.getUtil().createSubjectInfo(principal, credential, null);
              }
            }
            final Object[] params = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);

            if (!home && opName.equals("isIdentical") && params.length == 1) {
              // handle isIdentical specially
              Object val = params[0];
              if (val instanceof org.omg.CORBA.Object) {
                retVal = handleIsIdentical((org.omg.CORBA.Object) val);
              } else {
                retVal = false;
              }
            } else {

              if (sc != null) {
                setSecurityContextOnAssociation(sc);
              }
              try {
                final InterceptorContext interceptorContext = new InterceptorContext();

                if (sc != null) {
                  interceptorContext.putPrivateData(SecurityContext.class, sc);
                }
                prepareInterceptorContext(op, params, interceptorContext);
                retVal = componentView.invoke(interceptorContext);
              } finally {
                if (sc != null) {
                  clearSecurityContextOnAssociation();
                }
              }
            }
          } finally {
            if (tx != null) {
              if (transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION) {
                transactionManager.suspend();
              }
            }
          }
        }
        out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createReply();
        if (op.isNonVoid()) {
          op.writeRetval(out, retVal);
        }
      } catch (Exception e) {
        if (logger.isTraceEnabled()) {
          logger.trace("Exception in EJBObject invocation", e);
        }
        if (e instanceof MBeanException) {
          e = ((MBeanException) e).getTargetException();
        }
        RmiIdlUtil.rethrowIfCorbaSystemException(e);
        out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createExceptionReply();
        op.writeException(out, e);
      }
      return out;
    } finally {
      NamespaceContextSelector.popCurrentSelector();
      WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldCl);
    }
  }