Change the authorization sequence
[platform/core/connectivity/smartcard-service.git] / common / PKCS15.cpp
1 /*
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 /* standard library header */
19
20 /* SLP library header */
21
22 /* local header */
23 #include "Debug.h"
24 #include "PKCS15.h"
25
26 namespace smartcard_service_api
27 {
28         static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
29         ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
30
31         PKCS15::PKCS15(Channel *channel):PKCS15Object(channel), odf(NULL)
32         {
33                 int ret = 0;
34
35                 if ((ret = select(PKCS15::PKCS15_AID)) == 0)
36                 {
37                         SCARD_DEBUG("response : %s", selectResponse.toString());
38                 }
39                 else
40                 {
41                         SCARD_DEBUG_ERR("select failed, [%d]", ret);
42                 }
43         }
44
45         PKCS15::PKCS15(Channel *channel, ByteArray selectResponse):PKCS15Object(channel, selectResponse), odf(NULL)
46         {
47         }
48
49         PKCS15::~PKCS15()
50         {
51                 if (odf != NULL)
52                 {
53                         delete odf;
54                         odf = NULL;
55                 }
56         }
57
58         PKCS15ODF *PKCS15::getODF()
59         {
60                 if (odf == NULL)
61                 {
62                         odf = new PKCS15ODF(channel);
63
64                         if (odf != NULL && odf->isClosed() == true)
65                         {
66                                 SCARD_DEBUG_ERR("failed to open ODF");
67
68                                 delete odf;
69                                 odf = NULL;
70                         }
71                 }
72
73                 SCARD_DEBUG("odf [%p]", odf);
74
75                 return odf;
76         }
77
78 } /* namespace smartcard_service_api */