xref: /AOO41X/main/sal/inc/osl/security.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 _OSL_SECURITY_HXX_
29 #define _OSL_SECURITY_HXX_
30 
31 #include <rtl/ustring.hxx>
32 
33 #ifndef _OSL_SECURITY_DECL_HXX
34 #	include <osl/security_decl.hxx>
35 #endif
36 
37 namespace osl
38 {
39 
40 inline Security::Security()
41 {
42 	m_handle = osl_getCurrentSecurity();
43 }
44 
45 inline Security::~Security()
46 {
47     osl_freeSecurityHandle(m_handle);
48 }
49 
50 inline sal_Bool Security::logonUser(const rtl::OUString& strName,
51 									const rtl::OUString& strPasswd)
52 {
53     osl_freeSecurityHandle(m_handle);
54 
55     m_handle = 0;
56 
57 	return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
58 	        == osl_Security_E_None);
59 }
60 
61 inline sal_Bool Security::logonUser( const rtl::OUString& strName,
62 									  const rtl::OUString& strPasswd,
63 									  const rtl::OUString& strFileServer )
64 {
65     osl_freeSecurityHandle(m_handle);
66 
67     m_handle = NULL;
68 
69     return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
70 	        == osl_Security_E_None);
71 }
72 
73 inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
74 {
75     return osl_getUserIdent( m_handle, &strIdent.pData );
76 }
77 
78 
79 inline sal_Bool Security::getUserName( rtl::OUString& strName ) const
80 {
81     return osl_getUserName( m_handle, &strName.pData );
82 }
83 
84 
85 inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const
86 {
87     return osl_getHomeDir(m_handle, &strDirectory.pData );
88 }
89 
90 
91 inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
92 {
93     return osl_getConfigDir( m_handle, &strDirectory.pData );
94 }
95 
96 inline sal_Bool Security::isAdministrator() const
97 {
98     return osl_isAdministrator(m_handle);
99 }
100 
101 inline oslSecurity Security::getHandle() const
102 {
103     return m_handle;
104 }
105 
106 
107 }
108 
109 #endif	// _OSL_SECURITY_HXX_
110 
111