|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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: |
|
15 * authrepository - Central Repository methods implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #include "authrepository.h" |
|
25 #include "authserver_impl.h" |
|
26 |
|
27 using namespace AuthServer; |
|
28 |
|
29 CAuthRepository* CAuthRepository::NewL() |
|
30 { |
|
31 CAuthRepository* self = CAuthRepository::NewLC(); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 |
|
37 CAuthRepository* CAuthRepository::NewLC() |
|
38 { |
|
39 CAuthRepository* self = new (ELeave)CAuthRepository(); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 void CAuthRepository::ConstructL() |
|
46 { |
|
47 iRepository = CRepository::NewL(KUidAuthServerRepository); |
|
48 } |
|
49 |
|
50 |
|
51 CAuthRepository::~CAuthRepository() |
|
52 { |
|
53 delete iRepository; |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 /** |
|
59 Retrieves the default system wide plugin Id as defined in the |
|
60 central repository file |
|
61 |
|
62 |
|
63 @leave KErrArgument If the default plugin is not |
|
64 defined in the central repository |
|
65 file. |
|
66 |
|
67 @return The retrieved Plugin Id from the repository is returned. |
|
68 |
|
69 */ |
|
70 |
|
71 TPluginId CAuthRepository::DefaultPluginL() const |
|
72 { |
|
73 //Read the default plugin value from the configuration file. |
|
74 TInt defaultPlugin(0); |
|
75 User::LeaveIfError(iRepository->Get(KAuthDefaultPlugin, defaultPlugin)); |
|
76 |
|
77 //If the default plugin is not set. |
|
78 if(defaultPlugin == 0) |
|
79 { |
|
80 User::Leave(KErrArgument); |
|
81 } |
|
82 |
|
83 return defaultPlugin; |
|
84 |
|
85 } |
|
86 |
|
87 |
|
88 /** |
|
89 Retrieves the authentication alias as defined in the authserver's |
|
90 central repository file . |
|
91 |
|
92 @param aAuthAliasList An array to be populated with the |
|
93 authentication alias as obtained |
|
94 from the authserver's central repository |
|
95 file. |
|
96 @leave KErrArgument when the count of authentication aliases |
|
97 in authserver's central repository file is |
|
98 negative. |
|
99 @leave KErrNotFound when there is no authentication aliases |
|
100 defined in authserver's central repository file. |
|
101 */ |
|
102 |
|
103 void CAuthRepository::ListAliasL(RPointerArray<HBufC>& aAuthAliasList) |
|
104 { |
|
105 TInt authStrengthAliasCount(0); |
|
106 |
|
107 User::LeaveIfError(iRepository->Get(EAuthAliasesCount, authStrengthAliasCount)); |
|
108 |
|
109 // leave if the count is a negative value. |
|
110 if(authStrengthAliasCount < 0) |
|
111 User::Leave(KErrArgument); |
|
112 |
|
113 // leave with KErrNotFound when the count is zero. |
|
114 if(authStrengthAliasCount == 0) |
|
115 User::Leave(KErrNotFound); |
|
116 |
|
117 for(TInt i = 0; i < authStrengthAliasCount; ++i) |
|
118 { |
|
119 HBufC* strengthAlias = HBufC::NewLC(KMaxDescLen); |
|
120 TPtr value(strengthAlias->Des()); |
|
121 User::LeaveIfError(iRepository->Get(EAuthAliases+i, value)); |
|
122 aAuthAliasList.AppendL(strengthAlias); |
|
123 CleanupStack::Pop(strengthAlias); |
|
124 } |
|
125 } |
|
126 |
|
127 |
|
128 /** |
|
129 Retrieves the authentication definition corresponding to the alias |
|
130 as defined in the authserver's central repository file . |
|
131 |
|
132 @param aKey The index of the authentication alias |
|
133 in the central repository file. |
|
134 zero. |
|
135 |
|
136 @param aValue The retrieved definition value for |
|
137 the alias. |
|
138 */ |
|
139 |
|
140 void CAuthRepository::GetAliasDefinitionL(TInt aKey, TDes16& aValue) |
|
141 { |
|
142 User::LeaveIfError(iRepository->Get(EAuthAliasesExpr+aKey, aValue)); |
|
143 } |