diff -r 000000000000 -r 95b198f216e5 omadrm/drmengine/roap/src/JoinDomainReq.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omadrm/drmengine/roap/src/JoinDomainReq.cpp Thu Dec 17 08:52:27 2009 +0200 @@ -0,0 +1,224 @@ +/* +* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include "base64.h" +#include "JoinDomainReq.h" +#include "RoapDef.h" + +using namespace Roap; + +// LOCAL CONSTANTS AND MACROS +_LIT8(KReqHeader, ""); +_LIT8(KReqNonce, ""); +_LIT8(KReqNonceEnd, ""); +_LIT8(KReqTime, ""); +_LIT8(KReqDeviceId, ""); +_LIT8(KReqDeviceIdEnd, ""); +_LIT8(KReqRiId, ""); +_LIT8(KReqRiIdEnd, ""); +_LIT8(KReqDomainId, ""); +_LIT8(KReqDomainIdEnd, ""); +_LIT8(KReqCertChain, ""); +_LIT8(KReqCert, ""); +_LIT8(KReqCertEnd, ""); +_LIT8(KReqCertChainEnd, ""); +_LIT8(KReqExtensions, ""); +_LIT8(KReqExtensionsEnd, ""); +_LIT8(KReqPeerKey, "\ +"); +_LIT8(KReqPeerKeyEnd, ""); +_LIT8(KReqNoOcspResponse, ""); +_LIT8(KReqOcspResponderKeyId, "\ +"); +_LIT8(KReqOcspResponderKeyIdEnd, ""); +_LIT8(KReqHashChainSupport, ""); +_LIT8(KReqSig, ""); +_LIT8(KReqSigEnd, ""); + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CJoinDomainReq::CJoinDomainReq +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CJoinDomainReq::CJoinDomainReq(): + iDomainId(NULL), + iOcspResponderKeyId(NULL), + iSignature(NULL), + iTriggerNonce(NULL) + { + } + +// ----------------------------------------------------------------------------- +// CJoinDomainReq::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CJoinDomainReq::ConstructL() + { + iTime.UniversalTime(); + iPeerKeyIdentifier.SetLength(0); + iOcspInfoStored = EFalse; + iHashChainSupport = ETrue; + } + +// ----------------------------------------------------------------------------- +// CJoinDomainReq::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CJoinDomainReq* CJoinDomainReq::NewL() + { + CJoinDomainReq* self = new( ELeave ) CJoinDomainReq; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + + +// Destructor +CJoinDomainReq::~CJoinDomainReq() + { + iCertificateChain.ResetAndDestroy(); + delete iDomainId; + delete iSignature; + delete iTriggerNonce; + delete iOcspResponderKeyId; + } + + +// ----------------------------------------------------------------------------- +// CJoinDomainReq::?member_function +// ?implementation_description +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +HBufC8* CJoinDomainReq::MessageAsXmlL(void) + { + HBufC8* r = NULL; + CBufFlat* b = NULL; + TInt i; + + b = CBufFlat::NewL(128); + CleanupStack::PushL(b); + BufAppendL(b, KReqHeader); + if (iTriggerNonce) + { + BufAppendL(b, KReqNonceTrigger); + BufAppendL(b, *iTriggerNonce); + BufAppendL(b, KReqNonceTriggerEnd); + } + BufAppendL(b, KReqHeaderEnd); + + BufAppendL(b, KReqDeviceId); + BufAppendBase64L(b, iDeviceId); + BufAppendL(b, KReqDeviceIdEnd); + + BufAppendL(b, KReqRiId); + BufAppendBase64L(b, iRiId); + BufAppendL(b, KReqRiIdEnd); + + BufAppendL(b, KReqNonce); + BufAppendBase64L(b, iNonce); + BufAppendL(b, KReqNonceEnd); + + BufAppendL(b, KReqTime); + BufAppendTimeL(b, iTime); + BufAppendL(b, KReqTimeEnd); + + BufAppendL(b, KReqDomainId); + BufAppendL(b, *iDomainId); + BufAppendL(b, KReqDomainIdEnd); + + if (iCertificateChain.Count() > 0) + { + BufAppendL(b, KReqCertChain); + for (i = 0; i < iCertificateChain.Count(); i++) + { + BufAppendL(b, KReqCert); + BufAppendBase64L(b, *iCertificateChain[i]); + BufAppendL(b, KReqCertEnd); + } + BufAppendL(b, KReqCertChainEnd); + } + + if (iPeerKeyIdentifier.Length() || + iOcspResponderKeyId || + iOcspInfoStored || + iHashChainSupport) + { + BufAppendL(b, KReqExtensions); + } + + if (iPeerKeyIdentifier.Length()) + { + BufAppendL(b, KReqPeerKey); + BufAppendBase64L(b, iPeerKeyIdentifier); + BufAppendL(b, KReqPeerKeyEnd); + } + + if (iOcspInfoStored) + { + BufAppendL(b, KReqNoOcspResponse); + } + + if (iOcspResponderKeyId) + { + BufAppendL(b, KReqOcspResponderKeyId); + BufAppendBase64L(b, *iOcspResponderKeyId); + BufAppendL(b, KReqOcspResponderKeyIdEnd); + } + + if (iHashChainSupport) + { + BufAppendL(b, KReqHashChainSupport); + } + + if (iPeerKeyIdentifier.Length() || + iOcspResponderKeyId || + iOcspInfoStored || + iHashChainSupport) + { + BufAppendL(b, KReqExtensionsEnd); + } + + BufAppendL(b, KReqSig); + BufAppendL(b, KReqSigEnd); + + r = b->Ptr(0).AllocL(); + CleanupStack::PopAndDestroy(b); + return r; + }