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>
29 #include <com/sun/star/uno/XComponentContext.hpp>
35 class XMultiServiceFactory
;
38 class AuthenticationRequest
;
39 class XInteractionSupplyAuthentication
;
45 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
47 class PasswordContainerHelper
50 explicit PasswordContainerHelper(
51 css::uno::Reference
< css::uno::XComponentContext
> const & xContext
);
54 /** This member function tries to handle an authentication interaction
55 request by looking up credentials for the given URL in the password
58 In case of success the given interaction continuation
59 (XInteractionSupplyAuthentication) is filled with the credentials found
60 in the password container.
62 Please note the continuation gets not "selected" by this
63 implementation. "Selecting" the continuation is up to the caller (e.g.
64 an implementation of XInteractionHandler::handle) of this function.
67 The authentication request.
69 @param xSupplyAuthentication
70 The "supply authentication" interaction continuation.
73 The URL to lookup credentials for.
76 The interaction handler to use, for example if a master password is
77 needed to access the password container.
80 True, if the authentication request was handled successfully.
83 bool handleAuthenticationRequest(
84 css::ucb::AuthenticationRequest
const & rRequest
,
85 css::uno::Reference
< css::ucb::XInteractionSupplyAuthentication
> const & xSupplyAuthentication
,
86 OUString
const & rURL
,
87 css::uno::Reference
< css::task::XInteractionHandler2
> const & xIH
);
89 /** This member function adds credentials for the given URL to the password
93 The URL the credentials are valid for. rURL must not be empty.
99 This list of passwords.
102 The interaction handler to use, for example if a master password is
103 needed to access the password container.
106 True, the record will get stored persistently; restored upon
107 password container initialization
108 False, the record will be stored until password container instance
112 True, if the record was added successfully.
116 bool addRecord( OUString
const & rURL
,
117 OUString
const & rUsername
,
118 css::uno::Sequence
< OUString
> const & rPasswords
,
119 css::uno::Reference
< css::task::XInteractionHandler2
> const & xIH
,
124 css::uno::Reference
< css::task::XPasswordContainer2
> m_xPasswordContainer
;
128 class PasswordContainerInteractionHandler
:
129 public cppu::WeakImplHelper
< css::lang::XServiceInfo
,
130 css::task::XInteractionHandler2
>
133 explicit PasswordContainerInteractionHandler(
134 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
135 virtual ~PasswordContainerInteractionHandler() override
;
138 virtual OUString SAL_CALL
getImplementationName() override
;
140 virtual sal_Bool SAL_CALL
141 supportsService( const OUString
& ServiceName
) override
;
143 virtual css::uno::Sequence
< OUString
> SAL_CALL
144 getSupportedServiceNames() override
;
146 // XInteractionHandler2
147 virtual void SAL_CALL
148 handle( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
150 virtual sal_Bool SAL_CALL
151 handleInteractionRequest( const css::uno::Reference
< css::task::XInteractionRequest
>& Request
) override
;
154 PasswordContainerHelper m_aPwContainerHelper
;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */