/* This rule only allows GETs from 'OutboundQueue', if a password is */ /* supplied as part of the filter */ public void getMessage( String destQMgr, String destQ, MQeFields filter, MQeAttribute attr, long confirmId ) { super.getMessage( destQMgr, destQ, filter, attr, confirmId ); if (destQMgr.equals(Owner.GetName() && destQ.equals("OutboundQueue")) { if ( !(filter.Contains( "Password" ) ) { throw new MQeException( Except_Rule, "Password not supplied" ); } else { String pwd = filter.getAscii( "Password" ); if ( !(pwd.equals( "1234" )) ) { throw new MQeException( Except_Rule, "Incorrect password" ); } } } }
MQERETURN myRules_getMessage( MQeRulesGetMessage_in_ * pInput, MQeRulesGetMessage_out_ * pOutput) { MQeStringHndl hQueueManagerName, hCompareString, hCompareString2, hFieldName, hFieldValue; MQEBOOL isEqual = MQE_FALSE; MQEBOOL contains = MQE_FALSE; MQeQueueManagerHndl hQueueManager; MQERETURN rc = MQERETURN_OK; MQeExceptBlock * pExceptBlock = (MQeExceptBlock *) (pOutput->pExceptBlock); SET_EXCEPT_BLOCK_TO_DEFAULT(pExceptBlock); /* get the current queue manager */ rc = mqeQueueManager_getCurrentQueueManager(pExceptBlock, &hQueueManager); if(MQERETURN_OK == rc) { // if the destination queue manager is the local queue manager rc = mqeQueueManager_getName( hQueueManager, pExceptBlock, &hQueueManagerName ); if(MQERETURN_OK == rc) { rc = mqeString_equalTo(pInput->hQueue_QueueManagerName, pExceptBlock, &isEqual, hQueueManagerName); if(MQERETURN_OK == rc && isEqual) { // if the destination queue name is "OutboundQueue" rc = mqeString_newUtf8(pExceptBlock, &hCompareString, "OutboundQueue"); rc = mqeString_equalTo(pInput->hQueueName, pExceptBlock, &isEqual, hCompareString); if(MQERETURN_OK == rc && isEqual) { // password required for this queue MQEBOOL contains = MQE_FALSE; rc = mqeString_newUtf8(pExceptBlock, &hFieldName, "Password"); rc = mqeFields_contains(pInput->hFilter, pExceptBlock, &contains, hFieldName); if(MQERETURN_OK == rc && contains == MQE_FALSE) { SET_EXCEPT_BLOCK(pExceptBlock, MQERETURN_RULES_DISALLOWED_BY_RULE, MQEREASON_NA); } else { // parse password, etc. } } } } } }