merged tag ooo/DEV300_m102
[LibreOffice.git] / uui / source / passwordcontainer.hxx
blobaafcd1c4c1dd334104e6839e35f0caf79c9d4f81
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef INCLUDED_UUI_PASSWORDCONTAINER_HXX
29 #define INCLUDED_UUI_PASSWORDCONTAINER_HXX
31 #include "cppuhelper/implbase2.hxx"
33 #include "com/sun/star/lang/XServiceInfo.hpp"
34 #include "com/sun/star/lang/XSingleServiceFactory.hpp"
35 #include "com/sun/star/task/XInteractionHandler.hpp"
36 #include "com/sun/star/task/XPasswordContainer.hpp"
38 namespace com {
39 namespace sun {
40 namespace star {
41 namespace lang {
42 class XMultiServiceFactory;
44 namespace ucb {
45 class AuthenticationRequest;
46 class XInteractionSupplyAuthentication;
47 } } } }
49 namespace uui {
51 // ============================================================================
53 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
55 class PasswordContainerHelper
57 public:
58 PasswordContainerHelper(
59 com::sun::star::uno::Reference<
60 com::sun::star::lang::XMultiServiceFactory > const &
61 xServiceFactory );
63 // ------------------------------------------------------------------------
65 /** This member function tries to handle an authentication interaction
66 request by looking up credentials for the given URL in the password
67 container service.
69 In case of success the given interaction continuation
70 (XInteractionSupplyAuthentication) is filled with the credentials found
71 in the password container.
73 Please note the the continuation gets not "selected" by this
74 implementation. "Selecting" the continuation is up to the caller (e.g.
75 an implementation of XInteractionHandler::handle) of this function.
77 @param rRequest
78 The authentication request.
80 @param xSupplyAuthentication
81 The "supply authentication" interaction continuation.
83 @param rURL
84 The URL to lookup credentials for.
86 @param xIH
87 The interaction handler to use, for example if a master password is
88 needed to access the password container.
90 @return
91 True, if the authentication request was handled successfully.
92 False, otherwise.
94 bool handleAuthenticationRequest(
95 com::sun::star::ucb::AuthenticationRequest const & rRequest,
96 com::sun::star::uno::Reference<
97 com::sun::star::ucb::XInteractionSupplyAuthentication > const &
98 xSupplyAuthentication,
99 rtl::OUString const & rURL,
100 com::sun::star::uno::Reference<
101 com::sun::star::task::XInteractionHandler > const & xIH )
102 SAL_THROW( (com::sun::star::uno::RuntimeException) );
104 /** This member function adds credentials for the given URL to the password
105 container.
107 @param rURL
108 The URL the credentials are valid for. rURL must not be empty.
110 @param rUsername
111 The user name.
113 @param rPasswords
114 This list of passwords.
116 @param xIH
117 The interaction handler to use, for example if a master password is
118 needed to access the password container.
120 @param bPersist
121 True, the record will get stored persistently; restored upon
122 password container initialization
123 False, the record will be stored until password container instance
124 gets destroyed.
126 @return
127 True, if the record was added successfully.
128 False, otherwise.
131 bool addRecord( rtl::OUString const & rURL,
132 rtl::OUString const & rUsername,
133 com::sun::star::uno::Sequence< rtl::OUString > const &
134 rPasswords,
135 com::sun::star::uno::Reference<
136 com::sun::star::task::XInteractionHandler > const & xIH,
137 bool bPersist )
138 SAL_THROW( (com::sun::star::uno::RuntimeException) );
140 // ------------------------------------------------------------------------
142 private:
143 com::sun::star::uno::Reference<
144 com::sun::star::task::XPasswordContainer > m_xPasswordContainer;
147 // ============================================================================
149 class PasswordContainerInteractionHandler :
150 public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
151 com::sun::star::task::XInteractionHandler >
153 public:
154 PasswordContainerInteractionHandler(
155 const com::sun::star::uno::Reference<
156 com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
157 virtual ~PasswordContainerInteractionHandler();
159 // XServiceInfo
160 virtual ::rtl::OUString SAL_CALL getImplementationName()
161 throw ( com::sun::star::uno::RuntimeException );
163 virtual sal_Bool SAL_CALL
164 supportsService( const ::rtl::OUString& ServiceName )
165 throw ( com::sun::star::uno::RuntimeException );
167 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
168 getSupportedServiceNames()
169 throw ( com::sun::star::uno::RuntimeException );
171 // XInteractionHandler
172 virtual void SAL_CALL
173 handle( const ::com::sun::star::uno::Reference<
174 ::com::sun::star::task::XInteractionRequest >& Request )
175 throw (::com::sun::star::uno::RuntimeException);
177 // Non-UNO interfaces
178 static rtl::OUString
179 getImplementationName_Static();
181 static com::sun::star::uno::Sequence< rtl::OUString >
182 getSupportedServiceNames_Static();
184 static com::sun::star::uno::Reference<
185 com::sun::star::lang::XSingleServiceFactory >
186 createServiceFactory( const com::sun::star::uno::Reference<
187 com::sun::star::lang::XMultiServiceFactory > & rxServiceMgr );
189 private:
190 //com::sun::star::uno::Reference<
191 // com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
192 PasswordContainerHelper m_aPwContainerHelper;
195 } // namespace uui
197 #endif