LCOV - code coverage report
Current view: top level - include/osl - security.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 18 28 64.3 %
Date: 2014-04-11 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <rtl/ustring.hxx>
      24             : #include <osl/security_decl.hxx>
      25             : 
      26             : namespace osl
      27             : {
      28             : 
      29        1533 : inline Security::Security()
      30             : {
      31        1533 :     m_handle = osl_getCurrentSecurity();
      32        1533 : }
      33             : 
      34        1533 : inline Security::~Security()
      35             : {
      36        1533 :     osl_freeSecurityHandle(m_handle);
      37        1533 : }
      38             : 
      39           0 : inline bool Security::logonUser(const rtl::OUString& strName,
      40             :                                     const rtl::OUString& strPasswd)
      41             : {
      42           0 :     osl_freeSecurityHandle(m_handle);
      43             : 
      44           0 :     m_handle = 0;
      45             : 
      46           0 :     return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
      47           0 :             == osl_Security_E_None);
      48             : }
      49             : 
      50           0 : inline bool Security::logonUser( const rtl::OUString& strName,
      51             :                                       const rtl::OUString& strPasswd,
      52             :                                       const rtl::OUString& strFileServer )
      53             : {
      54           0 :     osl_freeSecurityHandle(m_handle);
      55             : 
      56           0 :     m_handle = NULL;
      57             : 
      58           0 :     return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
      59           0 :             == osl_Security_E_None);
      60             : }
      61             : 
      62           1 : inline bool Security::getUserIdent( rtl::OUString& strIdent) const
      63             : {
      64           1 :     return osl_getUserIdent( m_handle, &strIdent.pData );
      65             : }
      66             : 
      67             : 
      68         227 : inline bool Security::getUserName( rtl::OUString& strName ) const
      69             : {
      70         227 :     return osl_getUserName( m_handle, &strName.pData );
      71             : }
      72             : 
      73             : 
      74        1124 : inline bool Security::getHomeDir( rtl::OUString& strDirectory) const
      75             : {
      76        1124 :     return osl_getHomeDir(m_handle, &strDirectory.pData );
      77             : }
      78             : 
      79             : 
      80          33 : inline bool Security::getConfigDir( rtl::OUString& strDirectory ) const
      81             : {
      82          33 :     return osl_getConfigDir( m_handle, &strDirectory.pData );
      83             : }
      84             : 
      85           2 : inline bool Security::isAdministrator() const
      86             : {
      87           2 :     return osl_isAdministrator(m_handle);
      88             : }
      89             : 
      90         147 : inline oslSecurity Security::getHandle() const
      91             : {
      92         147 :     return m_handle;
      93             : }
      94             : 
      95             : 
      96             : }
      97             : 
      98             : #endif // INCLUDED_OSL_SECURITY_HXX
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10