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