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_xmlsecurity.hxx"
26 
27 #include "util.hxx"
28 
29 #include <stdio.h>
30 #include <tools/date.hxx>
31 #include <tools/time.hxx>
32 #include <cppuhelper/servicefactory.hxx>
33 
34 #include <xmlsecurity/biginteger.hxx>
35 #include <xmlsecurity/xmlsignaturehelper.hxx>
36 
37 using namespace ::com::sun::star;
38 
main(int argc,char ** argv)39 int SAL_CALL main( int argc, char **argv )
40 {
41 	fprintf( stdout, "\nTesting Mozilla Profile Detection...\n\nOpenOffice.org will use the first detected profile.\nResults might be different when started in OOo program folder!\n" ) ;
42 
43 	uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory();
44 	if ( !xMSF.is() )
45 	{
46 	    fprintf( stdout, "\n\nERROR: Can't create Service Factory\n" );
47 	    exit (-1);
48 	}
49 
50 	uno::Reference<mozilla::XMozillaBootstrap> xMozillaBootstrap( xMSF->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap" ) ) ), uno::UNO_QUERY );
51 	if ( !xMozillaBootstrap.is() )
52 	{
53 	    fprintf( stdout, "\n\nERROR: Can't create Mozilla Bootstrap Service\n" );
54 	    exit (-1);
55 	}
56 
57 	int nProducts = 4;
58 	mozilla::MozillaProductType productTypes[4] = { mozilla::MozillaProductType_Thunderbird, mozilla::MozillaProductType_Mozilla, mozilla::MozillaProductType_Firefox, mozilla::MozillaProductType_Default };
59 	for ( int i = 0; i < nProducts; i++)
60 	{
61 	    if ( i == 0 )
62 	        fprintf( stdout, "\nThunderbird: " );
63 	    else if ( i == 1 )
64 	        fprintf( stdout, "\nMozilla:     " );
65 	    else if ( i == 2 )
66 	        fprintf( stdout, "\nFireFox:     " );
67 	    else
68 	        fprintf( stdout, "\nDefault:     " );
69 
70 		::rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);
71 		if ( profile.getLength() )
72 		{
73 			::rtl::OUString profilepath = xMozillaBootstrap->getProfilePath(productTypes[i],profile);
74 	        fprintf( stdout, "Name=%s, Path=%s", rtl::OUStringToOString( profile , RTL_TEXTENCODING_ASCII_US ).getStr(), rtl::OUStringToOString( profilepath , RTL_TEXTENCODING_ASCII_US ).getStr() );
75 		}
76 		else
77 		{
78 		    fprintf( stdout, "NOT FOUND" );
79 		}
80 	}
81 
82 	/*
83 	 * creates a signature helper
84 	 */
85 	XMLSignatureHelper aSignatureHelper( xMSF );
86 
87 	/*
88 	 * creates a security context.
89 	 */
90 	rtl::OUString aCryptoToken;
91 	bool bInit = aSignatureHelper.Init( aCryptoToken );
92 	if ( !bInit )
93 	{
94 		fprintf( stdout, "\n\nERROR: Unable to initialize security environment.\n\n" );
95 	}
96 	else
97 	{
98 		fprintf( stdout, "\n\nSecurity environment can be initialized successfully.\n\n" );
99     }
100 
101 	return 0;
102 }
103 
104