use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class ContextManager method current.
/**
* Get the transaction for the invoking thread. If there isn't one in
* the normal thread associated data then look in the PI implementation.
*
* @return the current transaction for the invoking thread.
*/
public ControlWrapper current() throws SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextManager::current ()");
}
Object arg = otsCurrent.get(ThreadUtil.getThreadId());
ControlWrapper wrapper = null;
if (arg != null) {
try {
Stack hier = (Stack) arg;
wrapper = (ControlWrapper) hier.peek();
} catch (EmptyStackException e) {
e.printStackTrace();
}
}
if (wrapper == null) {
wrapper = currentPIContext();
try {
if (wrapper != null) {
pushAction(wrapper);
}
} catch (Throwable ex) {
jtsLogger.i18NLogger.warn_context_genfail("ContextManager.current", ex);
throw new BAD_OPERATION();
}
}
return wrapper;
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class ControlImple method destroy.
/**
* destroy should only be called for remote Control objects. Destroy them
* locally by calling DESTROY_IMPL.
*
* Since we assume that a factory will either be remote or local, we can
* destroy this object and rely upon the ORB to return an exception to
* subsequent clients which indicates they no longer have a valid reference.
*/
public synchronized void destroy() throws ActiveTransaction, ActiveThreads, BadControl, Destroyed, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("Control::destroy called for " + get_uid());
}
canDestroy();
try {
_destroyed = true;
removeControl();
if (_myControl != null) {
ORBManager.getPOA().shutdownObject(this);
_myControl = null;
}
if (_transactionHandle != null) {
// for gc
_transactionHandle.setControlHandle(null);
_transactionHandle = null;
}
tidyup();
} catch (Exception e) {
throw new BAD_OPERATION("ControlImple " + jtsLogger.i18NLogger.get_orbspecific_destroyfailed() + e);
}
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class ServerSynchronizationUnitTest method testNull.
@Test
public void testNull() throws Exception {
ServerSynchronization sync = new ServerSynchronization(null);
try {
sync.before_completion();
fail();
} catch (final BAD_OPERATION ex) {
}
try {
sync.after_completion(Status.StatusCommitted);
fail();
} catch (final BAD_OPERATION ex) {
}
}
use of org.omg.CORBA.BAD_OPERATION in project wildfly by wildfly.
the class EjbCorbaServant method invoke.
// Implementation of the interface LocalIIOPInvoker ------------------------
/**
* Receives intra-VM invocations on this servant's <code>EJBObject</code>s
* and forwards them to the bean container, through the JBoss
* <code>MBean</code>
* server.
*/
public Object invoke(String opName, Object[] arguments, Transaction tx, Principal identity, Object credential) throws Exception {
EjbLogger.ROOT_LOGGER.tracef("EJBObject local invocation: %s", opName);
SkeletonStrategy op = methodInvokerMap.get(opName);
if (op == null) {
throw new BAD_OPERATION(opName);
}
if (tx != null) {
transactionManager.resume(tx);
}
try {
final InterceptorContext interceptorContext = new InterceptorContext();
prepareInterceptorContext(op, arguments, interceptorContext);
return componentView.invoke(interceptorContext);
} finally {
if (tx != null && transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION) {
transactionManager.suspend();
}
}
}
use of org.omg.CORBA.BAD_OPERATION in project wildfly by wildfly.
the class EjbCorbaServant method _invoke.
/**
* 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) {
EjbLogger.ROOT_LOGGER.tracef("EJBObject invocation: %s", opName);
SkeletonStrategy op = methodInvokerMap.get(opName);
if (op == null) {
EjbLogger.ROOT_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);
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 {
Principal identityPrincipal = null;
Principal principal = null;
Object credential = null;
if (this.sasCurrent != null) {
final byte[] incomingIdentity = this.sasCurrent.get_incoming_principal_name();
// we have an identity token, which is a trust based mechanism
if (incomingIdentity != null && incomingIdentity.length > 0) {
String name = new String(incomingIdentity, StandardCharsets.UTF_8);
int domainIndex = name.indexOf('@');
if (domainIndex > 0)
name = name.substring(0, domainIndex);
identityPrincipal = new NamePrincipal(name);
}
final byte[] incomingUsername = this.sasCurrent.get_incoming_username();
if (incomingUsername != null && incomingUsername.length > 0) {
final byte[] incomingPassword = this.sasCurrent.get_incoming_password();
String name = new String(incomingUsername, StandardCharsets.UTF_8);
int domainIndex = name.indexOf('@');
if (domainIndex > 0) {
name = name.substring(0, domainIndex);
}
principal = new NamePrincipal(name);
credential = new String(incomingPassword, StandardCharsets.UTF_8).toCharArray();
}
}
final Object[] params = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);
if (!this.home && opName.equals("isIdentical") && params.length == 1) {
// handle isIdentical specially
Object val = params[0];
retVal = val instanceof org.omg.CORBA.Object && handleIsIdentical((org.omg.CORBA.Object) val);
} else {
if (this.securityDomain != null) {
// an elytron security domain is available: authenticate and authorize the client before invoking the component.
SecurityIdentity identity = this.securityDomain.getAnonymousSecurityIdentity();
AuthenticationConfiguration authenticationConfiguration = AuthenticationConfiguration.EMPTY;
if (identityPrincipal != null) {
// permission to run as the identity token principal.
if (principal != null) {
char[] password = (char[]) credential;
authenticationConfiguration = authenticationConfiguration.useName(principal.getName()).usePassword(password);
SecurityIdentity authenticatedIdentity = this.authenticate(principal, password);
identity = authenticatedIdentity.createRunAsIdentity(identityPrincipal.getName(), true);
} else {
// no TLS nor initial context token found - check if the anonymous identity has
// permission to run as the identity principal.
identity = this.securityDomain.getAnonymousSecurityIdentity().createRunAsIdentity(identityPrincipal.getName(), true);
}
} else if (principal != null) {
char[] password = (char[]) credential;
// we have an initial context token containing a username/password pair.
authenticationConfiguration = authenticationConfiguration.useName(principal.getName()).usePassword(password);
identity = this.authenticate(principal, password);
}
final InterceptorContext interceptorContext = new InterceptorContext();
this.prepareInterceptorContext(op, params, interceptorContext);
try {
final AuthenticationContext context = AuthenticationContext.captureCurrent().with(MatchRule.ALL.matchProtocol("iiop"), authenticationConfiguration);
retVal = identity.runAs((PrivilegedExceptionAction<Object>) () -> context.run((PrivilegedExceptionAction<Object>) () -> this.componentView.invoke(interceptorContext)));
} catch (PrivilegedActionException e) {
throw e.getCause();
}
} else {
// legacy security behavior: setup the security context if a SASCurrent is available and invoke the component.
// One of the EJB security interceptors will authenticate and authorize the client.
final InterceptorContext interceptorContext = new InterceptorContext();
prepareInterceptorContext(op, params, interceptorContext);
retVal = this.componentView.invoke(interceptorContext);
}
}
}
out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createReply();
if (op.isNonVoid()) {
op.writeRetval(out, retVal);
}
} catch (Throwable e) {
EjbLogger.ROOT_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);
}
}
Aggregations