2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import java
.io
.IOException
;
22 import com
.sun
.star
.bridge
.UnoUrlResolver
;
23 import com
.sun
.star
.bridge
.XUnoUrlResolver
;
24 import com
.sun
.star
.comp
.helper
.Bootstrap
;
25 import com
.sun
.star
.connection
.XConnection
;
26 import com
.sun
.star
.connection
.XConnector
;
27 import com
.sun
.star
.container
.XSet
;
28 import com
.sun
.star
.lang
.XMultiServiceFactory
;
29 import com
.sun
.star
.lang
.XSingleServiceFactory
;
30 import com
.sun
.star
.pgp
.SimplePGPMailerFactoryReg
;
31 import com
.sun
.star
.uno
.IBridge
;
32 import com
.sun
.star
.uno
.Type
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
35 import com
.sun
.star
.uno
.XNamingService
;
36 // import com.sun.star.comp.bootstrap.Bootstrap;
40 public class TestPGP
{
43 static void doSomething(Object r
) throws com
.sun
.star
.uno
.Exception
, IOException
, Exception
{
44 XNamingService rName
= UnoRuntime
.queryInterface(XNamingService
.class, r
);
47 System
.err
.println("got the remote naming service !");
48 Object rXsmgr
= rName
.getRegisteredObject("StarOffice.ServiceManager");
50 XMultiServiceFactory rSmgr
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, rXsmgr
);
52 System
.err
.println("got the remote service manager !");
55 XSet set
= UnoRuntime
.queryInterface(XSet
.class, rSmgr
);
57 System
.err
.println(" couldn't get XSet from ServiceFactory");
61 SimplePGPMailerFactoryReg mailerReg
= new SimplePGPMailerFactoryReg();
62 XSingleServiceFactory factory
= mailerReg
.getServiceFactory(
63 "com.sun.star.pgp.SimplePGPMailerImpl", rSmgr
, null, null);
65 if( factory
== null) {
66 System
.err
.println("couldn't create PGP factory !");
70 System
.err
.println("PGP factory inserted into service manager");
72 // }catch(Exception e ){
73 // System.err.println( "exception caught in TestPGP");
81 public static void main(String argv
[]) throws Exception
{
82 if(argv
.length
!= 1) {
83 System
.err
.println("usage : testoffice protocol:host:port");
88 XUnoUrlResolver resolver
= UnoUrlResolver
.create(Bootstrap
.createInitialComponentContext(null));
90 XConnector xConnector
= UnoRuntime
.queryInterface(XConnector
.class, resolver
.resolve("com.sun.star.connection.Connector"));
91 XConnection xConnection
= xConnector
.connect(argv
[0]);
93 String rootOid
= "classic_uno";
94 IBridge iBridge
= UnoRuntime
.getBridgeByName("java", null, "remote", null, new Object
[]{"iiop", xConnection
, null});
96 Object rInitialObject
= iBridge
.mapInterfaceFrom(rootOid
, new Type(XInterface
.class));
97 // Object rInitialObject = xBridge.getInstance("NamingService");
99 if(rInitialObject
!= null) {
100 System
.err
.println("got the remote object");
101 doSomething(rInitialObject
);
104 // catch (Exception exception) {
105 // System.err.println("Exception thrown:" + exception);