Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / uui / source / passwordcontainer.hxx
blobd4bdf32f9d9dc8849d5a8fdfc2df29b32e56c669
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
30 namespace com {
31 namespace sun {
32 namespace star {
33 namespace lang {
34 class XMultiServiceFactory;
36 namespace ucb {
37 class AuthenticationRequest;
38 class XInteractionSupplyAuthentication;
39 } } } }
41 namespace uui {
44 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
46 class PasswordContainerHelper
48 public:
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
55 container service.
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.
65 @param rRequest
66 The authentication request.
68 @param xSupplyAuthentication
69 The "supply authentication" interaction continuation.
71 @param rURL
72 The URL to lookup credentials for.
74 @param xIH
75 The interaction handler to use, for example if a master password is
76 needed to access the password container.
78 @return
79 True, if the authentication request was handled successfully.
80 False, otherwise.
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
89 container.
91 @param rURL
92 The URL the credentials are valid for. rURL must not be empty.
94 @param rUsername
95 The user name.
97 @param rPasswords
98 This list of passwords.
100 @param xIH
101 The interaction handler to use, for example if a master password is
102 needed to access the password container.
104 @param bPersist
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
108 gets destroyed.
110 @return
111 True, if the record was added successfully.
112 False, otherwise.
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,
119 bool bPersist );
122 private:
123 css::uno::Reference< css::task::XPasswordContainer2 > m_xPasswordContainer;
127 class PasswordContainerInteractionHandler :
128 public cppu::WeakImplHelper< css::lang::XServiceInfo,
129 css::task::XInteractionHandler2 >
131 public:
132 explicit PasswordContainerInteractionHandler(
133 const css::uno::Reference< css::uno::XComponentContext >& xContext );
134 virtual ~PasswordContainerInteractionHandler() override;
136 // XServiceInfo
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
153 static OUString
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 );
162 private:
163 PasswordContainerHelper m_aPwContainerHelper;
166 } // namespace uui
168 #endif
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */