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 29 #include <vos/security.hxx> 30 #include <vos/diagnose.hxx> 31 32 using namespace vos; 33 34 ///////////////////////////////////////////////////////////////////////////// 35 // Object super class 36 37 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSecurity, vos), VOS_NAMESPACE(OSecurity, vos), VOS_NAMESPACE(OObject, vos), 0); 38 39 OSecurity::OSecurity() 40 { 41 m_oslSecurity = osl_getCurrentSecurity(); 42 } 43 44 OSecurity::~OSecurity() 45 { 46 osl_freeSecurityHandle(m_oslSecurity); 47 } 48 49 sal_Bool OSecurity::logonUser(const rtl::OUString& strName, 50 const rtl::OUString& strPasswd) 51 { 52 osl_freeSecurityHandle(m_oslSecurity); 53 54 m_oslSecurity = NULL; 55 56 return (osl_loginUser( strName.pData, strPasswd.pData, &m_oslSecurity) 57 == osl_Security_E_None); 58 } 59 60 61 sal_Bool OSecurity::logonUser( const rtl::OUString& strName, 62 const rtl::OUString& strPasswd, 63 const rtl::OUString& strFileServer ) 64 { 65 osl_freeSecurityHandle(m_oslSecurity); 66 67 m_oslSecurity = NULL; 68 69 return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_oslSecurity) 70 == osl_Security_E_None); 71 } 72 73 74 sal_Bool OSecurity::getUserIdent( rtl::OUString& strIdent) const 75 { 76 VOS_ASSERT(m_oslSecurity); 77 78 return osl_getUserIdent( m_oslSecurity, &strIdent.pData ); 79 } 80 81 82 sal_Bool OSecurity::getUserName( rtl::OUString& strName ) const 83 { 84 VOS_ASSERT(m_oslSecurity); 85 86 return osl_getUserName( m_oslSecurity, &strName.pData ); 87 } 88 89 90 sal_Bool OSecurity::getHomeDir( rtl::OUString& strDirectory) const 91 { 92 VOS_ASSERT(m_oslSecurity); 93 94 return osl_getHomeDir(m_oslSecurity, &strDirectory.pData ); 95 } 96 97 98 sal_Bool OSecurity::getConfigDir( rtl::OUString& strDirectory ) const 99 { 100 VOS_ASSERT(m_oslSecurity); 101 102 return osl_getConfigDir( m_oslSecurity, &strDirectory.pData ); 103 } 104 105 sal_Bool OSecurity::isAdministrator() const 106 { 107 VOS_ASSERT(m_oslSecurity); 108 109 return osl_isAdministrator(m_oslSecurity); 110 } 111 112 OSecurity::operator oslSecurity() const 113 { 114 return m_oslSecurity; 115 } 116 117