diff options
-rw-r--r-- | uui/inc/ids.hrc | 22 | ||||
-rw-r--r-- | uui/inc/ids.hxx | 15 | ||||
-rw-r--r-- | uui/source/iahndl-ssl.cxx | 58 |
3 files changed, 36 insertions, 59 deletions
diff --git a/uui/inc/ids.hrc b/uui/inc/ids.hrc index 2156b63bd1b6..27777cf45ebf 100644 --- a/uui/inc/ids.hrc +++ b/uui/inc/ids.hrc @@ -150,25 +150,19 @@ const std::pair<const char*, ErrCode> RID_UUI_ERRHDL[] = ErrCode(sal_uInt32(ERRCODE_UUI_LOCKING_NOT_LOCKED) & ERRCODE_RES_MASK) }, { NC_("RID_UUI_ERRHDL", "The previously obtained lock for file $(ARG1) has expired.\nThis can happen due to problems on the server managing the file lock. It cannot be guaranteed that write operations on this file will not overwrite changes done by other users!"), ErrCode(sal_uInt32(ERRCODE_UUI_LOCKING_LOCK_EXPIRED) & ERRCODE_RES_MASK) }, - { NC_("RID_UUI_ERRHDL", "Unable to verify the identity of $(ARG1) site.\n\nBefore accepting this certificate, you should examine this site's certificate carefully. Are you willing to accept this certificate for the purpose of identifying the Web site $(ARG1)?"), - ErrCode(sal_uInt32(ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED)) }, - { NC_("RID_UUI_ERRHDL", "$(ARG1) is a site that uses a security certificate to encrypt data during transmission, but its certificate expired on $(ARG2).\n\nYou should check to make sure that your computer's time is correct."), - ErrCode(sal_uInt32(ERRCODE_UUI_SSLWARN_EXPIRED_1)) }, - { NC_("RID_UUI_ERRHDL", "You have attempted to establish a connection with $(ARG1). However, the security certificate presented belongs to $(ARG2). It is possible, though unlikely, that someone may be trying to intercept your communication with this web site.\n\nIf you suspect the certificate shown does not belong to $(ARG1), please cancel the connection and notify the site administrator.\n\nWould you like to continue anyway?"), - ErrCode(sal_uInt32(ERRCODE_UUI_SSLWARN_DOMAINMISMATCH_1)) }, - { NC_("RID_UUI_ERRHDL", "The certificate could not be validated. You should examine this site's certificate carefully.\n\nIf you suspect the certificate shown, please cancel the connection and notify the site administrator."), - ErrCode(sal_uInt32(ERRCODE_UUI_SSLWARN_INVALID_1)) }, - { NC_("RID_UUI_ERRHDL", "Security Warning: Domain Name Mismatch"), - ErrCode(TITLE_UUI_SSLWARN_DOMAINMISMATCH) }, - { NC_("RID_UUI_ERRHDL", "Security Warning: Server Certificate Expired"), - ErrCode(TITLE_UUI_SSLWARN_EXPIRED) }, - { NC_("RID_UUI_ERRHDL", "Security Warning: Server Certificate Invalid"), - ErrCode(TITLE_UUI_SSLWARN_INVALID) }, { NC_("RID_UUI_ERRHDL", "Component cannot be loaded, possibly broken or incomplete installation.\nFull error message:\n\n $(ARG1)."), ErrCode(sal_uInt32(ERRCODE_UUI_CANNOT_ACTIVATE_FACTORY) & ERRCODE_RES_MASK) }, { nullptr, ERRCODE_NONE } }; +#define STR_UUI_UNKNOWNAUTH_UNTRUSTED NC_("STR_UUI_UNKNOWNAUTH_UNTRUSTED", "Unable to verify the identity of $(ARG1) site.\n\nBefore accepting this certificate, you should examine this site's certificate carefully. Are you willing to accept this certificate for the purpose of identifying the Web site $(ARG1)?") +#define STR_UUI_SSLWARN_EXPIRED NC_("STR_UUI_SSLWARN_EXPIRED", "$(ARG1) is a site that uses a security certificate to encrypt data during transmission, but its certificate expired on $(ARG2).\n\nYou should check to make sure that your computer's time is correct.") +#define STR_UUI_SSLWARN_EXPIRED_TITLE NC_("STR_UUI_SSLWARN_EXPIRED_TITLE", "Security Warning: Server Certificate Invalid") +#define STR_UUI_SSLWARN_DOMAINMISMATCH NC_("STR_UUI_SSLWARN_DOMAINMISMATCH", "You have attempted to establish a connection with $(ARG1). However, the security certificate presented belongs to $(ARG2). It is possible, though unlikely, that someone may be trying to intercept your communication with this web site.\n\nIf you suspect the certificate shown does not belong to $(ARG1), please cancel the connection and notify the site administrator.\n\nWould you like to continue anyway?") +#define STR_UUI_SSLWARN_DOMAINMISMATCH_TITLE NC_("STR_UUI_SSLWARN_DOMAINMISMATCH_TITLE", "Security Warning: Server Certificate Expired") +#define STR_UUI_SSLWARN_INVALID NC_("STR_UUI_SSLWARN_INVALID", "The certificate could not be validated. You should examine this site's certificate carefully.\n\nIf you suspect the certificate shown, please cancel the connection and notify the site administrator.") +#define STR_UUI_SSLWARN_INVALID_TITLE NC_("STR_UUI_SSLWARN_INVALID_TITLE", "Security Warning: Domain Name Mismatch") + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/inc/ids.hxx b/uui/inc/ids.hxx index cccd0d36923e..15d2e12892d9 100644 --- a/uui/inc/ids.hxx +++ b/uui/inc/ids.hxx @@ -86,21 +86,6 @@ #define ERRCODE_UUI_LOCKING_NOT_LOCKED ErrCode(ERRCODE_AREA_UUI + 61) #define ERRCODE_UUI_LOCKING_LOCK_EXPIRED ErrCode(ERRCODE_AREA_UUI + 62) #define ERRCODE_UUI_CANNOT_ACTIVATE_FACTORY ErrCode(ERRCODE_AREA_UUI + 63) -#define ERRCODE_AREA_UUI_UNKNOWNAUTH 25000 -#define SSLWARN_TYPE_DOMAINMISMATCH 10 -#define SSLWARN_TYPE_EXPIRED 20 -#define SSLWARN_TYPE_INVALID 30 - -#define ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED ErrCode(ERRCODE_AREA_UUI_UNKNOWNAUTH + 1) - -#define ERRCODE_UUI_SSLWARN_EXPIRED_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_EXPIRED + 1) -#define TITLE_UUI_SSLWARN_EXPIRED (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_EXPIRED + 3) - -#define ERRCODE_UUI_SSLWARN_DOMAINMISMATCH_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_DOMAINMISMATCH + 1) -#define TITLE_UUI_SSLWARN_DOMAINMISMATCH (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_DOMAINMISMATCH + 3) - -#define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1) -#define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3) #endif diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index e27efb9ff10f..37126ca23361 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -45,9 +45,6 @@ #include <memory> -#define DESCRIPTION_1 1 -#define TITLE 3 - #define OID_SUBJECT_ALTERNATIVE_NAME "2.5.29.17" @@ -158,12 +155,10 @@ executeUnknownAuthDialog( std::locale aResLocale(Translate::Create("uui")); ErrorResource aErrorResource(RID_UUI_ERRHDL, aResLocale); - if (aErrorResource.getString(ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED, aMessage)) - { - aMessage = UUIInteractionHelper::replaceMessageWithArguments( + aMessage = Translate::get(STR_UUI_UNKNOWNAUTH_UNTRUSTED, aResLocale); + aMessage = UUIInteractionHelper::replaceMessageWithArguments( aMessage, aArguments ); - xDialog->setDescriptionText( aMessage ); - } + xDialog->setDescriptionText( aMessage ); return static_cast<bool>(xDialog->Execute()); } @@ -173,12 +168,16 @@ executeUnknownAuthDialog( } } +enum class SslWarnType { + DOMAINMISMATCH, EXPIRED, INVALID +}; + bool executeSSLWarnDialog( vcl::Window * pParent, uno::Reference< uno::XComponentContext > const & xContext, const uno::Reference< security::XCertificate >& rXCert, - sal_Int32 failure, + SslWarnType failure, const OUString & hostName ) { try @@ -188,18 +187,23 @@ executeSSLWarnDialog( ScopedVclPtrInstance< SSLWarnDialog > xDialog(pParent, rXCert, xContext); // Get correct resource string - OUString aMessage_1; std::vector< OUString > aArguments_1; + char const * pMessageKey = nullptr; + char const * pTitleKey = nullptr; switch( failure ) { - case SSLWARN_TYPE_DOMAINMISMATCH: + case SslWarnType::DOMAINMISMATCH: + pMessageKey = STR_UUI_SSLWARN_DOMAINMISMATCH; + pTitleKey = STR_UUI_SSLWARN_DOMAINMISMATCH_TITLE; aArguments_1.push_back( hostName ); aArguments_1.push_back( getContentPart( rXCert->getSubjectName()) ); aArguments_1.push_back( hostName ); break; - case SSLWARN_TYPE_EXPIRED: + case SslWarnType::EXPIRED: + pMessageKey = STR_UUI_SSLWARN_EXPIRED; + pTitleKey = STR_UUI_SSLWARN_EXPIRED_TITLE; aArguments_1.push_back( getContentPart( rXCert->getSubjectName()) ); aArguments_1.push_back( @@ -209,28 +213,22 @@ executeSSLWarnDialog( getLocalizedDatTimeStr( xContext, rXCert->getNotValidAfter() ) ); break; - case SSLWARN_TYPE_INVALID: + case SslWarnType::INVALID: + pMessageKey = STR_UUI_SSLWARN_INVALID; + pTitleKey = STR_UUI_SSLWARN_INVALID_TITLE; break; + default: assert(false); } std::locale aResLocale(Translate::Create("uui")); - ErrorResource aErrorResource(RID_UUI_ERRHDL, aResLocale); - if (aErrorResource.getString( - ErrCode(ERRCODE_AREA_UUI_UNKNOWNAUTH + failure + DESCRIPTION_1), - aMessage_1)) - { - aMessage_1 = UUIInteractionHelper::replaceMessageWithArguments( + OUString aMessage_1 = Translate::get(pMessageKey, aResLocale); + aMessage_1 = UUIInteractionHelper::replaceMessageWithArguments( aMessage_1, aArguments_1 ); - xDialog->setDescription1Text( aMessage_1 ); - } + xDialog->setDescription1Text( aMessage_1 ); - OUString aTitle; - if (aErrorResource.getString( - ErrCode(ERRCODE_AREA_UUI_UNKNOWNAUTH + failure + TITLE), aTitle)) - { - xDialog->SetText(aTitle); - } + OUString aTitle = Translate::get(pTitleKey, aResLocale); + xDialog->SetText(aTitle); return static_cast<bool>(xDialog->Execute()); } @@ -307,7 +305,7 @@ handleCertificateValidationRequest_( trustCert = executeSSLWarnDialog( pParent, xContext, rRequest.Certificate, - SSLWARN_TYPE_DOMAINMISMATCH, + SslWarnType::DOMAINMISMATCH, rRequest.HostName ); } @@ -320,7 +318,7 @@ handleCertificateValidationRequest_( trustCert = executeSSLWarnDialog( pParent, xContext, rRequest.Certificate, - SSLWARN_TYPE_EXPIRED, + SslWarnType::EXPIRED, rRequest.HostName ); } @@ -337,7 +335,7 @@ handleCertificateValidationRequest_( trustCert = executeSSLWarnDialog( pParent, xContext, rRequest.Certificate, - SSLWARN_TYPE_INVALID, + SslWarnType::INVALID, rRequest.HostName ); } |