1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _VOS_SECURITY_HXX_ 29 #define _VOS_SECURITY_HXX_ 30 31 # include <vos/object.hxx> 32 # include <rtl/ustring.hxx> 33 # include <osl/security.h> 34 35 namespace vos 36 { 37 38 /** capsulate security informations for one user. 39 A object of this class is used to execute a process with the rights an 40 security options of a scecified user. 41 @see OProcess::executeProcess 42 @author Bernd Hofner 43 @version 1.0 44 45 */ 46 class OSecurity : public OObject 47 { 48 VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSecurity, vos)); 49 50 public: 51 /// constructor 52 OSecurity(); 53 /// destructor 54 virtual ~OSecurity(); 55 /** get the security information for one user. 56 The underlying operating system is asked for this information. 57 @param strName [in] denotes the name of the user 58 @param strPasswd [in] denotes the password of this user 59 @return True, if the specified user is known by the underlying operating system, 60 otherwise False 61 */ 62 sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName, 63 const ::rtl::OUString& strPasswd); 64 /** get the security information for one user. 65 This method will try to login the user at the denoted file server. 66 If a network resource named \\server\username exists and this resource 67 could be connected by this user, the methos will return true and getHomeDir 68 will return \\server\username. 69 @param strName [in] denotes the name of the user 70 @param strPasswd [in] denotes the password of this user 71 @return True, if the specified user is known by file server and the 72 could be connected, otherwise False 73 */ 74 sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName, 75 const ::rtl::OUString& strPasswd, 76 const ::rtl::OUString& strFileServer); 77 78 /** get the ident of the logged in user. 79 @param strName [out] is the buffer which returns the name 80 @param max [in] is the size of this buffer 81 @return True, if any user is successfuly logged in, otherwise False 82 */ 83 sal_Bool SAL_CALL getUserIdent(::rtl::OUString& strIdent) const; 84 85 /** get the name of the logged in user. 86 @param strName [out] is the buffer which returns the name 87 @param max [in] is the size of this buffer 88 @return True, if any user is successfuly logged in, otherwise False 89 */ 90 sal_Bool SAL_CALL getUserName(::rtl::OUString& strName) const; 91 92 /** get the home directory of the logged in user. 93 @param strDirectory [out] is the buffer which returns the directory name 94 @param max [in] is the size of this buffer 95 @return True, if any user is successfuly logged in, otherwise False 96 */ 97 sal_Bool SAL_CALL getHomeDir(::rtl::OUString& strDirectory) const; 98 99 /** get the directory for configuration data of the logged in user. 100 @param strDirectory [out] is the buffer which returns the directory name 101 @param max [in] is the size of this buffer 102 @return True, if any user is successfuly logged in, otherwise False 103 */ 104 sal_Bool SAL_CALL getConfigDir(::rtl::OUString& strDirectory) const; 105 106 /** Query if the user who is logged inhas administrator rigths. 107 @return True, if the user has administrator rights, otherwise false. 108 */ 109 sal_Bool SAL_CALL isAdministrator() const; 110 111 virtual SAL_CALL operator oslSecurity() const; 112 113 protected: 114 115 oslSecurity m_oslSecurity; 116 }; 117 118 } 119 120 #endif // _VOS_SECURITY_HXX_ 121 122