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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucbhelper.hxx"
26 #include <com/sun/star/ucb/CertificateValidationRequest.hpp>
27 #include <ucbhelper/simplecertificatevalidationrequest.hxx>
28 
29 using namespace com::sun::star;
30 using namespace ucbhelper;
31 
32 //=========================================================================
SimpleCertificateValidationRequest(const sal_Int32 & lCertificateValidity,const com::sun::star::uno::Reference<com::sun::star::security::XCertificate> pCertificate,const rtl::OUString & hostname)33 SimpleCertificateValidationRequest::SimpleCertificateValidationRequest( const sal_Int32 & lCertificateValidity,
34                                                                         const com::sun::star::uno::Reference<com::sun::star::security::XCertificate> pCertificate,
35 																		const rtl::OUString & hostname)
36 {
37     // Fill request...
38     ucb::CertificateValidationRequest aRequest;
39     aRequest.CertificateValidity = lCertificateValidity;
40     aRequest.Certificate = pCertificate;
41 	aRequest.HostName = hostname;
42 
43     setRequest( uno::makeAny( aRequest ) );
44 
45     uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
46     aContinuations[ 0 ] = new InteractionAbort( this );
47     aContinuations[ 1 ] = new InteractionApprove( this );
48 
49     setContinuations( aContinuations );
50 	pCertificate.get();
51 }
52 
53 //=========================================================================
getResponse() const54 sal_Int32 SimpleCertificateValidationRequest::getResponse() const
55 {
56     rtl::Reference< InteractionContinuation > xSelection = getSelection();
57     if ( xSelection.is() )
58     {
59         InteractionContinuation * pSelection = xSelection.get();
60 
61         uno::Reference< task::XInteractionAbort > xAbort(
62                                         pSelection, uno::UNO_QUERY );
63         if ( xAbort.is() )
64             return 1;
65 
66         uno::Reference< task::XInteractionRetry > xRetry(
67                                         pSelection, uno::UNO_QUERY );
68         if ( xRetry.is() )
69             return 2;
70 
71         uno::Reference< task::XInteractionApprove > xApprove(
72                                         pSelection, uno::UNO_QUERY );
73         if ( xApprove.is() )
74             return 4;
75 
76         uno::Reference< task::XInteractionDisapprove > xDisapprove(
77                                         pSelection, uno::UNO_QUERY );
78         if ( xDisapprove.is() )
79             return 8;
80 
81         OSL_ENSURE( sal_False, "CertificateValidationRequest - Unknown continuation!" );
82     }
83     return 0;
84 }
85