LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/osl - security.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 28 64.3 %
Date: 2013-07-09 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 _OSL_SECURITY_HXX_
      21             : #define _OSL_SECURITY_HXX_
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #ifndef _OSL_SECURITY_DECL_HXX
      26             : #   include <osl/security_decl.hxx>
      27             : #endif
      28             : 
      29             : namespace osl
      30             : {
      31             : 
      32        1315 : inline Security::Security()
      33             : {
      34        1315 :     m_handle = osl_getCurrentSecurity();
      35        1315 : }
      36             : 
      37        1315 : inline Security::~Security()
      38             : {
      39        1315 :     osl_freeSecurityHandle(m_handle);
      40        1315 : }
      41             : 
      42           0 : inline sal_Bool Security::logonUser(const rtl::OUString& strName,
      43             :                                     const rtl::OUString& strPasswd)
      44             : {
      45           0 :     osl_freeSecurityHandle(m_handle);
      46             : 
      47           0 :     m_handle = 0;
      48             : 
      49           0 :     return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
      50           0 :             == osl_Security_E_None);
      51             : }
      52             : 
      53           0 : inline sal_Bool Security::logonUser( const rtl::OUString& strName,
      54             :                                       const rtl::OUString& strPasswd,
      55             :                                       const rtl::OUString& strFileServer )
      56             : {
      57           0 :     osl_freeSecurityHandle(m_handle);
      58             : 
      59           0 :     m_handle = NULL;
      60             : 
      61           0 :     return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
      62           0 :             == osl_Security_E_None);
      63             : }
      64             : 
      65           1 : inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
      66             : {
      67           1 :     return osl_getUserIdent( m_handle, &strIdent.pData );
      68             : }
      69             : 
      70             : 
      71         192 : inline sal_Bool Security::getUserName( rtl::OUString& strName ) const
      72             : {
      73         192 :     return osl_getUserName( m_handle, &strName.pData );
      74             : }
      75             : 
      76             : 
      77         929 : inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const
      78             : {
      79         929 :     return osl_getHomeDir(m_handle, &strDirectory.pData );
      80             : }
      81             : 
      82             : 
      83          33 : inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
      84             : {
      85          33 :     return osl_getConfigDir( m_handle, &strDirectory.pData );
      86             : }
      87             : 
      88           2 : inline sal_Bool Security::isAdministrator() const
      89             : {
      90           2 :     return osl_isAdministrator(m_handle);
      91             : }
      92             : 
      93         159 : inline oslSecurity Security::getHandle() const
      94             : {
      95         159 :     return m_handle;
      96             : }
      97             : 
      98             : 
      99             : }
     100             : 
     101             : #endif  // _OSL_SECURITY_HXX_
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10