/src/libreoffice/include/osl/security.hxx
Line | Count | Source |
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 | | /* |
21 | | * This file is part of LibreOffice published API. |
22 | | */ |
23 | | |
24 | | #ifndef INCLUDED_OSL_SECURITY_HXX |
25 | | #define INCLUDED_OSL_SECURITY_HXX |
26 | | |
27 | | #include "sal/config.h" |
28 | | |
29 | | #include <cstddef> |
30 | | |
31 | | #include "rtl/ustring.hxx" |
32 | | #include "osl/security_decl.hxx" |
33 | | |
34 | | namespace osl |
35 | | { |
36 | | |
37 | | inline Security::Security() |
38 | 150k | { |
39 | 150k | m_handle = osl_getCurrentSecurity(); |
40 | 150k | } |
41 | | |
42 | | inline Security::~Security() |
43 | 150k | { |
44 | 150k | osl_freeSecurityHandle(m_handle); |
45 | 150k | } |
46 | | |
47 | | inline bool Security::logonUser(const rtl::OUString& strName, |
48 | | const rtl::OUString& strPasswd) |
49 | 0 | { |
50 | 0 | osl_freeSecurityHandle(m_handle); |
51 | 0 |
|
52 | 0 | m_handle = NULL; |
53 | 0 |
|
54 | 0 | return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle) |
55 | 0 | == osl_Security_E_None); |
56 | 0 | } |
57 | | |
58 | | inline bool Security::logonUser( const rtl::OUString& strName, |
59 | | const rtl::OUString& strPasswd, |
60 | | const rtl::OUString& strFileServer ) |
61 | 0 | { |
62 | 0 | osl_freeSecurityHandle(m_handle); |
63 | 0 |
|
64 | 0 | m_handle = NULL; |
65 | 0 |
|
66 | 0 | return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle) |
67 | 0 | == osl_Security_E_None); |
68 | 0 | } |
69 | | |
70 | | inline bool Security::getUserIdent( rtl::OUString& strIdent) const |
71 | 0 | { |
72 | 0 | return osl_getUserIdent( m_handle, &strIdent.pData ); |
73 | 0 | } |
74 | | |
75 | | |
76 | | inline bool Security::getUserName( rtl::OUString& strName, bool bIncludeDomain ) const |
77 | 50.0k | { |
78 | 50.0k | if (bIncludeDomain) |
79 | 0 | return osl_getUserName( m_handle, &strName.pData ); |
80 | 50.0k | return osl_getShortUserName( m_handle, &strName.pData ); |
81 | 50.0k | } |
82 | | |
83 | | |
84 | | inline bool Security::getHomeDir( rtl::OUString& strDirectory) const |
85 | 100k | { |
86 | 100k | return osl_getHomeDir(m_handle, &strDirectory.pData ); |
87 | 100k | } |
88 | | |
89 | | |
90 | | inline bool Security::getConfigDir( rtl::OUString& strDirectory ) const |
91 | 0 | { |
92 | 0 | return osl_getConfigDir( m_handle, &strDirectory.pData ); |
93 | 0 | } |
94 | | |
95 | | inline bool Security::isAdministrator() const |
96 | 0 | { |
97 | 0 | return osl_isAdministrator(m_handle); |
98 | 0 | } |
99 | | |
100 | | inline oslSecurity Security::getHandle() const |
101 | 0 | { |
102 | 0 | return m_handle; |
103 | 0 | } |
104 | | |
105 | | |
106 | | } |
107 | | |
108 | | #endif // INCLUDED_OSL_SECURITY_HXX |
109 | | |
110 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |