1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX 25 #define _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX 26 27 #include <rtl/ref.hxx> 28 #include <ucbhelper/interactionrequest.hxx> 29 #include "ucbhelper/ucbhelperdllapi.h" 30 31 namespace com { namespace sun { namespace star { namespace ucb { 32 class URLAuthenticationRequest; 33 } } } } 34 35 namespace ucbhelper { 36 37 /** 38 * This class implements a simple authentication interaction request. 39 * Instances can be passed directly to XInteractionHandler::handle(...). Each 40 * instance contains an AuthenticationRequest and three interaction 41 * continuations: "Abort", "Retry" and "SupplyAuthentication". The parameters 42 * for the AuthenticationRequest and the InteractionSupplyAuthentication 43 * objects are partly taken from contructors parameters and partly defaulted 44 * as follows: 45 * 46 * Read-only values : servername, realm 47 * Read-write values: username, password, account 48 * All remember-authentication values: RememberAuthentication_NO 49 * 50 * @see com::sun::star::ucb::AuthenticationRequest 51 * @see com::sun::star::ucb::RememberAuthentication 52 * @see InteractionAbort 53 * @see InteractionRetry 54 * @see InteractionSupplyAuthentication 55 */ 56 class UCBHELPER_DLLPUBLIC SimpleAuthenticationRequest : public ucbhelper::InteractionRequest 57 { 58 rtl::Reference< 59 ucbhelper::InteractionSupplyAuthentication > m_xAuthSupplier; 60 61 private: 62 void initialize( const ::com::sun::star::ucb::URLAuthenticationRequest & rRequest, 63 sal_Bool bCanSetRealm, 64 sal_Bool bCanSetUserName, 65 sal_Bool bCanSetPassword, 66 sal_Bool bCanSetAccount, 67 sal_Bool bAllowPersistentStoring, 68 sal_Bool bAllowUseSystemCredentials ); 69 70 public: 71 /** Specification whether some entity (realm, username, password, account) 72 is either not applicable at all, has a fixed value, or is modifiable. 73 */ 74 enum EntityType 75 { 76 ENTITY_NA, 77 ENTITY_FIXED, 78 ENTITY_MODIFY 79 }; 80 81 /** 82 * Constructor. 83 * 84 * @param rURL contains a URL for which authentication is requested. 85 * @param rServerName contains a server name. 86 * @param rRealm contains a realm, if applicable. 87 * @param rUserName contains a username, if available (for instance from 88 * a previous try). 89 * @param rPassword contains a password, if available (for instance from 90 * a previous try). 91 * @param rAccount contains an account, if applicable. 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 = rtl::OUString() ); 100 101 /** 102 * Constructor. 103 * 104 * @param rURL contains a URL for which authentication is requested. 105 * @param rServerName contains a server name. 106 * @param rRealm contains a realm, if applicable. 107 * @param rUserName contains a username, if available (for instance from 108 * a previous try). 109 * @param rPassword contains a password, if available (for instance from 110 * a previous try). 111 * @param rAccount contains an account, if applicable. 112 * @param bAllowPersistentStoring specifies if the credentials should 113 * be stored in the passowrd container persistently 114 * @param bAllowUseSystemCredntials specifies if requesting client is 115 * able to obtain and use system credentials for authentication 116 */ 117 SimpleAuthenticationRequest( const rtl::OUString & rURL, 118 const rtl::OUString & rServerName, 119 const rtl::OUString & rRealm, 120 const rtl::OUString & rUserName, 121 const rtl::OUString & rPassword, 122 const rtl::OUString & rAccount, 123 sal_Bool bAllowPersistentStoring, 124 sal_Bool bAllowUseSystemCredentials ); 125 126 127 /** 128 * Constructor. 129 * 130 * @param rServerName contains a server name. 131 * @param eRealmType specifies whether a realm is applicable and 132 modifiable. 133 * @param rRealm contains a realm, if applicable. 134 * @param eUserNameType specifies whether a username is applicable and 135 modifiable. 136 * @param rUserName contains a username, if available (for instance from 137 * a previous try). 138 * @param ePasswordType specifies whether a password is applicable and 139 modifiable. 140 * @param rPassword contains a password, if available (for instance from 141 * a previous try). 142 * @param eAccountType specifies whether an account is applicable and 143 modifiable. 144 * @param rAccount contains an account, if applicable. 145 */ 146 SimpleAuthenticationRequest( const rtl::OUString & rURL, 147 const rtl::OUString & rServerName, 148 EntityType eRealmType, 149 const rtl::OUString & rRealm, 150 EntityType eUserNameType, 151 const rtl::OUString & rUserName, 152 EntityType ePasswordType, 153 const rtl::OUString & rPassword, 154 EntityType eAccountType = ENTITY_NA, 155 const rtl::OUString & rAccount 156 = rtl::OUString() ); 157 158 /** 159 * Constructor. 160 * 161 * @param rURL contains a URL for which authentication is requested. 162 * @param rServerName contains a server name. 163 * @param eRealmType specifies whether a realm is applicable and 164 modifiable. 165 * @param rRealm contains a realm, if applicable. 166 * @param eUserNameType specifies whether a username is applicable and 167 modifiable. 168 * @param rUserName contains a username, if available (for instance from 169 * a previous try). 170 * @param ePasswordType specifies whether a password is applicable and 171 modifiable. 172 * @param rPassword contains a password, if available (for instance from 173 * a previous try). 174 * @param eAccountType specifies whether an account is applicable and 175 modifiable. 176 * @param rAccount contains an account, if applicable. 177 * @param bAllowPersistentStoring specifies if the credentials should 178 * be stored in the passowrd container persistently 179 * @param bAllowUseSystemCredntials specifies if requesting client is 180 * able to obtain and use system credentials for authentication 181 */ 182 SimpleAuthenticationRequest( const rtl::OUString & rURL, 183 const rtl::OUString & rServerName, 184 EntityType eRealmType, 185 const rtl::OUString & rRealm, 186 EntityType eUserNameType, 187 const rtl::OUString & rUserName, 188 EntityType ePasswordType, 189 const rtl::OUString & rPassword, 190 EntityType eAccountType, 191 const rtl::OUString & rAccount, 192 sal_Bool bAllowPersistentStoring, 193 sal_Bool bAllowUseSystemCredentials ); 194 195 /** 196 * This method returns the supplier for the missing authentication data, 197 * that, for instance can be used to query the password supplied by the 198 * interaction handler. 199 * 200 * @return the supplier for the missing authentication data. 201 */ 202 const rtl::Reference< ucbhelper::InteractionSupplyAuthentication > & getAuthenticationSupplier() const203 getAuthenticationSupplier() const { return m_xAuthSupplier; } 204 }; 205 206 } // namespace ucbhelper 207 208 #endif /* !_UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX */ 209