LCOV - code coverage report
Current view: top level - uui/source - passwordcontainer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.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_UUI_SOURCE_PASSWORDCONTAINER_HXX
      21             : #define INCLUDED_UUI_SOURCE_PASSWORDCONTAINER_HXX
      22             : 
      23             : #include <cppuhelper/implbase2.hxx>
      24             : 
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      27             : #include <com/sun/star/task/XInteractionHandler2.hpp>
      28             : #include <com/sun/star/task/XPasswordContainer2.hpp>
      29             : 
      30             : namespace com {
      31             :     namespace sun {
      32             :         namespace star {
      33             :             namespace lang {
      34             :                 class XMultiServiceFactory;
      35             :             }
      36             :             namespace ucb {
      37             :                 class AuthenticationRequest;
      38             :                 class XInteractionSupplyAuthentication;
      39             : } } } }
      40             : 
      41             : namespace uui {
      42             : 
      43             : 
      44             : 
      45             : /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
      46             :  */
      47           1 : class PasswordContainerHelper
      48             : {
      49             : public:
      50             :     explicit PasswordContainerHelper(
      51             :         com::sun::star::uno::Reference<
      52             :             com::sun::star::uno::XComponentContext > const &
      53             :                 xContext );
      54             : 
      55             : 
      56             : 
      57             :     /** This member function tries to handle an authentication interaction
      58             :         request by looking up credentials for the given URL in the password
      59             :         container service.
      60             : 
      61             :         In case of success the given interaction continuation
      62             :         (XInteractionSupplyAuthentication) is filled with the credentials found
      63             :         in the password container.
      64             : 
      65             :         Please note the continuation gets not "selected" by this
      66             :         implementation. "Selecting" the continuation is up to the caller (e.g.
      67             :         an implementation of XInteractionHandler::handle) of this function.
      68             : 
      69             :         @param rRequest
      70             :             The authentication request.
      71             : 
      72             :         @param xSupplyAuthentication
      73             :             The "supply authentication" interaction continuation.
      74             : 
      75             :         @param rURL
      76             :             The URL to lookup credentials for.
      77             : 
      78             :         @param xIH
      79             :             The interaction handler to use, for example if a master password is
      80             :             needed to access the password container.
      81             : 
      82             :         @return
      83             :             True, if the authentication request was handled successfully.
      84             :             False, otherwise.
      85             :      */
      86             :     bool handleAuthenticationRequest(
      87             :         com::sun::star::ucb::AuthenticationRequest const & rRequest,
      88             :         com::sun::star::uno::Reference<
      89             :             com::sun::star::ucb::XInteractionSupplyAuthentication > const &
      90             :                 xSupplyAuthentication,
      91             :         OUString const & rURL,
      92             :         com::sun::star::uno::Reference<
      93             :             com::sun::star::task::XInteractionHandler2 > const & xIH );
      94             : 
      95             :     /** This member function adds credentials for the given URL to the password
      96             :         container.
      97             : 
      98             :         @param rURL
      99             :             The URL the credentials are valid for. rURL must not be empty.
     100             : 
     101             :         @param rUsername
     102             :             The user name.
     103             : 
     104             :         @param rPasswords
     105             :             This list of passwords.
     106             : 
     107             :         @param xIH
     108             :             The interaction handler to use, for example if a master password is
     109             :             needed to access the password container.
     110             : 
     111             :         @param bPersist
     112             :             True, the record will get stored persistently; restored upon
     113             :             password container initialization
     114             :             False, the record will be stored until password container instance
     115             :             gets destroyed.
     116             : 
     117             :         @return
     118             :             True, if the record was added successfully.
     119             :             False, otherwise.
     120             : 
     121             :     */
     122             :     bool addRecord( OUString const & rURL,
     123             :                     OUString const & rUsername,
     124             :                     com::sun::star::uno::Sequence< OUString > const &
     125             :                     rPasswords,
     126             :                     com::sun::star::uno::Reference<
     127             :                         com::sun::star::task::XInteractionHandler2 > const & xIH,
     128             :                     bool bPersist );
     129             : 
     130             : 
     131             : 
     132             : private:
     133             :     com::sun::star::uno::Reference<
     134             :         com::sun::star::task::XPasswordContainer2 > m_xPasswordContainer;
     135             : };
     136             : 
     137             : 
     138             : 
     139             : class PasswordContainerInteractionHandler :
     140             :         public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
     141             :                                       com::sun::star::task::XInteractionHandler2 >
     142             : {
     143             : public:
     144             :     explicit PasswordContainerInteractionHandler(
     145             :         const com::sun::star::uno::Reference<
     146             :             com::sun::star::uno::XComponentContext >& xContext );
     147             :     virtual ~PasswordContainerInteractionHandler();
     148             : 
     149             :     // XServiceInfo
     150             :     virtual OUString SAL_CALL getImplementationName()
     151             :         throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     152             : 
     153             :     virtual sal_Bool SAL_CALL
     154             :     supportsService( const OUString& ServiceName )
     155             :         throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     156             : 
     157             :     virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
     158             :     getSupportedServiceNames()
     159             :         throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     160             : 
     161             :     // XInteractionHandler2
     162             :     virtual void SAL_CALL
     163             :     handle( const ::com::sun::star::uno::Reference<
     164             :                 ::com::sun::star::task::XInteractionRequest >& Request )
     165             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             : 
     167             :     virtual sal_Bool SAL_CALL
     168             :     handleInteractionRequest( const ::com::sun::star::uno::Reference<
     169             :                 ::com::sun::star::task::XInteractionRequest >& Request )
     170             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             : 
     172             :     // Non-UNO interfaces
     173             :     static OUString
     174             :     getImplementationName_Static();
     175             : 
     176             :     static com::sun::star::uno::Sequence< OUString >
     177             :     getSupportedServiceNames_Static();
     178             : 
     179             :     static com::sun::star::uno::Reference<
     180             :             com::sun::star::lang::XSingleServiceFactory >
     181             :     createServiceFactory( const com::sun::star::uno::Reference<
     182             :             com::sun::star::lang::XMultiServiceFactory > & rxServiceMgr );
     183             : 
     184             : private:
     185             :     //com::sun::star::uno::Reference<
     186             :     //    com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
     187             :     PasswordContainerHelper m_aPwContainerHelper;
     188             : };
     189             : 
     190             : } // namespace uui
     191             : 
     192             : #endif
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11