xref: /aoo4110/main/vos/inc/vos/security.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _VOS_SECURITY_HXX_
25 #define _VOS_SECURITY_HXX_
26 
27 #   include <vos/object.hxx>
28 #   include <rtl/ustring.hxx>
29 #   include <osl/security.h>
30 
31 namespace vos
32 {
33 
34 /** capsulate security informations for one user.
35     A object of this class is used to execute a process with the rights an
36     security options of a scecified user.
37     @see OProcess::executeProcess
38     @author  Bernd Hofner
39     @version 1.0
40 
41 */
42 class OSecurity : public OObject
43 {
44     VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSecurity, vos));
45 
46 public:
47     /// constructor
48     OSecurity();
49     /// destructor
50     virtual ~OSecurity();
51     /** get the security information for one user.
52         The underlying operating system is asked for this information.
53         @param strName [in] denotes the name of the user
54         @param strPasswd [in] denotes the password of this user
55         @return True, if the specified user is known by the underlying operating system,
56         otherwise False
57     */
58     sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
59                                 const ::rtl::OUString& strPasswd);
60     /** get the security information for one user.
61         This method will try to login the user at the denoted file server.
62         If a network resource named \\server\username exists and this resource
63         could be connected by this user, the methos will return true and getHomeDir
64         will return \\server\username.
65         @param strName [in] denotes the name of the user
66         @param strPasswd [in] denotes the password of this user
67         @return True, if the specified user is known by file server and the
68         could be connected, otherwise False
69     */
70     sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
71                                 const ::rtl::OUString& strPasswd,
72                                 const ::rtl::OUString& strFileServer);
73 
74     /** get the ident of the logged in user.
75         @param strName [out] is the buffer which returns the name
76         @param max [in] is the size of this buffer
77         @return True, if any user is successfuly logged in, otherwise False
78     */
79     sal_Bool SAL_CALL getUserIdent(::rtl::OUString& strIdent) const;
80 
81     /** get the name of the logged in user.
82         @param strName [out] is the buffer which returns the name
83         @param max [in] is the size of this buffer
84         @return True, if any user is successfuly logged in, otherwise False
85     */
86     sal_Bool SAL_CALL getUserName(::rtl::OUString& strName) const;
87 
88     /** get the home directory of the logged in user.
89         @param strDirectory [out] is the buffer which returns the directory name
90         @param max [in] is the size of this buffer
91         @return True, if any user is successfuly logged in, otherwise False
92     */
93     sal_Bool SAL_CALL getHomeDir(::rtl::OUString& strDirectory) const;
94 
95     /** get the directory for configuration data of the logged in user.
96         @param strDirectory [out] is the buffer which returns the directory name
97         @param max [in] is the size of this buffer
98         @return True, if any user is successfuly logged in, otherwise False
99     */
100     sal_Bool SAL_CALL getConfigDir(::rtl::OUString& strDirectory) const;
101 
102     /** Query if the user who is logged inhas administrator rigths.
103         @return True, if the user has administrator rights, otherwise false.
104     */
105     sal_Bool SAL_CALL isAdministrator() const;
106 
107     virtual SAL_CALL operator oslSecurity() const;
108 
109 protected:
110 
111     oslSecurity m_oslSecurity;
112 };
113 
114 }
115 
116 #endif  // _VOS_SECURITY_HXX_
117 
118