Debian Codegraph @

src/lib/object_store/ObjectStoreToken.h

raw
1 /*
2 * Copyright (c) 2013 SURFnet bv
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 /*****************************************************************************
28 ObjectStoreToken.h
29
30 The object store abstract token base class;
31 *****************************************************************************/
32
33 #ifndef _SOFTHSM_V2_OBJECTSTORETOKEN_H
34 #define _SOFTHSM_V2_OBJECTSTORETOKEN_H
35
36 #include "config.h"
37 #include "OSObject.h"
38 #include <string>
39 #include <set>
40
41 class ObjectStoreToken
42 {
43 public:
44 // Select the type of backend to use for storing token objects.
45 static bool selectBackend(const std::string& backend);
46
47 // Create a new token
48 static ObjectStoreToken* createToken(const std::string basePath, const std::string tokenDir, const ByteString& label, const ByteString& serial);
49
50 // Access an existing token
51 static ObjectStoreToken* accessToken(const std::string &basePath, const std::string &tokenDir);
52
53 // Set the SO PIN
54 virtual bool setSOPIN(const ByteString& soPINBlob) = 0;
55
56 // Get the SO PIN
57 virtual bool getSOPIN(ByteString& soPINBlob) = 0;
58
59 // Set the user PIN
60 virtual bool setUserPIN(ByteString userPINBlob) = 0;
61
62 // Get the user PIN
63 virtual bool getUserPIN(ByteString& userPINBlob) = 0;
64
65 // Get the token flags
66 virtual bool getTokenFlags(CK_ULONG& flags) = 0;
67
68 // Set the token flags
69 virtual bool setTokenFlags(const CK_ULONG flags) = 0;
70
71 // Retrieve the token label
72 virtual bool getTokenLabel(ByteString& label) = 0;
73
74 // Retrieve the token serial
75 virtual bool getTokenSerial(ByteString& serial) = 0;
76
77 // Retrieve objects
78 virtual std::set<OSObject*> getObjects() = 0;
79
80 // Insert objects into the given set
81 virtual void getObjects(std::set<OSObject*> &objects) = 0;
82
83 // Create a new object
84 virtual OSObject* createObject() = 0;
85
86 // Delete an object
87 virtual bool deleteObject(OSObject* object) = 0;
88
89 // Destructor
90 virtual ~ObjectStoreToken() {};
91
92 // Checks if the token is consistent
93 virtual bool isValid() = 0;
94
95 // Invalidate the token (for instance if it is deleted)
96 virtual void invalidate() = 0;
97
98 // Delete the token
99 virtual bool clearToken() = 0;
100
101 // Reset the token
102 virtual bool resetToken(const ByteString& label) = 0;
103 };
104
105 #endif // !_SOFTHSM_V2_OBJECTSTORETOKEN_H
106