1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_UUI_SOURCE_PASSWORDCONTAINER_HXX
21 #define INCLUDED_UUI_SOURCE_PASSWORDCONTAINER_HXX
23 #include <cppuhelper/implbase.hxx>
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>
34 class XMultiServiceFactory
;
37 class AuthenticationRequest
;
38 class XInteractionSupplyAuthentication
;
44 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
46 class PasswordContainerHelper
49 explicit PasswordContainerHelper(
50 css::uno::Reference
< css::uno::XComponentContext
> const & xContext
);
53 /** This member function tries to handle an authentication interaction
54 request by looking up credentials for the given URL in the password
57 In case of success the given interaction continuation
58 (XInteractionSupplyAuthentication) is filled with the credentials found
59 in the password container.
61 Please note the continuation gets not "selected" by this
62 implementation. "Selecting" the continuation is up to the caller (e.g.
63 an implementation of XInteractionHandler::handle) of this function.
66 The authentication request.
68 @param xSupplyAuthentication
69 The "supply authentication" interaction continuation.
72 The URL to lookup credentials for.
75 The interaction handler to use, for example if a master password is
76 needed to access the password container.
79 True, if the authentication request was handled successfully.
82 bool handleAuthenticationRequest(
83 css::ucb::AuthenticationRequest
const & rRequest
,
84 css::uno::Reference
< css::ucb::XInteractionSupplyAuthentication
> const & xSupplyAuthentication
,
85 OUString
const & rURL
,
86 css::uno::Reference
< css::task::XInteractionHandler2
> const & xIH
);
88 /** This member function adds credentials for the given URL to the password
92 The URL the credentials are valid for. rURL must not be empty.
98 This list of passwords.
101 The interaction handler to use, for example if a master password is
102 needed to access the password container.
105 True, the record will get stored persistently; restored upon
106 password container initialization
107 False, the record will be stored until password container instance
111 True, if the record was added successfully.
115 bool addRecord( OUString
const & rURL
,
116 OUString
const & rUsername
,
117 css::uno::Sequence
< OUString
> const & rPasswords
,
118 css::uno::Reference
< css::task::XInteractionHandler2
> const & xIH
,
123 css::uno::Reference
< css::task::XPasswordContainer2
> m_xPasswordContainer
;
127 class PasswordContainerInteractionHandler
:
128 public cppu::WeakImplHelper
< css::lang::XServiceInfo
,
129 css::task::XInteractionHandler2
>
132 explicit PasswordContainerInteractionHandler(
133 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
134 virtual ~PasswordContainerInteractionHandler() override
;
137 virtual OUString SAL_CALL
getImplementationName() override
;
139 virtual sal_Bool SAL_CALL
140 supportsService( const OUString
& ServiceName
) override
;
142 virtual css::uno::Sequence
< OUString
> SAL_CALL
143 getSupportedServiceNames() override
;
145 // XInteractionHandler2
146 virtual void SAL_CALL
147 handle( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
149 virtual sal_Bool SAL_CALL
150 handleInteractionRequest( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
152 // Non-UNO interfaces
154 getImplementationName_Static();
156 static css::uno::Sequence
< OUString
>
157 getSupportedServiceNames_Static();
159 static css::uno::Reference
< css::lang::XSingleServiceFactory
>
160 createServiceFactory( const css::uno::Reference
< css::lang::XMultiServiceFactory
> & rxServiceMgr
);
163 PasswordContainerHelper m_aPwContainerHelper
;
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */