nss: upgrade to release 3.73
[LibreOffice.git] / uui / source / passwordcontainer.hxx
blobcb4d5a533507970a1761fae285a4a67b83854217
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>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 namespace com {
32 namespace sun {
33 namespace star {
34 namespace lang {
35 class XMultiServiceFactory;
37 namespace ucb {
38 class AuthenticationRequest;
39 class XInteractionSupplyAuthentication;
40 } } } }
42 namespace uui {
45 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
47 class PasswordContainerHelper
49 public:
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
56 container service.
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.
66 @param rRequest
67 The authentication request.
69 @param xSupplyAuthentication
70 The "supply authentication" interaction continuation.
72 @param rURL
73 The URL to lookup credentials for.
75 @param xIH
76 The interaction handler to use, for example if a master password is
77 needed to access the password container.
79 @return
80 True, if the authentication request was handled successfully.
81 False, otherwise.
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
90 container.
92 @param rURL
93 The URL the credentials are valid for. rURL must not be empty.
95 @param rUsername
96 The user name.
98 @param rPasswords
99 This list of passwords.
101 @param xIH
102 The interaction handler to use, for example if a master password is
103 needed to access the password container.
105 @param bPersist
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
109 gets destroyed.
111 @return
112 True, if the record was added successfully.
113 False, otherwise.
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,
120 bool bPersist );
123 private:
124 css::uno::Reference< css::task::XPasswordContainer2 > m_xPasswordContainer;
128 class PasswordContainerInteractionHandler :
129 public cppu::WeakImplHelper< css::lang::XServiceInfo,
130 css::task::XInteractionHandler2 >
132 public:
133 explicit PasswordContainerInteractionHandler(
134 const css::uno::Reference< css::uno::XComponentContext >& xContext );
135 virtual ~PasswordContainerInteractionHandler() override;
137 // XServiceInfo
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;
153 private:
154 PasswordContainerHelper m_aPwContainerHelper;
157 } // namespace uui
159 #endif
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */