EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername,
                                    const TDesC8& aPassword,
                                    HBufC8*& aToken)
    {
    TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
    aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() +
                            KUsernameFmt().Length() +
                            KUsernameTokenEndTag().Length() +
                            KPasswordStartTagDefaultFmt().Length() +
                            KPasswordEndTagFmt().Length() +
                            aPassword.Length() +
                            aUsername.Length() + 
                            nsPrefix.Length() * 6 );

    TPtr8 ptr = aToken->Des();
//    ptr.Format(KNameTokenFormat, &nsPrefix, &nsPrefix, &aUsername, &nsPrefix, &nsPrefix);
    ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix);
    ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix);
    ptr.AppendFormat(KPasswordStartTagDefaultFmt, 
                     &nsPrefix, &aPassword); // no Type -attribute used
    ptr.AppendFormat(KPasswordEndTagFmt, &nsPrefix);
    ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix);
    CleanupStack::Pop();    // aToken
    return KErrNone;
    }
EXPORT_C TInt CSenWsSecurityHeader::BinarySecurityTokenL(const TDesC8& aContent, HBufC8*& aToken)
    {
    TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
    aToken = HBufC8::NewLC( KBinarySecurityTokenFmt().Length() +
                            aContent.Length() +
                            nsPrefix.Length() * 2 );

    TPtr8 ptr = aToken->Des();
    ptr.Format(KBinarySecurityTokenFmt, &nsPrefix, &aContent, &nsPrefix);
    CleanupStack::Pop();    // aToken
    return KErrNone;
    }
예제 #3
0
// ==========================================================================
// METHOD:  HexDump
//
// DESIGN:  
// ==========================================================================
void CLogFileHandler::HexDump( const TDesC8& /*aClassName*/,
                               const TDesC8& /*aFuncName*/,
                               const TDesC8& aBuffer )
    {
	TInt remainingLength = aBuffer.Length();
	TInt i = 0;
	
	while( remainingLength > 0 )
		{
        const TInt KHexDumpWidth=32;
		TInt n = Min( KHexDumpWidth, remainingLength );
		
		// Add the starting byte number.
        _LIT8(KFirstFormatString,"%04x : ");
		iFormatBuffer8.Format(KFirstFormatString, i);
		
		// Add hex values.
		TInt j;
		for (j=0; j<n; j++)
		    {		    
            _LIT8(KSecondFormatString,"%02x ");
			iFormatBuffer8.AppendFormat(KSecondFormatString, aBuffer[i+j]);
		    } // end for
			
        // Fill in incomplete lines.			
		while (j<KHexDumpWidth)
		    {		    
            _LIT8(KThreeSpaces,"   ");
			iFormatBuffer8.Append(KThreeSpaces);
			j++;
		    } // end while
		    
		// Add text representation.
        _LIT8(KTwoSpaces," ");
		iFormatBuffer8.Append(KTwoSpaces);
		for (j=0; j<n; j++)
		    {		    
            _LIT8(KThirdFormatString,"%c");
			iFormatBuffer8.AppendFormat( KThirdFormatString, aBuffer[i+j] );
		    } // end for
		
		iOutputBuffer.SetLength( 0 );		
		TRAP_IGNORE( WriteLineL( iFormatBuffer8 ) );
		
		remainingLength -= n;
		i += n;
		
		} // end while
		    
    } // END HexDump
예제 #4
0
/**
CPplContactsFile ConstructL.
*/	
void CPplContactsFile::ConstructL()
	{
	iItemManager = CPplContactItemManager::NewL(iDatabase, *this, iContactProperties, iIccContactStore);
	iContactProperties.SetContactItemManagerL(*iItemManager);
	
	iConfigureStr = NULL;
	if(KContactsModelSqliteDbCacheSize > 0)
		{
		//Create configure string to be used when creating/opening database
		iConfigureStr = HBufC8::NewL(KSqliteCacheSize().Length() + KCacheDataSize);
		TPtr8 ptrConfigureStr = iConfigureStr->Des();
		ptrConfigureStr.Format(KSqliteCacheSize(), KContactsModelSqliteDbCacheSize);
		}
	}
EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername, HBufC8*& aToken)
    {
    TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
    aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() +
                            KUsernameFmt().Length() +
                            KUsernameTokenEndTag().Length() +
                            aUsername.Length() + 
                            nsPrefix.Length() * 4 );

    TPtr8 ptr = aToken->Des();
    ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix);
    ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix);
    ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix);
    CleanupStack::Pop();    // aToken
    return KErrNone;
    }
예제 #6
0
// -----------------------------------------------------------------------------
// CSeiForwardPlugin::ReceiveMessageL
// 
// 
// -----------------------------------------------------------------------------
//
void CSeiForwardPlugin::ReceiveMessageL( TInt aChannel, TPtrC8 aMessage )
	{
	RDebug::Print( _L( "EcmtSeiForwardPlugin::ReceiveMessageL: channel = %d" ), aChannel );
	
	HBufC8* buf = HBufC8::NewLC( KMaxMsgPrefixLen + 1 + aMessage.Length() );
	TPtr8 message = buf->Des();
		
	message.Format( KMsg, aChannel );
	message.Append( KBlanco );
	message.Append( aMessage );
		
	CEcmtMessageEvent* m = iMessaging->NewMessageEvent( TUid::Uid( KSEIFORWARDPLUGIN_IMPL_UID ), message );
	
	User::LeaveIfNull( m );
	iMessaging->GetMessageSender()->SendMessage( m );
	}
예제 #7
0
/**
CPplContactsFile ConstructL.
*/
void CPplContactsFile::ConstructL()
{
    // Do this first since the contacts table created by the
    // iItemManager will need to know if the directory exists.
    TRAP_IGNORE(TCntImageRescaleUtility::CreateImageDirectoryL());

    iItemManager = CPplContactItemManager::NewL(iDatabase, *this, iContactProperties, iIccContactStore);
    iContactProperties.SetContactItemManagerL(*iItemManager);

    iConfigureStr = NULL;
    if(KContactsModelSqliteDbCacheSize > 0)
    {
        //Create configure string to be used when creating/opening database
        iConfigureStr = HBufC8::NewL(KSqliteCacheSize().Length() + KCacheDataSize);
        TPtr8 ptrConfigureStr = iConfigureStr->Des();
        ptrConfigureStr.Format(KSqliteCacheSize(), KContactsModelSqliteDbCacheSize);
    }
}
EXPORT_C TInt CSenWsSecurityHeader::TimestampL(const TDesC8& aCreated, HBufC8*& aToken)
    {
    TPtrC8 nsPrefix = KSecurityUtilityXmlNsPrefix();
    aToken = HBufC8::NewLC(KTimestampFormatString8().Length()
                            + aCreated.Length() 
                            + nsPrefix.Length()*5
                            + KSecurityUtilityXmlNs().Length());

    TPtr8 ptr = aToken->Des();
    ptr.Format(KTimestampFormatString8, 
               &nsPrefix, 
               &nsPrefix, 
               &KSecurityUtilityXmlNs(),
               &nsPrefix, 
               &aCreated,
               &nsPrefix, 
               &nsPrefix);
    CleanupStack::Pop(aToken);
    return KErrNone;
    }
EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername,
                                    const TDesC8& aPassword,
                                    CSenWsSecurityHeader::TPasswordType aType,
                                    HBufC8*& aToken)
    {
    switch(aType)
        {
        case EText:
            {
            return UsernameTokenL(aUsername, aPassword, aToken);
            }
        case EDigest:
            {
            TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
            TPtrC8 typeAttr(KSecurityAttrTypeDigest);

            aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() +
                                    KUsernameFmt().Length() +
                                    KUsernameTokenEndTag().Length() +
                                    KPasswordStartTagTypeFmt().Length() +
                                    KPasswordEndTagFmt().Length() +
                                    aUsername.Length() + 
                                    aPassword.Length() +
                                    typeAttr.Length() +
                                    nsPrefix.Length() * 7 );
            TPtr8 ptr = aToken->Des();
            ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix);
            ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix);
            ptr.AppendFormat(KPasswordStartTagTypeFmt, &nsPrefix, &nsPrefix, 
                             &typeAttr, &aPassword); // Type = wsse:PasswordDigest
            ptr.AppendFormat(KPasswordEndTagFmt, &nsPrefix);
            ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix);
            CleanupStack::Pop();    // aToken
            return KErrNone;
            }
        default:
            {
            return KErrNotSupported;
            }
        }
    }
/**
This method is a callback that sends data container reference
@param				aContainer Container encapsulating binary data
@param				aErrorCode is the error code.
					If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnDataContainerL(const TXmlEngDataContainer& aContainer, TInt aErrorCode)
{
	_LIT8(KOnContentFuncName,"OnDataContainer()\r\n");
	_LIT8(KInfoOnContent,"\tData container CID: %S \r\n");
	_LIT8(KInfoOnError,"Error occurs %d \r\n");
	
	HBufC8* info = HBufC8::NewL(aContainer.Cid().Size() + 50);
	TPtr8 infoPtr = info->Des();

	iLog.Write(KOnContentFuncName);

	if (aErrorCode == KErrNone)
	{   TPtrC8 cid = aContainer.Cid();
		infoPtr.Format(KInfoOnContent, &cid);
		iLog.Write(infoPtr);
	}
	else
	{
		TBuf8<KShortInfoSize> info;
		info.Format(KInfoOnError,aErrorCode);
		iLog.Write(info);
	}
	delete info;	
}
/**
This method is a callback that sends the binary content of the element.
@param				aBytes is the raw binary content data for the element. 
@param				aErrorCode is the error code.
					If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnBinaryContentL(const TDesC8& aBytes, const TDesC8& aCid, TInt aErrorCode)
{
/*
	//use this part of the code if you want to save binary data to MSWord format
	RFs fs;
	CleanupClosePushL(fs);
	User::LeaveIfError(fs.Connect());
	RFile f;
	CleanupClosePushL(f);
	TInt err = f.Replace(fs, _L("c:\\xmlengine\\deserializer\\output\\bin.doc"), EFileWrite);
	err = f.Write(aBytes);
	CleanupStack::PopAndDestroy(2); //f fs
*/
	aCid.Size(); // eliminate compilation warning
	_LIT8(KOnContentFuncName,"OnBinaryContent()\r\n");
	_LIT8(KInfoOnContent,"\tBinary content of element: %S \r\n");
	_LIT8(KInfoOnError,"Error occurs %d \r\n");
	
	HBufC8* info = HBufC8::NewL(aBytes.Size() + 50);
	TPtr8 infoPtr = info->Des();

	iLog.Write(KOnContentFuncName);

	if (aErrorCode == KErrNone)
	{
		infoPtr.Format(KInfoOnContent, &aBytes);
		iLog.Write(infoPtr);
	}
	else
	{
		TBuf8<KShortInfoSize> info;
		info.Format(KInfoOnError,aErrorCode);
		iLog.Write(info);
	}
	delete info;
}
TInt CTestHostlet::ServiceL(MSenHostletRequest& aRequest, MSenHostletResponse& aResponse)
    {
    

    iTxnIds.Append(aRequest.RequestId());
    iResponseCodes.Append(KErrNone);
    

    	
    TInt retVal(KErrNone);
    // Setup default response, can be overridden by test case:
    // Dummy response
    TPtrC8 request = aRequest.RequestUtf8();


    iRequests.Append(request.AllocL());
    
    MSenProperties::TSenPropertiesClassType propType;
    TPtrC8 requestProperties = aRequest.Properties(propType);
    iRequestProps.Append(requestProperties.AllocL());
    iRequestPropTypes.Append(propType);
    
//    _LIT8(KResponseFmt, "<Response><ReplyMessage>CSenHostletConnectionBCTest is alive.</ReplyMessage><Request>%S</Request></Response>");
  	_LIT8(KResponseFmt, "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Header></S:Header><S:Body>testing text hostlet</S:Body></S:Envelope>");  
    HBufC8* pResponse = HBufC8::NewLC(request.Length()+KResponseFmt().Length());
    TInt appendError = iResponses.Append(pResponse);
    if( appendError )
        {
        CleanupStack::PopAndDestroy(pResponse); // delete orphan HBufC8 / pResponse
        }
    else
        {
        CleanupStack::Pop(pResponse); // now owned by iResponses -array..
        }        
    
    TPtr8 response = iResponses[iTxnIds.Count()-1]->Des();
    response.Format(KResponseFmt, &request);
    aResponse.SetResponseUtf8L(response, iResponseCodes[iTxnIds.Count()-1]); // by default, all requests are "accepted"
      
    if ( ip2ServiceL )
        {
        // NOTE(!): if RESPONSE CODE in aResponse is modified in YOUR test case,
        // remember set iResponseCodes for this test hostlet instance in your test
        //  case code (ServiceL callback)
        retVal = (*ip2ServiceL)(ipTestSuite, aRequest, aResponse); 
        }
    TPtrC8 providedResponse = aResponse.ResponseUtf8();
    
    if ( iResponses[iTxnIds.Count()-1]->Compare(providedResponse) != 0 )
        {
        // response was altered by TEST CASE:
        iResponses.Insert(aResponse.ResponseUtf8().AllocL(),iTxnIds.Count()-1);
        }
        
        
    RDebug::Print(_L("CTestHostlet::ServiceL received:"));
    RDebug::RawPrint(request);
    if (ipTestSuite->ipUsedHostletConnection)
    {
    	iRespondRetCode = ipTestSuite->ipUsedHostletConnection->RespondL(aResponse); 
    }
    else
		iRespondRetCode = ipTestSuite->ipHostletConnection->RespondL(aResponse); 
   return retVal;
    }