Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX
21 : #define _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX
22 :
23 : #include <rtl/ref.hxx>
24 : #include <ucbhelper/interactionrequest.hxx>
25 : #include "ucbhelper/ucbhelperdllapi.h"
26 :
27 : namespace com { namespace sun { namespace star { namespace ucb {
28 : class URLAuthenticationRequest;
29 : } } } }
30 :
31 : namespace ucbhelper {
32 :
33 : /**
34 : * This class implements a simple authentication interaction request.
35 : * Instances can be passed directly to XInteractionHandler::handle(...). Each
36 : * instance contains an AuthenticationRequest and three interaction
37 : * continuations: "Abort", "Retry" and "SupplyAuthentication". The parameters
38 : * for the AuthenticationRequest and the InteractionSupplyAuthentication
39 : * objects are partly taken from contructors parameters and partly defaulted
40 : * as follows:
41 : *
42 : * Read-only values : servername, realm
43 : * Read-write values: username, password, account
44 : * All remember-authentication values: RememberAuthentication_NO
45 : *
46 : * @see com::sun::star::ucb::AuthenticationRequest
47 : * @see com::sun::star::ucb::RememberAuthentication
48 : * @see InteractionAbort
49 : * @see InteractionRetry
50 : * @see InteractionSupplyAuthentication
51 : */
52 0 : class UCBHELPER_DLLPUBLIC SimpleAuthenticationRequest : public ucbhelper::InteractionRequest
53 : {
54 : rtl::Reference<
55 : ucbhelper::InteractionSupplyAuthentication > m_xAuthSupplier;
56 :
57 : private:
58 : void initialize( const ::com::sun::star::ucb::URLAuthenticationRequest & rRequest,
59 : sal_Bool bCanSetRealm,
60 : sal_Bool bCanSetUserName,
61 : sal_Bool bCanSetPassword,
62 : sal_Bool bCanSetAccount,
63 : sal_Bool bAllowPersistentStoring,
64 : sal_Bool bAllowUseSystemCredentials );
65 :
66 : public:
67 : /** Specification whether some entity (realm, username, password, account)
68 : is either not applicable at all, has a fixed value, or is modifiable.
69 : */
70 : enum EntityType
71 : {
72 : ENTITY_NA,
73 : ENTITY_FIXED,
74 : ENTITY_MODIFY
75 : };
76 :
77 : /**
78 : * Constructor.
79 : *
80 : * @param rURL contains a URL for which authentication is requested.
81 : * @param rServerName contains a server name.
82 : * @param rRealm contains a realm, if applicable.
83 : * @param rUserName contains a username, if available (for instance from
84 : * a previous try).
85 : * @param rPassword contains a password, if available (for instance from
86 : * a previous try).
87 : * @param rAccount contains an account, if applicable.
88 : * @param bAllowPersistentStoring specifies if the credentials should
89 : * be stored in the passowrd container persistently
90 : * @param bAllowUseSystemCredntials specifies if requesting client is
91 : * able to obtain and use system credentials for authentication
92 : */
93 : SimpleAuthenticationRequest( const rtl::OUString & rURL,
94 : const rtl::OUString & rServerName,
95 : const rtl::OUString & rRealm,
96 : const rtl::OUString & rUserName,
97 : const rtl::OUString & rPassword,
98 : const rtl::OUString & rAccount,
99 : sal_Bool bAllowPersistentStoring,
100 : sal_Bool bAllowUseSystemCredentials );
101 :
102 :
103 : /**
104 : * Constructor.
105 : *
106 : * @param rServerName contains a server name.
107 : * @param eRealmType specifies whether a realm is applicable and
108 : modifiable.
109 : * @param rRealm contains a realm, if applicable.
110 : * @param eUserNameType specifies whether a username is applicable and
111 : modifiable.
112 : * @param rUserName contains a username, if available (for instance from
113 : * a previous try).
114 : * @param ePasswordType specifies whether a password is applicable and
115 : modifiable.
116 : * @param rPassword contains a password, if available (for instance from
117 : * a previous try).
118 : * @param eAccountType specifies whether an account is applicable and
119 : modifiable.
120 : * @param rAccount contains an account, if applicable.
121 : */
122 : SimpleAuthenticationRequest( const rtl::OUString & rURL,
123 : const rtl::OUString & rServerName,
124 : EntityType eRealmType,
125 : const rtl::OUString & rRealm,
126 : EntityType eUserNameType,
127 : const rtl::OUString & rUserName,
128 : EntityType ePasswordType,
129 : const rtl::OUString & rPassword,
130 : EntityType eAccountType = ENTITY_NA,
131 : const rtl::OUString & rAccount
132 : = rtl::OUString() );
133 :
134 : /**
135 : * This method returns the supplier for the missing authentication data,
136 : * that, for instance can be used to query the password supplied by the
137 : * interaction handler.
138 : *
139 : * @return the supplier for the missing authentication data.
140 : */
141 : const rtl::Reference< ucbhelper::InteractionSupplyAuthentication > &
142 0 : getAuthenticationSupplier() const { return m_xAuthSupplier; }
143 : };
144 :
145 : } // namespace ucbhelper
146 :
147 : #endif /* !_UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX */
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|