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