xref: /trunk/main/vos/inc/vos/security.hxx (revision d98e0520)
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 #   include <vos/vosdllapi.h>
31 
32 namespace vos
33 {
34 
35 /** capsulate security informations for one user.
36     A object of this class is used to execute a process with the rights an
37     security options of a scecified user.
38     @see OProcess::executeProcess
39     @author  Bernd Hofner
40     @version 1.0
41 
42 */
43 class VOS_DLLPUBLIC OSecurity : public OObject
44 {
45     VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSecurity, vos));
46 
47 public:
48     /// constructor
49     OSecurity();
50     /// destructor
51     virtual ~OSecurity();
52     /** get the security information for one user.
53         The underlying operating system is asked for this information.
54         @param strName [in] denotes the name of the user
55         @param strPasswd [in] denotes the password of this user
56         @return True, if the specified user is known by the underlying operating system,
57         otherwise False
58     */
59     sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
60                                 const ::rtl::OUString& strPasswd);
61     /** get the security information for one user.
62         This method will try to login the user at the denoted file server.
63         If a network resource named \\server\username exists and this resource
64         could be connected by this user, the methos will return true and getHomeDir
65         will return \\server\username.
66         @param strName [in] denotes the name of the user
67         @param strPasswd [in] denotes the password of this user
68         @return True, if the specified user is known by file server and the
69         could be connected, otherwise False
70     */
71     sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
72                                 const ::rtl::OUString& strPasswd,
73                                 const ::rtl::OUString& strFileServer);
74 
75     /** get the ident of the logged in user.
76         @param strName [out] is the buffer which returns the name
77         @param max [in] is the size of this buffer
78         @return True, if any user is successfuly logged in, otherwise False
79     */
80     sal_Bool SAL_CALL getUserIdent(::rtl::OUString& strIdent) const;
81 
82     /** get the name of the logged in user.
83         @param strName [out] is the buffer which returns the name
84         @param max [in] is the size of this buffer
85         @return True, if any user is successfuly logged in, otherwise False
86     */
87     sal_Bool SAL_CALL getUserName(::rtl::OUString& strName) const;
88 
89     /** get the home directory of the logged in user.
90         @param strDirectory [out] is the buffer which returns the directory name
91         @param max [in] is the size of this buffer
92         @return True, if any user is successfuly logged in, otherwise False
93     */
94     sal_Bool SAL_CALL getHomeDir(::rtl::OUString& strDirectory) const;
95 
96     /** get the directory for configuration data of the logged in user.
97         @param strDirectory [out] is the buffer which returns the directory name
98         @param max [in] is the size of this buffer
99         @return True, if any user is successfuly logged in, otherwise False
100     */
101     sal_Bool SAL_CALL getConfigDir(::rtl::OUString& strDirectory) const;
102 
103     /** Query if the user who is logged inhas administrator rigths.
104         @return True, if the user has administrator rights, otherwise false.
105     */
106     sal_Bool SAL_CALL isAdministrator() const;
107 
108     virtual SAL_CALL operator oslSecurity() const;
109 
110 protected:
111 
112     oslSecurity m_oslSecurity;
113 };
114 
115 }
116 
117 #endif  // _VOS_SECURITY_HXX_
118 
119