1 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies of substantial portions of this software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 mike 1.2 // DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Bapu Patil, Hewlett-Packard Company (bapu_patil@hp.com)
27 //
28 // Modified By:
29 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
30 //
31 //%/////////////////////////////////////////////////////////////////////////////
32
33 #ifndef Pegasus_LocalAuthFile_h
34 #define Pegasus_LocalAuthFile_h
35
36 #include <fstream>
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/System.h>
41 #include "Linkage.h"
42
43 mike 1.2 PEGASUS_NAMESPACE_BEGIN
44
45 /**
46 * Maximum buffer size
47 */
48 #define MAX_BUFFER_SIZE 256
49
50 /**
51 * Maximum password buffer size. Used by getpwnam_r call.
52 */
53 #define MAX_PWD_BUFFER_SIZE 1024
54
55
56 /**
57 This class provides the required functions to create, write and delete to a
58 file on UNIX file system.
59 */
60
61 class PEGASUS_SECURITY_LINKAGE LocalAuthFile
62 {
63 public:
64 mike 1.2
65 /** Constructor. */
66 LocalAuthFile(String userName);
67
68
69 /** Destructor. */
70 ~LocalAuthFile();
71
72 /**
73 Create a file and make a random token data entry to it.
74
75 @return String full path name of the file created if
76 the file created successfull, null otherwise.
77 */
78 String create();
79
80 /**
81 Removes the file created.
82
83 @return true on successful removal of the file,
84 false otherwise.
85 mike 1.2 */
86 Boolean remove();
87
88 /**
89 Get the string that was created as a challenge string
90 */
91 String getChallengeString();
92
93 private:
94
95 /**
96 Changes file owner to the current process owner and also set
97 file permissions to read-only by that user.
98
99 @param filename name of the file
100 @return true on success, false on failure.
101 */
102 Boolean _changeFileOwner(char* fileName);
103
104 /**
105 Generate random token string.
106 mike 1.2 */
107 String _generateRandomTokenString();
108
109 /**
110 Used to store the user name
111 */
112 char* _user;
113
114 /**
115 Full path name of the file that is sent in the challenge.
116 */
117 String _filePathName;
118
119 /**
120 Challenge string that is written to the file.
121 */
122 String _challenge;
123
124 };
125
126 PEGASUS_NAMESPACE_END
127 mike 1.2
128 #endif /* Pegasus_LocalAuthFile_h */
|