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