1: <?php
2: /*
3: * Copyright (C) 2013 Bryan Nielsen - All Rights Reserved
4: *
5: * Author: Bryan Nielsen (bnielsen1965@gmail.com)
6: *
7: *
8: * This file is part of cryptUser.
9: * cryptUser is free software: you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License as published by
11: * the Free Software Foundation, either version 3 of the License, or
12: * (at your option) any later version.
13: *
14: * cryptUser is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: * GNU General Public License for more details.
18: *
19: * You should have received a copy of the GNU General Public License
20: * along with cryptUser. If not, see <http://www.gnu.org/licenses/>.
21: */
22:
23: namespace BSN\CryptUser;
24:
25: /**
26: * The data source interface used to define functions required by any data source.
27: *
28: * @author Bryan Nielsen, bnielsen1965@gmail.com
29: * @copyright Copyright 2013, Bryan Nielsen
30: */
31: interface CryptDataSource {
32: /**
33: * Get the source type. This function should return a string representing
34: * the type of data source, i.e. 'JSON' or 'MySQL'.
35: *
36: * @return string The data source type.
37: */
38: public function getSourceType();
39:
40: /**
41: * Get array of user elements that match a given name.
42: * The aray of user elements may come from any type of data source, a database
43: * table, a flat file, etc., but the returned user array must include the following
44: * elements:
45: * username, passwordHash, sslKey, flags
46: *
47: * @param string $username The username to search for in the data source.
48: * @return array|boolean An array of arrays containing user elements to create a user
49: * or FALSE if not found.
50: */
51: public function getUserByName($username);
52:
53: /**
54: * Get a list of usernames
55: * @return array An array of strings containing the usernames from the data source.
56: */
57: public function getUsernames();
58:
59: /**
60: * Save the provided user details in the data source.
61: * @param array $user An array of user elements to be saved.
62: * @return boolean Returns TRUE on success and FALSE on failure.
63: */
64: public function saveUser($user);
65:
66: /**
67: * Delete the specified user from the data source.
68: * @param string $username The username of the user to delete.
69: * @return boolean Returns TRUE on success and FALSE on failure.
70: */
71: public function deleteUser($username);
72:
73: }
74:
75: