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