Search in sources :

Example 1 with NO_PERMISSION

use of org.omg.CORBA.NO_PERMISSION in project narayana by jbosstm.

the class ArjunaTransactionImple method rollback.

public void rollback() throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::rollback for " + get_uid());
    }
    if (ArjunaTransactionImple._checkedTransactions && !checkAccess()) {
        throw new NO_PERMISSION(0, CompletionStatus.COMPLETED_NO);
    }
    int status = super.status();
    if ((status == ActionStatus.RUNNING) || // already aborted?
    (status == ActionStatus.ABORT_ONLY)) {
        if (ArjunaTransactionImple._syncOn) {
            if (TxControl.isBeforeCompletionWhenRollbackOnly()) {
                try {
                    if (_synchs != null)
                        doBeforeCompletion();
                } catch (Exception e) {
                /*
                           * Don't do anything - we're about to rollback anyway!
                           */
                }
            }
        } else {
            /*
                     * If we have any synchronizations delete them now. Can only be
                     * a top-level action.
                     */
            _synchs = null;
        }
        if (parentTransaction != null) {
            parentTransaction.removeChildAction(this);
        }
        super.Abort();
        if (ArjunaTransactionImple._syncOn) {
            try {
                if (_synchs != null) {
                    currentStatus = determineStatus(this);
                    doAfterCompletion(currentStatus);
                }
            } catch (Exception e) {
            }
        }
        destroyAction();
        status = super.status();
    } else if ((status == ActionStatus.ABORTING) || (status == ActionStatus.ABORTED) || (status == ActionStatus.H_ROLLBACK)) {
        if (jtsLogger.logger.isInfoEnabled()) {
            jtsLogger.i18NLogger.info_rollback_aborted_transaction(get_transaction_name());
        }
        return;
    } else {
        // means
        throw new INVALID_TRANSACTION(0, CompletionStatus.COMPLETED_NO);
    // transaction
    // already
    // terminated.
    }
    switch(status) {
        case ActionStatus.ABORTING:
        case ActionStatus.ABORTED:
        case ActionStatus.H_ROLLBACK:
            /*
			 * If the transaction has already rolledback then silently ignore
			 * the multiple rollback attempts.
			 */
            return;
        // shouldn't be able to get heuristics or
        case ActionStatus.PREPARING:
        // any of these!
        case ActionStatus.PREPARED:
        case ActionStatus.COMMITTING:
        case ActionStatus.COMMITTED:
        case ActionStatus.H_COMMIT:
        case ActionStatus.H_MIXED:
        case ActionStatus.H_HAZARD:
            // means
            throw new INVALID_TRANSACTION(0, CompletionStatus.COMPLETED_NO);
        // terminated.
        case ActionStatus.INVALID:
        case ActionStatus.CLEANUP:
            throw new UNKNOWN(ExceptionCodes.UNKNOWN_EXCEPTION, CompletionStatus.COMPLETED_MAYBE);
    }
}
Also used : NO_PERMISSION(org.omg.CORBA.NO_PERMISSION) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) UNKNOWN(org.omg.CORBA.UNKNOWN) SystemException(org.omg.CORBA.SystemException)

Example 2 with NO_PERMISSION

use of org.omg.CORBA.NO_PERMISSION in project Payara by payara.

the class POAProtocolMgr method mapException.

/**
 * Map the EJB/RMI exception to a protocol-specific (e.g. CORBA) exception
 */
@Override
public Throwable mapException(Throwable exception) {
    boolean initCause = true;
    Throwable mappedException = exception;
    if (exception instanceof java.rmi.NoSuchObjectException || exception instanceof NoSuchObjectLocalException) {
        mappedException = new OBJECT_NOT_EXIST(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else if (exception instanceof java.rmi.AccessException || exception instanceof javax.ejb.AccessLocalException) {
        mappedException = new NO_PERMISSION(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else if (exception instanceof java.rmi.MarshalException) {
        mappedException = new MARSHAL(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else if (exception instanceof javax.transaction.TransactionRolledbackException || exception instanceof TransactionRolledbackLocalException) {
        mappedException = new TRANSACTION_ROLLEDBACK(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else if (exception instanceof javax.transaction.TransactionRequiredException || exception instanceof TransactionRequiredLocalException) {
        mappedException = new TRANSACTION_REQUIRED(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else if (exception instanceof javax.transaction.InvalidTransactionException) {
        mappedException = new INVALID_TRANSACTION(MAPEXCEPTION_CODE, CompletionStatus.COMPLETED_MAYBE);
    } else {
        initCause = false;
    }
    if (initCause) {
        mappedException.initCause(exception);
    }
    return mappedException;
}
Also used : NO_PERMISSION(org.omg.CORBA.NO_PERMISSION) TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) MARSHAL(org.omg.CORBA.MARSHAL) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) TRANSACTION_REQUIRED(org.omg.CORBA.TRANSACTION_REQUIRED) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) TransactionRequiredLocalException(javax.ejb.TransactionRequiredLocalException)

Example 3 with NO_PERMISSION

use of org.omg.CORBA.NO_PERMISSION in project Payara by payara.

the class Counter method receive_request.

@Override
public void receive_request(ServerRequestInfo serverRequestInfo) throws ForwardRequest {
    // SecurityContext to be sent
    SecurityContext securityContext = null;
    // service context
    ServiceContext serviceContext = null;
    int status = 0;
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "++++ Entered " + prname + "receive_request");
    }
    ORB orb = orbHelper.getORB();
    try {
        serviceContext = serverRequestInfo.get_request_service_context(SECURITY_ATTRIBUTE_SERVICE_ID);
        if (serviceContext == null) {
            handle_null_service_context(serverRequestInfo, orb);
            return;
        }
    } catch (BAD_PARAM e) {
        handle_null_service_context(serverRequestInfo, orb);
        return;
    }
    if (logger.isLoggable(FINE)) {
        logger.log(FINE, "Received a non null SAS context element");
    }
    // Decode the service context field
    Any SasAny;
    try {
        SasAny = codec.decode_value(serviceContext.context_data, SASContextBodyHelper.type());
    } catch (Exception e) {
        logger.log(SEVERE, "iiop.decode_exception", e);
        throw new SecurityException(localStrings.getLocalString("secserverreqinterceptor.err_cdr_decode", "CDR Decoding error for SAS context element."));
    }
    if (logger.isLoggable(FINE)) {
        logger.log(FINE, "Successfully decoded CDR encoded SAS context element.");
    }
    SASContextBody sasctxbody = SASContextBodyHelper.extract(SasAny);
    short sasdiscr = sasctxbody.discriminator();
    if (logger.isLoggable(FINE)) {
        logger.log(FINE, "SAS context element is a/an " + SvcContextUtils.getMsgname(sasdiscr) + " message");
    }
    if (sasdiscr == MTMessageInContext.value) {
        sasctxbody = createContextError(SvcContextUtils.MessageInContextMinor);
        serviceContext = createSvcContext(sasctxbody, orb);
        if (logger.isLoggable(FINE)) {
            logger.log(FINE, "Adding ContextError message to service context list");
            logger.log(FINE, "SecurityContext set to null");
        }
        serverRequestInfo.add_reply_service_context(serviceContext, NO_REPLACE);
        throw new NO_PERMISSION();
    }
    if (sasdiscr != MTEstablishContext.value) {
        logger.log(SEVERE, "iiop.not_establishcontext_msg");
        throw new SecurityException(localStrings.getLocalString("secserverreqinterceptor.err_not_ec_msg", "Received message not an EstablishContext message."));
    }
    EstablishContext establishContext = sasctxbody.establish_msg();
    securityContext = new SecurityContext();
    securityContext.subject = new Subject();
    try {
        if (establishContext.client_authentication_token.length != 0) {
            if (logger.isLoggable(FINE)) {
                logger.log(FINE, "Message contains Client Authentication Token");
            }
            createAuthCredential(securityContext, establishContext.client_authentication_token, orb);
        }
    } catch (Exception e) {
        logger.log(SEVERE, "iiop.authentication_exception", e);
        throw new SecurityException(localStrings.getLocalString("secsercverreqinterceptor.err_cred_create", "Error while creating a JAAS subject credential."));
    }
    try {
        if (establishContext.identity_token != null) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "Message contains an Identity Token");
            }
            createIdCred(securityContext, establishContext.identity_token);
        }
    } catch (SecurityException secex) {
        logger.log(SEVERE, "iiop.security_exception", secex);
        sasctxbody = createContextError(INVALID_MECHANISM_MAJOR, INVALID_MECHANISM_MINOR);
        serviceContext = createSvcContext(sasctxbody, orb);
        serverRequestInfo.add_reply_service_context(serviceContext, NO_REPLACE);
        throw new NO_PERMISSION();
    } catch (Exception e) {
        logger.log(SEVERE, "iiop.generic_exception", e);
        throw new SecurityException(localStrings.getLocalString("secsercverreqinterceptor.err_cred_create", "Error while creating a JAAS subject credential."));
    }
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "Invoking setSecurityContext() to set security context");
    }
    status = secContextUtil.setSecurityContext(securityContext, serverRequestInfo.object_id(), serverRequestInfo.operation(), getServerSocket());
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "setSecurityContext() returned status code " + status);
    }
    /**
     * CSIV2 SPEC NOTE:
     *
     * If ec.client_context_id is non zero, then this is a stateful request. As specified in section
     * 4.2.1, a stateless server must attempt to validate the security tokens in the security context
     * field. If validation succeeds then CompleteEstablishContext message is sent back. If validation
     * fails, a ContextError must be sent back.
     */
    if (status == STATUS_FAILED) {
        if (logger.isLoggable(FINE)) {
            logger.log(FINE, "setSecurityContext() returned STATUS_FAILED");
        }
        sasctxbody = createContextError(status);
        serviceContext = createSvcContext(sasctxbody, orb);
        if (logger.isLoggable(FINE)) {
            logger.log(FINE, "Adding ContextError message to service context list");
        }
        serverRequestInfo.add_reply_service_context(serviceContext, NO_REPLACE);
        throw new NO_PERMISSION();
    }
    if (logger.isLoggable(FINE)) {
        logger.log(FINE, "setSecurityContext() returned SUCCESS");
    }
    sasctxbody = createCompleteEstablishContext(status);
    serviceContext = createSvcContext(sasctxbody, orb);
    if (logger.isLoggable(FINE)) {
        logger.log(FINE, "Adding CompleteEstablisContext message to service context list");
    }
    serverRequestInfo.add_reply_service_context(serviceContext, NO_REPLACE);
}
Also used : NO_PERMISSION(org.omg.CORBA.NO_PERMISSION) ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(com.sun.corba.ee.org.omg.CSI.SASContextBody) Any(org.omg.CORBA.Any) Subject(javax.security.auth.Subject) SecurityContext(com.sun.enterprise.common.iiop.security.SecurityContext) CompleteEstablishContext(com.sun.corba.ee.org.omg.CSI.CompleteEstablishContext) MTEstablishContext(com.sun.corba.ee.org.omg.CSI.MTEstablishContext) EstablishContext(com.sun.corba.ee.org.omg.CSI.EstablishContext) ORB(org.omg.CORBA.ORB)

Example 4 with NO_PERMISSION

use of org.omg.CORBA.NO_PERMISSION in project Payara by payara.

the class Counter method handle_null_service_context.

private void handle_null_service_context(ServerRequestInfo serverRequestInfo, ORB orb) {
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "No SAS context element found in service context list for operation: " + serverRequestInfo.operation());
    }
    ServiceContext serviceContext = null;
    int secStatus = secContextUtil.setSecurityContext(null, serverRequestInfo.object_id(), serverRequestInfo.operation(), getServerSocket());
    if (secStatus == STATUS_FAILED) {
        SASContextBody sasctxbody = createContextError(INVALID_MECHANISM_MAJOR, INVALID_MECHANISM_MINOR);
        serviceContext = createSvcContext(sasctxbody, orb);
        serverRequestInfo.add_reply_service_context(serviceContext, NO_REPLACE);
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "SecServerRequestInterceptor.receive_request: NO_PERMISSION");
        }
        throw new NO_PERMISSION();
    }
}
Also used : NO_PERMISSION(org.omg.CORBA.NO_PERMISSION) ServiceContext(org.omg.IOP.ServiceContext) SASContextBody(com.sun.corba.ee.org.omg.CSI.SASContextBody)

Example 5 with NO_PERMISSION

use of org.omg.CORBA.NO_PERMISSION in project narayana by jbosstm.

the class ArjunaTransactionImple method commit.

/**
 * If the transaction has already been committed (by another thread, for
 * example) then we do nothing - could throw TransactionRequired or
 * INVALID_TRANSACTION. However, if it was rolledback then we throw
 * TRANSACTION_ROLLEDBACK. Seems like an inconsistency.
 *
 * OTS is vague as to what to do if the transaction has been terminated,
 * so we make a sensible choice.
 *
 * report_heuristics is ignored if we are a subtransaction.
 */
public void commit(boolean report_heuristics) throws HeuristicMixed, HeuristicHazard, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::commit for " + get_uid());
    }
    if (ArjunaTransactionImple._checkedTransactions && !checkAccess()) {
        throw new NO_PERMISSION(0, CompletionStatus.COMPLETED_NO);
    }
    int outcome = super.status();
    if ((outcome == ActionStatus.RUNNING) || // have we already been
    (outcome == ActionStatus.ABORT_ONLY)) // committed?
    {
        try {
            if (_synchs != null) {
                if (outcome == ActionStatus.RUNNING || (outcome == ActionStatus.ABORT_ONLY && TxControl.isBeforeCompletionWhenRollbackOnly())) {
                    doBeforeCompletion();
                }
            }
        } catch (Exception e) {
        /*
				 * Don't do anything, since we will have marked the transaction
				 * as rollback only.
				 */
        }
        if (parentTransaction != null) {
            parentTransaction.removeChildAction(this);
        }
        outcome = super.End(report_heuristics);
        try {
            if (_synchs != null) {
                currentStatus = determineStatus(this);
                doAfterCompletion(currentStatus);
                _synchs = null;
            }
        } catch (Exception e) {
        }
        destroyAction();
    } else if (outcome == ActionStatus.ABORTED || outcome == ActionStatus.H_ROLLBACK) {
        throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.FAILED_TO_COMMIT, CompletionStatus.COMPLETED_NO);
    } else {
        throw new INVALID_TRANSACTION(0, CompletionStatus.COMPLETED_NO);
    }
    switch(outcome) {
        case ActionStatus.COMMITTED:
        case ActionStatus.H_COMMIT:
        case // in case asynchronous commit!
        ActionStatus.COMMITTING:
            return;
        case ActionStatus.ABORTED:
        // in case of asynchronous abort!
        case ActionStatus.ABORTING:
        case ActionStatus.H_ROLLBACK:
            throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.FAILED_TO_COMMIT, CompletionStatus.COMPLETED_NO);
        case ActionStatus.H_MIXED:
            if (report_heuristics)
                throw new HeuristicMixed();
            break;
        case ActionStatus.H_HAZARD:
        default:
            if (report_heuristics)
                throw new HeuristicHazard();
            break;
    }
}
Also used : NO_PERMISSION(org.omg.CORBA.NO_PERMISSION) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) SystemException(org.omg.CORBA.SystemException) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Aggregations

NO_PERMISSION (org.omg.CORBA.NO_PERMISSION)5 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 SASContextBody (com.sun.corba.ee.org.omg.CSI.SASContextBody)2 SystemException (org.omg.CORBA.SystemException)2 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)2 ServiceContext (org.omg.IOP.ServiceContext)2 CompleteEstablishContext (com.sun.corba.ee.org.omg.CSI.CompleteEstablishContext)1 EstablishContext (com.sun.corba.ee.org.omg.CSI.EstablishContext)1 MTEstablishContext (com.sun.corba.ee.org.omg.CSI.MTEstablishContext)1 SecurityContext (com.sun.enterprise.common.iiop.security.SecurityContext)1 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)1 TransactionRequiredLocalException (javax.ejb.TransactionRequiredLocalException)1 TransactionRolledbackLocalException (javax.ejb.TransactionRolledbackLocalException)1 Subject (javax.security.auth.Subject)1 Any (org.omg.CORBA.Any)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 MARSHAL (org.omg.CORBA.MARSHAL)1 OBJECT_NOT_EXIST (org.omg.CORBA.OBJECT_NOT_EXIST)1 ORB (org.omg.CORBA.ORB)1 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)1