|
1 /* |
|
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: implementation of CDmAdPKCS12 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "dmadutil.h" |
|
21 #include "dmadstorepkcs12.h" |
|
22 #include "vpnlogger.h" |
|
23 #include "dmadcertxmldefs.h" |
|
24 #include "XppImpl.h" |
|
25 #include "XwImpl.h" |
|
26 #include "pkcs12vpn.h" |
|
27 |
|
28 #include <vpnlogmessages.rsg> |
|
29 |
|
30 CDmAdPKCS12* CDmAdPKCS12::NewL(RPKIServiceAPI& aPkiServiceApi) |
|
31 { |
|
32 TRACE("CDmAdPKCS12::NewL"); |
|
33 |
|
34 CDmAdPKCS12* self = NewLC(aPkiServiceApi); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CDmAdPKCS12* CDmAdPKCS12::NewLC(RPKIServiceAPI& aPkiServiceApi) |
|
40 { |
|
41 CDmAdPKCS12* self = new (ELeave) CDmAdPKCS12(aPkiServiceApi); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 void CDmAdPKCS12::ConstructL() |
|
48 { |
|
49 TRACE("CDmAdPKCS12::ConstructL"); |
|
50 } |
|
51 |
|
52 CDmAdPKCS12::CDmAdPKCS12(RPKIServiceAPI& aPkiServiceApi) : iPkiServiceApi(&aPkiServiceApi) |
|
53 { |
|
54 } |
|
55 |
|
56 CDmAdPKCS12::~CDmAdPKCS12() |
|
57 { |
|
58 TRACE("CDmAdPKCS12::~CDmAdPKCS12"); |
|
59 } |
|
60 |
|
61 HBufC8* CDmAdPKCS12::AddL(const CDmAdPKCS12Parms& aParms) |
|
62 { |
|
63 TRACE("CDmAdPKCS12::AddL"); |
|
64 |
|
65 DEBUG_LOG(_L("Instantiating pkcs12handler")); |
|
66 CPKCS12Handler* pkcs12handler = CPKCS12Handler::NewLC(*iPkiServiceApi); |
|
67 |
|
68 DEBUG_LOG(_L("Setting deletable")); |
|
69 pkcs12handler->SetDeletable(aParms.Deletable()); |
|
70 |
|
71 DEBUG_LOG(_L("Setting applicability")); |
|
72 pkcs12handler->SetApplicability(aParms.Applicability()); |
|
73 |
|
74 HBufC* pwd(NULL); |
|
75 if (aParms.Password().Length() == 0) |
|
76 { |
|
77 DEBUG_LOG(_L("Password length is zero, no password given")); |
|
78 pwd = HBufC::NewLC(0); |
|
79 } |
|
80 else |
|
81 { |
|
82 DEBUG_LOG(_L("Converting password to 16bit base")); |
|
83 pwd = HBufC::NewLC(aParms.Password().Length()); |
|
84 pwd->Des().Copy(aParms.Password()); |
|
85 } |
|
86 |
|
87 DEBUG_LOG(_L("Storing pkcs12 object")); |
|
88 pkcs12handler->StorePKCS12ObjectL(aParms.Content(), *pwd); |
|
89 |
|
90 DEBUG_LOG(_L("Freeing handler resources")); |
|
91 |
|
92 CleanupStack::PopAndDestroy(2, pkcs12handler); |
|
93 |
|
94 return NULL; |
|
95 } |
|
96 |