1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: security.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OSL_SECURITY_HXX_
32 #define _OSL_SECURITY_HXX_
34 #include <rtl/ustring.hxx>
36 #ifndef _OSL_SECURITY_DECL_HXX
37 # include <osl/security_decl.hxx>
43 inline Security::Security()
45 m_handle
= osl_getCurrentSecurity();
48 inline Security::~Security()
50 osl_freeSecurityHandle(m_handle
);
53 inline sal_Bool
Security::logonUser(const rtl::OUString
& strName
,
54 const rtl::OUString
& strPasswd
)
56 osl_freeSecurityHandle(m_handle
);
60 return (osl_loginUser( strName
.pData
, strPasswd
.pData
, &m_handle
)
61 == osl_Security_E_None
);
64 inline sal_Bool
Security::logonUser( const rtl::OUString
& strName
,
65 const rtl::OUString
& strPasswd
,
66 const rtl::OUString
& strFileServer
)
68 osl_freeSecurityHandle(m_handle
);
72 return (osl_loginUserOnFileServer(strName
.pData
, strPasswd
.pData
, strFileServer
.pData
, &m_handle
)
73 == osl_Security_E_None
);
76 inline sal_Bool
Security::getUserIdent( rtl::OUString
& strIdent
) const
78 return osl_getUserIdent( m_handle
, &strIdent
.pData
);
82 inline sal_Bool
Security::getUserName( rtl::OUString
& strName
) const
84 return osl_getUserName( m_handle
, &strName
.pData
);
88 inline sal_Bool
Security::getHomeDir( rtl::OUString
& strDirectory
) const
90 return osl_getHomeDir(m_handle
, &strDirectory
.pData
);
94 inline sal_Bool
Security::getConfigDir( rtl::OUString
& strDirectory
) const
96 return osl_getConfigDir( m_handle
, &strDirectory
.pData
);
99 inline sal_Bool
Security::isAdministrator() const
101 return osl_isAdministrator(m_handle
);
104 inline oslSecurity
Security::getHandle() const
112 #endif // _OSL_SECURITY_HXX_