1*06b3ce53SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06b3ce53SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06b3ce53SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06b3ce53SAndrew Rist * distributed with this work for additional information 6*06b3ce53SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06b3ce53SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06b3ce53SAndrew Rist * "License"); you may not use this file except in compliance 9*06b3ce53SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*06b3ce53SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*06b3ce53SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06b3ce53SAndrew Rist * software distributed under the License is distributed on an 15*06b3ce53SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06b3ce53SAndrew Rist * KIND, either express or implied. See the License for the 17*06b3ce53SAndrew Rist * specific language governing permissions and limitations 18*06b3ce53SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*06b3ce53SAndrew Rist *************************************************************/ 21*06b3ce53SAndrew Rist 22*06b3ce53SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "util.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <stdio.h> 30cdf0e10cSrcweir #include <tools/date.hxx> 31cdf0e10cSrcweir #include <tools/time.hxx> 32cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <xmlsecurity/biginteger.hxx> 35cdf0e10cSrcweir #include <xmlsecurity/xmlsignaturehelper.hxx> 36cdf0e10cSrcweir #include <com/sun/star/mozilla/XMozillaBootstrap.hpp> 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace ::com::sun::star; 39cdf0e10cSrcweir 40cdf0e10cSrcweir int SAL_CALL main( int argc, char **argv ) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir 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" ) ; 43cdf0e10cSrcweir 44cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMSF = CreateDemoServiceFactory(); 45cdf0e10cSrcweir if ( !xMSF.is() ) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir fprintf( stdout, "\n\nERROR: Can't create Service Factory\n" ); 48cdf0e10cSrcweir exit (-1); 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir uno::Reference<mozilla::XMozillaBootstrap> xMozillaBootstrap( xMSF->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap" ) ) ), uno::UNO_QUERY ); 52cdf0e10cSrcweir if ( !xMozillaBootstrap.is() ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir fprintf( stdout, "\n\nERROR: Can't create Mozilla Bootstrap Service\n" ); 55cdf0e10cSrcweir exit (-1); 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir int nProducts = 4; 59cdf0e10cSrcweir mozilla::MozillaProductType productTypes[4] = { mozilla::MozillaProductType_Thunderbird, mozilla::MozillaProductType_Mozilla, mozilla::MozillaProductType_Firefox, mozilla::MozillaProductType_Default }; 60cdf0e10cSrcweir for ( int i = 0; i < nProducts; i++) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir if ( i == 0 ) 63cdf0e10cSrcweir fprintf( stdout, "\nThunderbird: " ); 64cdf0e10cSrcweir else if ( i == 1 ) 65cdf0e10cSrcweir fprintf( stdout, "\nMozilla: " ); 66cdf0e10cSrcweir else if ( i == 2 ) 67cdf0e10cSrcweir fprintf( stdout, "\nFireFox: " ); 68cdf0e10cSrcweir else 69cdf0e10cSrcweir fprintf( stdout, "\nDefault: " ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir ::rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]); 72cdf0e10cSrcweir if ( profile.getLength() ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ::rtl::OUString profilepath = xMozillaBootstrap->getProfilePath(productTypes[i],profile); 75cdf0e10cSrcweir fprintf( stdout, "Name=%s, Path=%s", rtl::OUStringToOString( profile , RTL_TEXTENCODING_ASCII_US ).getStr(), rtl::OUStringToOString( profilepath , RTL_TEXTENCODING_ASCII_US ).getStr() ); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir else 78cdf0e10cSrcweir { 79cdf0e10cSrcweir fprintf( stdout, "NOT FOUND" ); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir /* 84cdf0e10cSrcweir * creates a signature helper 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir XMLSignatureHelper aSignatureHelper( xMSF ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /* 89cdf0e10cSrcweir * creates a security context. 90cdf0e10cSrcweir */ 91cdf0e10cSrcweir rtl::OUString aCryptoToken; 92cdf0e10cSrcweir bool bInit = aSignatureHelper.Init( aCryptoToken ); 93cdf0e10cSrcweir if ( !bInit ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir fprintf( stdout, "\n\nERROR: Unable to initialize security environment.\n\n" ); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir else 98cdf0e10cSrcweir { 99cdf0e10cSrcweir fprintf( stdout, "\n\nSecurity environment can be initialized successfully.\n\n" ); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir return 0; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105