LibreOffice: osl/security.hxx Source File

LibreOffice LibreOffice 5.2 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

security.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #ifndef INCLUDED_OSL_SECURITY_HXX
21 #define INCLUDED_OSL_SECURITY_HXX
22
23 #include <sal/config.h>
24
25 #include <cstddef>
26
27 #include <rtl/ustring.hxx>
28 #include <osl/security_decl.hxx>
29
30 namespace osl
31 {
32
33 inline Security::Security()
34 {
35 m_handle = osl_getCurrentSecurity();
36 }
37
38 inline Security::~Security()
39 {
40 osl_freeSecurityHandle(m_handle);
41 }
42
43 inline bool Security::logonUser(const rtl::OUString& strName,
44 const rtl::OUString& strPasswd)
45 {
46 osl_freeSecurityHandle(m_handle);
47
48 m_handle = NULL;
49
50 return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
51 == osl_Security_E_None);
52 }
53
54 inline bool Security::logonUser( const rtl::OUString& strName,
55 const rtl::OUString& strPasswd,
56 const rtl::OUString& strFileServer )
57 {
58 osl_freeSecurityHandle(m_handle);
59
60 m_handle = NULL;
61
62 return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
63 == osl_Security_E_None);
64 }
65
66 inline bool Security::getUserIdent( rtl::OUString& strIdent) const
67 {
68 return osl_getUserIdent( m_handle, &strIdent.pData );
69 }
70
71
72 inline bool Security::getUserName( rtl::OUString& strName, bool bIncludeDomain ) const
73 {
74 if (bIncludeDomain)
75 return osl_getUserName( m_handle, &strName.pData );
76 return osl_getShortUserName( m_handle, &strName.pData );
77 }
78
79
80 inline bool Security::getHomeDir( rtl::OUString& strDirectory) const
81 {
82 return osl_getHomeDir(m_handle, &strDirectory.pData );
83 }
84
85
86 inline bool Security::getConfigDir( rtl::OUString& strDirectory ) const
87 {
88 return osl_getConfigDir( m_handle, &strDirectory.pData );
89 }
90
91 inline bool Security::isAdministrator() const
92 {
93 return osl_isAdministrator(m_handle);
94 }
95
96 inline oslSecurity Security::getHandle() const
97 {
98 return m_handle;
99 }
100
101
102 }
103
104 #endif // INCLUDED_OSL_SECURITY_HXX
105
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Security::logonUser
bool logonUser(const rtl::OUString &strName, const rtl::OUString &strPasswd)
get the security information for one user.
Definition: security.hxx:43
osl_getHomeDir
SAL_DLLPUBLIC sal_Bool osl_getHomeDir(oslSecurity Security, rtl_uString **strDirectory)
Get the home directory of the user of this security handle.
osl_loginUserOnFileServer
SAL_DLLPUBLIC oslSecurityError osl_loginUserOnFileServer(rtl_uString *strUserName, rtl_uString *strPasswd, rtl_uString *strFileServer, oslSecurity *pSecurity)
Create a security handle for the denoted user.
osl_getUserIdent
SAL_DLLPUBLIC sal_Bool osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent)
Get the login ident for the user of this security handle.
osl_getCurrentSecurity
SAL_DLLPUBLIC oslSecurity osl_getCurrentSecurity(void)
Create a security handle for the current user.
config.h
osl_loginUser
SAL_DLLPUBLIC oslSecurityError osl_loginUser(rtl_uString *strUserName, rtl_uString *strPasswd, oslSecurity *pSecurity)
Deprecated API Create a security handle for the denoted user.
osl_isAdministrator
SAL_DLLPUBLIC sal_Bool osl_isAdministrator(oslSecurity Security)
Query if the user who is denotes by this security has administrator rights.
osl::Security::Security
Security()
constructor
Definition: security.hxx:33
osl_freeSecurityHandle
SAL_DLLPUBLIC void osl_freeSecurityHandle(oslSecurity Security)
Free the security handle, created by osl_loginUser or osl_getCurrentSecurity.
osl::Security::getHomeDir
bool getHomeDir(rtl::OUString &strDirectory) const
get the home directory of the logged in user.
Definition: security.hxx:80
osl::Security::getUserName
bool getUserName(rtl::OUString &strName, bool bIncludeDomain=true) const
get the name of the logged in user.
Definition: security.hxx:72
osl_getConfigDir
SAL_DLLPUBLIC sal_Bool osl_getConfigDir(oslSecurity Security, rtl_uString **strDirectory)
Get the directory for configuration data of the user of this security handle.
osl::Security::isAdministrator
bool isAdministrator() const
Query if the user who is logged in has administrator rights.
Definition: security.hxx:91
osl::Security::getHandle
oslSecurity getHandle() const
Returns the underlying oslSecurity handle.
Definition: security.hxx:96
osl_getUserName
SAL_DLLPUBLIC sal_Bool osl_getUserName(oslSecurity Security, rtl_uString **strName)
Get the login name for the user of this security handle.
osl::Security::getUserIdent
bool getUserIdent(rtl::OUString &strIdent) const
get the ident of the logged in user.
Definition: security.hxx:66
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
osl::Security::getConfigDir
bool getConfigDir(rtl::OUString &strDirectory) const
get the directory for configuration data of the logged in user.
Definition: security.hxx:86
ustring.hxx
security_decl.hxx
oslSecurity
void * oslSecurity
Process handle.
Definition: security.h:45
osl_getShortUserName
SAL_DLLPUBLIC sal_Bool osl_getShortUserName(oslSecurity Security, rtl_uString **strName)
Get the login name for the user of this security handle, excluding the domain name on Windows...
osl::Security::m_handle
oslSecurity m_handle
Definition: security_decl.hxx:37
osl
Definition: conditn.hxx:32
osl_Security_E_None
Definition: security.h:33
osl::Security::~Security
~Security()
destructor
Definition: security.hxx:38