Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / uui / source / passwordcontainer.hxx
blobcd29fb308ac6e19402dc423a6cfea49cdb8c334d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_UUI_PASSWORDCONTAINER_HXX
30 #define INCLUDED_UUI_PASSWORDCONTAINER_HXX
32 #include "cppuhelper/implbase2.hxx"
34 #include "com/sun/star/lang/XServiceInfo.hpp"
35 #include "com/sun/star/lang/XSingleServiceFactory.hpp"
36 #include "com/sun/star/task/XInteractionHandler.hpp"
37 #include "com/sun/star/task/XPasswordContainer.hpp"
39 namespace com {
40 namespace sun {
41 namespace star {
42 namespace lang {
43 class XMultiServiceFactory;
45 namespace ucb {
46 class AuthenticationRequest;
47 class XInteractionSupplyAuthentication;
48 } } } }
50 namespace uui {
52 // ============================================================================
54 /** Passwordcontainer UNO service (com.sun.star.task.PasswordContainer) helper.
56 class PasswordContainerHelper
58 public:
59 PasswordContainerHelper(
60 com::sun::star::uno::Reference<
61 com::sun::star::lang::XMultiServiceFactory > const &
62 xServiceFactory );
64 // ------------------------------------------------------------------------
66 /** This member function tries to handle an authentication interaction
67 request by looking up credentials for the given URL in the password
68 container service.
70 In case of success the given interaction continuation
71 (XInteractionSupplyAuthentication) is filled with the credentials found
72 in the password container.
74 Please note the the continuation gets not "selected" by this
75 implementation. "Selecting" the continuation is up to the caller (e.g.
76 an implementation of XInteractionHandler::handle) of this function.
78 @param rRequest
79 The authentication request.
81 @param xSupplyAuthentication
82 The "supply authentication" interaction continuation.
84 @param rURL
85 The URL to lookup credentials for.
87 @param xIH
88 The interaction handler to use, for example if a master password is
89 needed to access the password container.
91 @return
92 True, if the authentication request was handled successfully.
93 False, otherwise.
95 bool handleAuthenticationRequest(
96 com::sun::star::ucb::AuthenticationRequest const & rRequest,
97 com::sun::star::uno::Reference<
98 com::sun::star::ucb::XInteractionSupplyAuthentication > const &
99 xSupplyAuthentication,
100 rtl::OUString const & rURL,
101 com::sun::star::uno::Reference<
102 com::sun::star::task::XInteractionHandler > const & xIH )
103 SAL_THROW( (com::sun::star::uno::RuntimeException) );
105 /** This member function adds credentials for the given URL to the password
106 container.
108 @param rURL
109 The URL the credentials are valid for. rURL must not be empty.
111 @param rUsername
112 The user name.
114 @param rPasswords
115 This list of passwords.
117 @param xIH
118 The interaction handler to use, for example if a master password is
119 needed to access the password container.
121 @param bPersist
122 True, the record will get stored persistently; restored upon
123 password container initialization
124 False, the record will be stored until password container instance
125 gets destroyed.
127 @return
128 True, if the record was added successfully.
129 False, otherwise.
132 bool addRecord( rtl::OUString const & rURL,
133 rtl::OUString const & rUsername,
134 com::sun::star::uno::Sequence< rtl::OUString > const &
135 rPasswords,
136 com::sun::star::uno::Reference<
137 com::sun::star::task::XInteractionHandler > const & xIH,
138 bool bPersist )
139 SAL_THROW( (com::sun::star::uno::RuntimeException) );
141 // ------------------------------------------------------------------------
143 private:
144 com::sun::star::uno::Reference<
145 com::sun::star::task::XPasswordContainer > m_xPasswordContainer;
148 // ============================================================================
150 class PasswordContainerInteractionHandler :
151 public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo,
152 com::sun::star::task::XInteractionHandler >
154 public:
155 PasswordContainerInteractionHandler(
156 const com::sun::star::uno::Reference<
157 com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
158 virtual ~PasswordContainerInteractionHandler();
160 // XServiceInfo
161 virtual ::rtl::OUString SAL_CALL getImplementationName()
162 throw ( com::sun::star::uno::RuntimeException );
164 virtual sal_Bool SAL_CALL
165 supportsService( const ::rtl::OUString& ServiceName )
166 throw ( com::sun::star::uno::RuntimeException );
168 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
169 getSupportedServiceNames()
170 throw ( com::sun::star::uno::RuntimeException );
172 // XInteractionHandler
173 virtual void SAL_CALL
174 handle( const ::com::sun::star::uno::Reference<
175 ::com::sun::star::task::XInteractionRequest >& Request )
176 throw (::com::sun::star::uno::RuntimeException);
178 // Non-UNO interfaces
179 static rtl::OUString
180 getImplementationName_Static();
182 static com::sun::star::uno::Sequence< rtl::OUString >
183 getSupportedServiceNames_Static();
185 static com::sun::star::uno::Reference<
186 com::sun::star::lang::XSingleServiceFactory >
187 createServiceFactory( const com::sun::star::uno::Reference<
188 com::sun::star::lang::XMultiServiceFactory > & rxServiceMgr );
190 private:
191 //com::sun::star::uno::Reference<
192 // com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
193 PasswordContainerHelper m_aPwContainerHelper;
196 } // namespace uui
198 #endif
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */