You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by jc...@apache.org on 2009/09/27 02:15:08 UTC
svn commit: r819236 [6/6] - in /incubator/river/jtsk/trunk: ./ examples/
examples/hello/ examples/hello/config/ examples/hello/config/META-INF/
examples/hello/prebuiltkeys/ examples/hello/scripts/ examples/hello/src/
examples/hello/src/com/ examples/he...
Added: incubator/river/jtsk/trunk/examples/hello/scripts/krb-setenv.sh
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/krb-setenv.sh?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/krb-setenv.sh (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/krb-setenv.sh Sun Sep 27 00:15:03 2009
@@ -0,0 +1,49 @@
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+# This file should be sourced instead of running directly
+
+# Shell script to be sourced to set environment variables used by
+# Kerberos scripts. You should modify the variable values to match
+# your environment setup.
+
+# Client principal, excluding the realm
+# Example: CLIENT=client
+CLIENT=${CLIENT:-client}
+
+# Server principal, including server name and instance, but not the realm
+# Example: SERVER=server or
+# SERVER=server/server1.xyz.com
+SERVER=${SERVER:-server}
+
+# Phoenix principal, including phoenix name and instance, but not the realm
+# Example: PHOENIX=phoenix or
+# PHOENIX=phoenix/server2.xyz.com
+PHOENIX=${PHOENIX:-phoenix}
+
+# Reggie principal, including reggie name and instance, but not the realm
+# Example: REGGIE=reggie or
+# REGGIE=reggie/server2.xyz.com
+REGGIE=${REGGIE:-reggie}
+
+# Default realm used by KDC and all principals in this example
+# Example: REALM=REALM1.XYZ.COM
+REALM=${REALM:-your_default_realm}
+
+# Host on which the KDC server is running
+# Example: KDC_HOST=server3.xyz.com
+KDC_HOST=${KDC_HOST:-your_kdc_host}
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/krb-setenv.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.bat
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.bat?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.bat (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.bat Sun Sep 27 00:15:03 2009
@@ -0,0 +1,31 @@
+@rem /*
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem */
+
+@rem Batch file to run SSL client
+
+java -Djava.security.manager= ^
+ -Djava.security.policy=config\ssl-client.policy ^
+ -Djava.security.auth.login.config=config\ssl-client.login ^
+ -Djavax.net.ssl.trustStore=prebuiltkeys\truststore ^
+ -Djava.protocol.handler.pkgs=net.jini.url ^
+ -Djava.security.properties=config\dynamic-policy.security-properties ^
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider ^
+ -Dexport.codebase.source.jsk=..\..\lib-dl ^
+ -Dexport.codebase.jsk=httpmd://%computername%:8080/jsk-dl.jar;sha=0 ^
+ -jar lib\client.jar ^
+ config\ssl-client.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.bat
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.sh
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.sh?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.sh (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.sh Sun Sep 27 00:15:03 2009
@@ -0,0 +1,36 @@
+#! /bin/sh
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+
+# Shell script to run SSL client
+
+host=`hostname`
+
+set -x
+
+java -Djava.security.manager= \
+ -Djava.security.policy=config/ssl-client.policy \
+ -Djava.security.properties=config/dynamic-policy.security-properties \
+ -Djava.security.auth.login.config=config/ssl-client.login \
+ -Djavax.net.ssl.trustStore=prebuiltkeys/truststore \
+ -Djava.protocol.handler.pkgs=net.jini.url \
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider \
+ -Dexport.codebase.source.jsk=../../lib-dl \
+ -Dexport.codebase.jsk=httpmd://$host:8080/jsk-dl.jar\;sha=0 \
+ -jar lib/client.jar \
+ config/ssl-client.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-client.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.bat
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.bat?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.bat (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.bat Sun Sep 27 00:15:03 2009
@@ -0,0 +1,32 @@
+@rem /*
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem */
+
+@rem Batch file to run SSL Phoenix
+
+java -Djava.security.manager= ^
+ -Djava.security.policy=config\ssl-phoenix.policy ^
+ -Djava.security.properties=config\dynamic-policy.security-properties ^
+ -Djava.security.auth.login.config=config\ssl-phoenix.login ^
+ -Djavax.net.ssl.trustStore=prebuiltkeys\truststore ^
+ -Djava.protocol.handler.pkgs=net.jini.url ^
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider ^
+ -Dexport.codebase.source.jsk=..\..\lib-dl ^
+ -Dexport.codebase.jsk="httpmd://%computername%:8080/phoenix-dl.jar;sha=0 httpmd://%computername%:8080/jsk-dl.jar;sha=0" ^
+ -classpath ..\..\lib\phoenix.jar;lib\mdprefld.jar ^
+ com.sun.jini.phoenix.Activation ^
+ config\ssl-phoenix.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.bat
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.sh
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.sh?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.sh (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.sh Sun Sep 27 00:15:03 2009
@@ -0,0 +1,38 @@
+#! /bin/sh
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+
+# Shell script to run SSL Phoenix
+
+# The server host
+host=`hostname`
+
+set -x
+
+java -Djava.security.manager= \
+ -Djava.security.policy=config/ssl-phoenix.policy \
+ -Djava.security.properties=config/dynamic-policy.security-properties \
+ -Djava.security.auth.login.config=config/ssl-phoenix.login \
+ -Djavax.net.ssl.trustStore=prebuiltkeys/truststore \
+ -Djava.protocol.handler.pkgs=net.jini.url \
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider \
+ -Dexport.codebase.source.jsk=../../lib-dl \
+ -Dexport.codebase.jsk="httpmd://$host:8080/phoenix-dl.jar;sha=0 httpmd://$host:8080/jsk-dl.jar;sha=0" \
+ -classpath ../../lib/phoenix.jar:lib/mdprefld.jar \
+ com.sun.jini.phoenix.Activation \
+ config/ssl-phoenix.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-phoenix.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.bat
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.bat?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.bat (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.bat Sun Sep 27 00:15:03 2009
@@ -0,0 +1,28 @@
+@rem /*
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem */
+
+@rem Batch file to run SSL Reggie
+
+java -Djava.security.manager= ^
+ -Djava.security.policy=config\ssl-reggie.policy ^
+ -Djava.security.auth.login.config=config\ssl-reggie.login ^
+ -Djava.security.properties=config\dynamic-policy.security-properties ^
+ -Djavax.net.ssl.trustStore=prebuiltkeys\truststore ^
+ -Djava.protocol.handler.pkgs=net.jini.url ^
+ -jar ..\..\lib\start.jar ^
+ config\start-ssl-reggie.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.bat
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.sh
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.sh?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.sh (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.sh Sun Sep 27 00:15:03 2009
@@ -0,0 +1,33 @@
+#! /bin/sh
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+
+# Shell script to run SSL Reggie
+
+host=`hostname`
+
+set -x
+
+java -Djava.security.manager= \
+ -Djava.security.policy=config/ssl-reggie.policy \
+ -Djava.security.auth.login.config=config/ssl-reggie.login \
+ -Djava.security.properties=config/dynamic-policy.security-properties \
+ -Djavax.net.ssl.trustStore=prebuiltkeys/truststore \
+ -Djava.protocol.handler.pkgs=net.jini.url \
+ -jar ../../lib/start.jar \
+ config/start-ssl-reggie.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-reggie.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.bat
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.bat?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.bat (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.bat Sun Sep 27 00:15:03 2009
@@ -0,0 +1,33 @@
+@rem /*
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem */
+
+@rem Batch file to run SSL server
+
+java -Djava.security.manager= ^
+ -Djava.security.policy=config\ssl-server.policy ^
+ -Djava.security.auth.login.config=config\ssl-server.login ^
+ -Djava.security.properties=config\dynamic-policy.security-properties ^
+ -Djavax.net.ssl.trustStore=prebuiltkeys\truststore ^
+ -Djava.protocol.handler.pkgs=net.jini.url ^
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider ^
+ -Dexport.codebase.source.app=lib ^
+ -Dexport.codebase.app="httpmd://%computername%:8080/server-dl.jar;sha=0" ^
+ -Dexport.codebase.source.jsk=..\..\lib-dl ^
+ -Dexport.codebase.jsk="httpmd://%computername%:8080/jsk-dl.jar;sha=0" ^
+ -jar lib\server.jar ^
+ config\ssl-server.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.bat
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.sh
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.sh?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.sh (added)
+++ incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.sh Sun Sep 27 00:15:03 2009
@@ -0,0 +1,39 @@
+#! /bin/sh
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+
+# Shell script to run SSL server
+
+# The server host
+host=`hostname`
+
+set -x
+
+java -Djava.security.manager= \
+ -Djava.security.policy=config/ssl-server.policy \
+ -Djava.security.auth.login.config=config/ssl-server.login \
+ -Djava.security.properties=config/dynamic-policy.security-properties \
+ -Djavax.net.ssl.trustStore=prebuiltkeys/truststore \
+ -Djava.protocol.handler.pkgs=net.jini.url \
+ -Djava.rmi.server.RMIClassLoaderSpi=com.sun.jini.example.hello.MdClassAnnotationProvider \
+ -Dexport.codebase.source.app=lib \
+ -Dexport.codebase.app=httpmd://$host:8080/server-dl.jar\;sha=0 \
+ -Dexport.codebase.source.jsk=../../lib-dl \
+ -Dexport.codebase.jsk=httpmd://$host:8080/jsk-dl.jar\;sha=0 \
+ -jar lib/server.jar \
+ config/ssl-server.config
Propchange: incubator/river/jtsk/trunk/examples/hello/scripts/ssl-server.sh
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/server-act.mf
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/server-act.mf?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/server-act.mf (added)
+++ incubator/river/jtsk/trunk/examples/hello/server-act.mf Sun Sep 27 00:15:03 2009
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.sun.jini.example.hello.ActivatableServer
+Class-Path: ../../../lib/jsk-platform.jar ../../../lib/jsk-lib.jar mdprefld.jar ../../../lib/phoenix-init.jar
Propchange: incubator/river/jtsk/trunk/examples/hello/server-act.mf
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/server.mf
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/server.mf?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/server.mf (added)
+++ incubator/river/jtsk/trunk/examples/hello/server.mf Sun Sep 27 00:15:03 2009
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.sun.jini.example.hello.Server
+Class-Path: ../../../lib/jsk-platform.jar ../../../lib/jsk-lib.jar mdprefld.jar ../../../lib/phoenix-init.jar
Propchange: incubator/river/jtsk/trunk/examples/hello/server.mf
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ActivatableServer.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ActivatableServer.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ActivatableServer.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ActivatableServer.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationGroup;
+import java.rmi.activation.ActivationGroupDesc.CommandEnvironment;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationSystem;
+import java.security.PrivilegedExceptionAction;
+import java.util.Properties;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationProvider;
+import net.jini.core.lookup.ServiceID;
+import net.jini.export.Exporter;
+import net.jini.security.BasicProxyPreparer;
+import net.jini.security.ProxyPreparer;
+
+/**
+ * Defines an activatable application server that provides an implementation of
+ * the Hello interface.
+ *
+ * The application uses the following arguments:
+ *
+ * [all] - All arguments are used as options when getting the configuration
+ *
+ * The application uses the following configuration entries, with component
+ * com.sun.jini.example.hello.Server:
+ *
+ * activationIdPreparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the service proxy's activation ID
+ *
+ * activationSystemPreparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the activation system proxy
+ *
+ * configOptions
+ * type: String[]
+ * default: none
+ * The options for the configuration used to configure the server
+ *
+ * discoveryManager
+ * type: DiscoveryManagement
+ * default: new LookupDiscovery(new String[] { "" }, config)
+ * Object used to discover lookup services to join.
+ *
+ * exporter
+ * type: Exporter
+ * default: none
+ * The object to use for exporting the server
+ *
+ * loginContext
+ * type: LoginContext
+ * default: null
+ * If non-null, specifies the JAAS login context to use for performing a JAAS
+ * login and supplying the Subject to use when starting the service. If null,
+ * no JAAS login is performed.
+ *
+ * javaOptions
+ * type: String[]
+ * default: new String[0]
+ * Command line options for the activation group executable
+ *
+ * javaProgram
+ * type: String
+ * default: null
+ * The executable for the activation group, or the default executable if null
+ *
+ * javaProperties
+ * type: String[]
+ * default: new String[0]
+ * System properties for the activation group executable, specified as pairs
+ * of keys and values
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class ActivatableServer extends Server {
+
+ /** The activation ID for this server */
+ private ActivationID aid;
+
+ /** The service ID for this server */
+ private final ServiceID serviceID;
+
+ /**
+ * Starts and registers an activatable server that implements the Hello
+ * interface.
+ */
+ public static void main(String[] args) throws Exception {
+ final Configuration config = ConfigurationProvider.getInstance(args);
+ LoginContext loginContext = (LoginContext) config.getEntry(
+ "com.sun.jini.example.hello.Server", "loginContext",
+ LoginContext.class, null);
+ if (loginContext == null) {
+ mainAsSubject(config);
+ } else {
+ loginContext.login();
+ Subject.doAsPrivileged(
+ loginContext.getSubject(),
+ new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ mainAsSubject(config);
+ return null;
+ }
+ },
+ null);
+ }
+ }
+
+ /** Starts the server with the subject already set. */
+ static void mainAsSubject(Configuration config) throws Exception {
+ /* Get Java program */
+ String program = (String) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaProgram",
+ String.class, null);
+
+ /* Get options for Java program */
+ String[] options = (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaOptions", String[].class,
+ new String[0]);
+
+ /* Create command environment */
+ CommandEnvironment cmd = new CommandEnvironment(program, options);
+
+ /* Get system properties for Java program */
+ String[] propValues = (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaProperties",
+ String[].class, new String[0]);
+ Properties props = new Properties();
+ for (int i = 0; i < propValues.length; i += 2) {
+ props.setProperty(propValues[i], propValues[i + 1]);
+ }
+
+ /* Create group description */
+ ActivationGroupDesc groupDesc = new ActivationGroupDesc(props, cmd);
+
+ /* Create the activation data -- configuration source and service ID */
+ MarshalledObject data = new MarshalledObject(
+ new ActivationData(
+ (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "configOptions",
+ String[].class),
+ createServiceID()));
+
+ /* Get the activation system */
+ ProxyPreparer actSysPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationSystemPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer());
+ ActivationSystem actSys =
+ (ActivationSystem) actSysPreparer.prepareProxy(
+ ActivationGroup.getSystem());
+
+ /* Create the activation group */
+ ActivationGroupID gid = actSys.registerGroup(groupDesc);
+
+ /* Create the activation descriptor */
+ ActivationDesc actDesc =
+ new ActivationDesc(
+ gid, ActivatableServer.class.getName(),
+ null /* location */, data, true /* restart */);
+
+ /* Register the activation descriptor */
+ ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationIdPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer());
+ ActivationID aid = (ActivationID) actIdPreparer.prepareProxy(
+ actSys.registerObject(actDesc));
+
+ /* Activate the server */
+ aid.activate(true);
+
+ System.out.println("Activated server");
+ }
+
+ /**
+ * Creates the server
+ *
+ * @param aid the activation ID for the server
+ * @param data the data for the activatable server, which should be the
+ * options to use when getting the Configuration
+ * @throws Exception if a problem occurs
+ */
+ public ActivatableServer(ActivationID aid, MarshalledObject data)
+ throws Exception
+ {
+ super(((ActivationData) data.get()).configOptions);
+ this.aid = aid;
+ serviceID = ((ActivationData) data.get()).serviceID;
+ init();
+ }
+
+ /**
+ * Stores the configuration options and service ID for the activatable
+ * server.
+ */
+ static class ActivationData implements Serializable {
+ private static final long serialVersionUID = 2L;
+ final String[] configOptions;
+ final ServiceID serviceID;
+
+ ActivationData(String[] configOptions, ServiceID serviceID) {
+ this.configOptions = configOptions;
+ this.serviceID = serviceID;
+ }
+ }
+
+ /**
+ * Returns the exporter for exporting the server. Prepares the activation
+ * ID and makes it available to the exporter through the getActivationID
+ * method.
+ *
+ * @throws ConfigurationException if a problem occurs getting the exporter
+ * from the configuration
+ * @throws RemoteException if a remote communication problem occurs
+ */
+ protected Exporter getExporter()
+ throws ConfigurationException, RemoteException
+ {
+ /* Prepare the activation ID */
+ ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationIdPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer());
+ aid = (ActivationID) actIdPreparer.prepareProxy(aid);
+
+ /* Provide the activation ID to the exporter */
+ return (Exporter) config.getEntry(
+ "com.sun.jini.example.hello.Server", "exporter", Exporter.class,
+ Configuration.NO_DEFAULT, aid);
+ }
+
+ /** Returns the service ID for this server. */
+ protected ServiceID getServiceID() {
+ return serviceID;
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ActivatableServer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Client.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Client.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Client.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Client.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.rmi.RemoteException;
+import java.security.PrivilegedExceptionAction;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationProvider;
+import net.jini.config.NoSuchEntryException;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.discovery.LookupDiscovery;
+import net.jini.lookup.ServiceDiscoveryManager;
+import net.jini.lookup.ServiceItemFilter;
+import net.jini.security.BasicProxyPreparer;
+import net.jini.security.ProxyPreparer;
+
+/**
+ * Defines an application that makes calls to a remote Hello server.
+ *
+ * The application uses the following arguments:
+ *
+ * [all] - All arguments are used as options when getting the configuration
+ *
+ * The application uses the following configuration entries, with component
+ * com.sun.jini.example.hello.Client:
+ *
+ * loginContext
+ * type: LoginContext
+ * default: null
+ * If non-null, specifies the JAAS login context to use for performing a JAAS
+ * login and supplying the Subject to use when running the client. If null,
+ * no JAAS login is performed.
+ *
+ * preparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the server proxy
+ *
+ * serviceDiscovery
+ * type: ServiceDiscoveryManager
+ * default: new ServiceDiscoveryManager(
+ * new LookupDiscovery(new String[] { "" }, config),
+ * null, config)
+ * Object used for discovering a server that implement Hello.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class Client {
+
+ /**
+ * Starts an application that makes calls to a remote Hello implementation.
+ */
+ public static void main(String[] args) throws Exception {
+ /*
+ * The configuration contains information about constraints to apply to
+ * the server proxy.
+ */
+ final Configuration config = ConfigurationProvider.getInstance(args);
+ LoginContext loginContext = (LoginContext) config.getEntry(
+ "com.sun.jini.example.hello.Client", "loginContext",
+ LoginContext.class, null);
+ if (loginContext == null) {
+ mainAsSubject(config);
+ } else {
+ loginContext.login();
+ Subject.doAsPrivileged(
+ loginContext.getSubject(),
+ new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ mainAsSubject(config);
+ return null;
+ }
+ },
+ null);
+ }
+ }
+
+ /**
+ * Performs the main operations of the application with the specified
+ * configuration and assuming that the appropriate subject is in effect.
+ */
+ static void mainAsSubject(Configuration config) throws Exception {
+
+ /* Get the service discovery manager, for discovering other services */
+ ServiceDiscoveryManager serviceDiscovery;
+ try {
+ serviceDiscovery = (ServiceDiscoveryManager) config.getEntry(
+ "com.sun.jini.example.hello.Client", "serviceDiscovery",
+ ServiceDiscoveryManager.class);
+ } catch (NoSuchEntryException e) {
+ /* Default to search in the public group */
+ serviceDiscovery = new ServiceDiscoveryManager(
+ new LookupDiscovery(new String[] { "" }, config),
+ null, config);
+ }
+
+ /* Retrieve the server proxy preparer from the configuration */
+ ProxyPreparer preparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Client",
+ "preparer", ProxyPreparer.class, new BasicProxyPreparer());
+
+ /* Create the filter to pass to the SDM for proxy preparation */
+ ServiceItemFilter filter = new ProxyPreparerFilter(preparer);
+
+ /* Look up the remote server (SDM performs proxy preparation) */
+ ServiceItem serviceItem = serviceDiscovery.lookup(
+ new ServiceTemplate(null, new Class[] { Hello.class }, null),
+ filter, Long.MAX_VALUE);
+ Hello server = (Hello) serviceItem.service;
+
+ /* Use the server */
+ System.out.println("Server says: " + server.sayHello());
+
+ /* Exit to close any thread created by the callback handler's GUI */
+ System.exit(0);
+ }
+
+ /** Performs proxy preparation on discovered services. For more information
+ * see the javadoc for the net.jini.lookup.ServiceItemFilter interface.
+ */
+ private static class ProxyPreparerFilter implements ServiceItemFilter {
+ private ProxyPreparer preparer;
+
+ ProxyPreparerFilter(ProxyPreparer preparer) {
+ this. preparer = preparer;
+ }
+
+ /** See the javadoc for the ServiceItemFilter.check method. */
+ public boolean check(ServiceItem item) {
+ try {
+ item.service = preparer.prepareProxy(item.service);
+ return true; //pass
+ } catch(SecurityException e) {//definite exception
+ return false; //fail: don't try again
+ } catch(RemoteException e) {//indefinite exception
+ item.service = null;
+ return true; //null & true == indefinite: will retry later
+ }
+ }
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Client.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingILFactory.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingILFactory.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingILFactory.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingILFactory.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.server.ExportException;
+import java.rmi.server.ServerNotActiveException;
+import java.util.Collection;
+import javax.swing.JOptionPane;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.export.ServerContext;
+import net.jini.io.context.ClientHost;
+import net.jini.jeri.BasicILFactory;
+import net.jini.jeri.BasicInvocationDispatcher;
+import net.jini.jeri.InvocationDispatcher;
+import net.jini.jeri.ObjectEndpoint;
+import net.jini.jeri.ServerCapabilities;
+
+/**
+ * Defines an <code>InvocationLayerFactory</code> that uses pop-up dialog
+ * windows to confirm calls.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class ConfirmingILFactory extends BasicILFactory {
+
+ /**
+ * Creates a <code>InvocationLayerFactory</code> that confirms calls, with
+ * no server constraints and no permission class.
+ */
+ public ConfirmingILFactory() { }
+
+ /**
+ * Creates a <code>InvocationLayerFactory</code> that confirms calls, and
+ * uses the specified server constraints and permission class.
+ */
+ public ConfirmingILFactory(MethodConstraints serverConstraints,
+ Class permissionClass)
+ {
+ super(serverConstraints, permissionClass);
+ }
+
+ /**
+ * Returns a confirming invocation handler for the object endpoint and
+ * interfaces.
+ *
+ * @param interfaces the interfaces
+ * @param impl the remote object
+ * @param oe the object endpoint
+ * @return a confirming invocation handler for the object endpoint and
+ * interfaces
+ */
+ protected InvocationHandler createInvocationHandler(Class[] interfaces,
+ Remote impl,
+ ObjectEndpoint oe)
+ {
+ return new ConfirmingInvocationHandler(oe, getServerConstraints());
+ }
+
+
+ /**
+ * Returns a confirming invocation dispatcher for the remote object.
+ *
+ * @param methods a collection of {@link Method} instances for the
+ * remote methods
+ * @param impl a remote object that the dispatcher is being created for
+ * @param capabilities the transport capabilities of the server
+ * @return a confirming invocation dispatcher for the remote object
+ */
+ protected InvocationDispatcher createInvocationDispatcher(
+ Collection methods, Remote impl, ServerCapabilities capabilities)
+ throws ExportException
+ {
+ if (impl == null) {
+ throw new NullPointerException("impl is null");
+ }
+ return new Dispatch(methods, capabilities, getServerConstraints(),
+ getPermissionClass());
+ }
+
+ /** Defines a subclass of BasicInvocationDispatcher that confirms calls. */
+ private static class Dispatch extends BasicInvocationDispatcher {
+
+ Dispatch(Collection methods,
+ ServerCapabilities capabilities,
+ MethodConstraints serverConstraints,
+ Class permissionClass)
+ throws ExportException
+ {
+ super(methods, capabilities,
+ serverConstraints, permissionClass, null);
+ }
+
+ /**
+ * Reads the call identifier and asks whether the call should be
+ * permitted before unmarshalling the arguments.
+ */
+ protected Object[] unmarshalArguments(Remote obj,
+ Method method,
+ ObjectInputStream in,
+ Collection context)
+ throws IOException, ClassNotFoundException
+ {
+ long callId = in.readLong();
+ ClientHost client = null;
+ try {
+ client = (ClientHost)
+ ServerContext.getServerContextElement(ClientHost.class);
+ } catch (ServerNotActiveException e) {
+ }
+ int result = JOptionPane.showConfirmDialog(
+ null,
+ "Permit incoming remote call?" +
+ "\n Client: " + (client != null
+ ? client.toString() : "not active") +
+ "\n Object: " + obj +
+ "\n Method: " + method.getName() +
+ "\n Call id: " + callId,
+ "Permit incoming remote call?",
+ JOptionPane.OK_CANCEL_OPTION);
+ if (result != JOptionPane.OK_OPTION) {
+ throw new SecurityException("Server denied call");
+ }
+ return super.unmarshalArguments(obj, method, in, context);
+ }
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingILFactory.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingInvocationHandler.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingInvocationHandler.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingInvocationHandler.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import javax.swing.JOptionPane;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.jeri.BasicInvocationHandler;
+import net.jini.jeri.ObjectEndpoint;
+
+/** Defines an invocation handler that confirms calls. */
+public class ConfirmingInvocationHandler extends BasicInvocationHandler {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Create a confirming invocation handler from a basic handler and
+ * constraints.
+ */
+ public ConfirmingInvocationHandler(ConfirmingInvocationHandler other,
+ MethodConstraints clientConstraints) {
+ super(other, clientConstraints);
+ }
+
+ /**
+ * Create a confirming invocation handler for the object endpoint and
+ * server constraints.
+ */
+ public ConfirmingInvocationHandler(ObjectEndpoint oe,
+ MethodConstraints serverConstraints) {
+ super(oe, serverConstraints);
+ }
+
+ /**
+ * Asks whether the call should be made, then writes a call identifier
+ * before the arguments.
+ */
+ protected void marshalArguments(Object proxy,
+ Method method,
+ Object[] args,
+ ObjectOutputStream out,
+ Collection context)
+ throws IOException
+ {
+ long callId = System.currentTimeMillis();
+ int result = JOptionPane.showConfirmDialog(
+ null,
+ "Make remote call?" +
+ "\n Object: " + proxy +
+ "\n Method: " + method.getName() +
+ "\n Call id: " + callId,
+ "Make remote call?",
+ JOptionPane.OK_CANCEL_OPTION);
+ if (result != JOptionPane.OK_OPTION) {
+ throw new RuntimeException("Client cancelled call");
+ }
+ out.writeLong(callId);
+ super.marshalArguments(proxy, method, args, out, context);
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ConfirmingInvocationHandler.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Hello.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Hello.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Hello.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Hello.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Defines a simple remote interface.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public interface Hello extends Remote {
+
+ /**
+ * Returns a message string.
+ *
+ * @return message string
+ * @throws RemoteException if a remote communication problem occurs
+ */
+ String sayHello() throws RemoteException;
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Hello.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/MdClassAnnotationProvider.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/MdClassAnnotationProvider.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/MdClassAnnotationProvider.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/MdClassAnnotationProvider.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import net.jini.loader.pref.PreferredClassProvider;
+import net.jini.url.httpmd.HttpmdUtil;
+
+/**
+ * A preferred class provider that computes HTTPMD URLs to use as the class
+ * annotation for classes in the application and bootstrap classpath. The
+ * following system properties control the HTTPMD URLs created:
+ *
+ * o export.codebase -- a space-separated list of the HTTPMD URLs for use as
+ * the codebase. The digest values specified in the URLs will be ignored.
+ * The path portion of the URLs, without the message digest parameters, will
+ * be used to specify the source files, relative to the source directory, to
+ * use for computing message digests.
+ *
+ * o export.codebase.source -- the name of the directory containing the source
+ * files corresponding to the URLs in the codebase
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class MdClassAnnotationProvider
+ extends PreferredClassProvider
+{
+ private final String codebase;
+
+ public MdClassAnnotationProvider()
+ throws IOException, MalformedURLException
+ {
+ super(false);
+ String codebaseApp = null;
+ try {
+ codebaseApp = HttpmdUtil.computeDigestCodebase(
+ System.getProperty("export.codebase.source.app"),
+ System.getProperty("export.codebase.app"));
+ } catch(NullPointerException e) { /* properties not set */ }
+
+ String codebaseJsk = null;
+ try {
+ codebaseJsk = HttpmdUtil.computeDigestCodebase(
+ System.getProperty("export.codebase.source.jsk"),
+ System.getProperty("export.codebase.jsk"));
+ } catch(NullPointerException e) { /* properties not set */ }
+
+ if( (codebaseApp != null) && (codebaseJsk != null) ) {
+ codebase = codebaseApp+" "+codebaseJsk;
+ } else if(codebaseApp != null) {
+ codebase = codebaseApp;
+ } else if(codebaseJsk != null) {
+ codebase = codebaseJsk;
+ } else {
+ throw new NullPointerException("no codebase properties defined");
+ }
+ }
+
+ protected String getClassAnnotation(ClassLoader loader) {
+ return codebase;
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/MdClassAnnotationProvider.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Proxy.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Proxy.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Proxy.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.security.TrustVerifier;
+import net.jini.security.proxytrust.ProxyTrustIterator;
+import net.jini.security.proxytrust.SingletonProxyTrustIterator;
+import net.jini.security.proxytrust.TrustEquivalence;
+
+/** Define a smart proxy for the server. */
+class Proxy implements Serializable, Hello {
+
+ private static final long serialVersionUID = 2L;
+
+ /** The server proxy */
+ final Hello serverProxy;
+
+ /**
+ * Create a smart proxy, using an implementation that supports constraints
+ * if the server proxy does.
+ */
+ static Proxy create(Hello serverProxy) {
+ return (serverProxy instanceof RemoteMethodControl)
+ ? new ConstrainableProxy(serverProxy)
+ : new Proxy(serverProxy);
+ }
+
+ Proxy(Hello serverProxy) {
+ this.serverProxy = serverProxy;
+ }
+
+ public boolean equals(Object o) {
+ return getClass() == o.getClass()
+ && serverProxy.equals(((Proxy) o).serverProxy);
+ }
+
+ public int hashCode() {
+ return serverProxy.hashCode();
+ }
+
+ /** Implement Hello. */
+ public String sayHello() throws RemoteException {
+ System.out.println("Calling sayHello in smart proxy");
+ return serverProxy.sayHello();
+ }
+
+ /** A constrainable implementation of the smart proxy. */
+ private static final class ConstrainableProxy extends Proxy
+ implements RemoteMethodControl
+ {
+ private static final long serialVersionUID = 2L;
+
+ ConstrainableProxy(Hello serverProxy) {
+ super(serverProxy);
+ }
+
+ /** Implement RemoteMethodControl */
+
+ public MethodConstraints getConstraints() {
+ return ((RemoteMethodControl) serverProxy).getConstraints();
+ }
+
+ public RemoteMethodControl setConstraints(MethodConstraints mc) {
+ return new ConstrainableProxy(
+ (Hello) ((RemoteMethodControl) serverProxy).setConstraints(
+ mc));
+ }
+
+ /*
+ * Provide access to the underlying server proxy to permit the
+ * ProxyTrustVerifier class to verify the proxy.
+ */
+ private ProxyTrustIterator getProxyTrustIterator() {
+ return new SingletonProxyTrustIterator(serverProxy);
+ }
+ }
+
+ /** A trust verifier for secure smart proxies. */
+ final static class Verifier implements TrustVerifier, Serializable {
+
+ private static final long serialVersionUID = 2L;
+
+ private final RemoteMethodControl serverProxy;
+
+ /**
+ * Create the verifier, throwing UnsupportedOperationException if the
+ * server proxy does not implement both RemoteMethodControl and
+ * TrustEquivalence.
+ */
+ Verifier(Hello serverProxy) {
+ if (serverProxy instanceof RemoteMethodControl &&
+ serverProxy instanceof TrustEquivalence)
+ {
+ this.serverProxy = (RemoteMethodControl) serverProxy;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /** Implement TrustVerifier */
+ public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx)
+ throws RemoteException
+ {
+ if (obj == null || ctx == null) {
+ throw new NullPointerException();
+ } else if (!(obj instanceof ConstrainableProxy)) {
+ return false;
+ }
+ RemoteMethodControl otherServerProxy =
+ (RemoteMethodControl) ((ConstrainableProxy) obj).serverProxy;
+ MethodConstraints mc = otherServerProxy.getConstraints();
+ TrustEquivalence trusted =
+ (TrustEquivalence) serverProxy.setConstraints(mc);
+ return trusted.checkTrustEquivalence(otherServerProxy);
+ }
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Proxy.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Server.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Server.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Server.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Server.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import java.rmi.RemoteException;
+import java.security.PrivilegedExceptionAction;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationProvider;
+import net.jini.config.NoSuchEntryException;
+import net.jini.core.lookup.ServiceID;
+import net.jini.discovery.DiscoveryManagement;
+import net.jini.discovery.LookupDiscovery;
+import net.jini.export.Exporter;
+import net.jini.export.ProxyAccessor;
+import net.jini.id.Uuid;
+import net.jini.id.UuidFactory;
+import net.jini.jeri.BasicILFactory;
+import net.jini.jeri.BasicJeriExporter;
+import net.jini.jeri.tcp.TcpServerEndpoint;
+import net.jini.lookup.JoinManager;
+import net.jini.security.TrustVerifier;
+import net.jini.security.proxytrust.ServerProxyTrust;
+
+/**
+ * Defines an application server that provides an implementation of the Hello
+ * interface.
+ *
+ * The application uses the following arguments:
+ *
+ * [all] - All arguments are used as options when getting the configuration
+ *
+ * The application uses the following configuration entries, with component
+ * com.sun.jini.example.hello.Server:
+ *
+ * discoveryManager
+ * type: DiscoveryManagement
+ * default: new LookupDiscovery(new String[] { "" }, config)
+ * Object used to discover lookup services to join.
+ *
+ * exporter
+ * type: Exporter
+ * default: none
+ * The object to use for exporting the server
+ *
+ * loginContext
+ * type: LoginContext
+ * default: null
+ * If non-null, specifies the JAAS login context to use for performing a JAAS
+ * login and supplying the Subject to use when running the server. If null,
+ * no JAAS login is performed.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class Server implements Hello, ServerProxyTrust, ProxyAccessor {
+
+ /**
+ * If the impl gets GC'ed, then the server will be unexported.
+ * Store the instance here to prevent this.
+ */
+ private static Server serverImpl;
+
+ /* The configuration to use for configuring the server */
+ protected final Configuration config;
+
+ /** The server proxy, for use by getProxyVerifier */
+ protected Hello serverProxy;
+
+ /**
+ * Starts and registers a server that implements the Hello interface.
+ *
+ * @param args options to use when getting the Configuration
+ * @throws ConfigurationException if a problem occurs with the
+ * configuration
+ * @throws RemoteException if a remote communication problem occurs
+ */
+ public static void main(String[] args) throws Exception {
+ serverImpl = new Server(args);
+ serverImpl.init();
+ System.out.println("Hello server is ready");
+ }
+
+ /**
+ * Creates the server.
+ *
+ * @param configOptions options to use when getting the Configuration
+ * @throws ConfigurationException if a problem occurs creating the
+ * configuration
+ */
+ protected Server(String[] configOptions) throws ConfigurationException {
+ config = ConfigurationProvider.getInstance
+ ( configOptions, (this.getClass()).getClassLoader() );
+ }
+
+ /**
+ * Initializes the server, including exporting it and storing its proxy in
+ * the registry.
+ *
+ * @throws Exception if a problem occurs
+ */
+ protected void init() throws Exception {
+ LoginContext loginContext = (LoginContext) config.getEntry(
+ "com.sun.jini.example.hello.Server", "loginContext",
+ LoginContext.class, null);
+ if (loginContext == null) {
+ initAsSubject();
+ } else {
+ loginContext.login();
+ Subject.doAsPrivileged(
+ loginContext.getSubject(),
+ new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ initAsSubject();
+ return null;
+ }
+ },
+ null);
+ }
+ }
+
+ /**
+ * Initializes the server, assuming that the appropriate subject is in
+ * effect.
+ */
+ protected void initAsSubject() throws Exception {
+ /* Export the server */
+ Exporter exporter = getExporter();
+ serverProxy = (Hello) exporter.export(this);
+
+ /* Create the smart proxy */
+ Proxy smartProxy = Proxy.create(serverProxy);
+
+ /* Get the discovery manager, for discovering lookup services */
+ DiscoveryManagement discoveryManager;
+ try {
+ discoveryManager = (DiscoveryManagement) config.getEntry(
+ "com.sun.jini.example.hello.Server", "discoveryManager",
+ DiscoveryManagement.class);
+ } catch (NoSuchEntryException e) {
+ /* Use the public group */
+ discoveryManager = new LookupDiscovery(
+ new String[] { "" }, config);
+ }
+
+ /* Get the join manager, for joining lookup services */
+ JoinManager joinManager =
+ new JoinManager(smartProxy, null /* attrSets */, getServiceID(),
+ discoveryManager, null /* leaseMgr */, config);
+ }
+
+ /**
+ * Returns the exporter for exporting the server.
+ *
+ * @throws ConfigurationException if a problem occurs getting the exporter
+ * from the configuration
+ * @throws RemoteException if a remote communication problem occurs
+ */
+ protected Exporter getExporter()
+ throws ConfigurationException, RemoteException
+ {
+ return (Exporter) config.getEntry(
+ "com.sun.jini.example.hello.Server", "exporter", Exporter.class,
+ new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
+ new BasicILFactory()));
+ }
+
+ /** Returns the service ID for this server. */
+ protected ServiceID getServiceID() {
+ return createServiceID();
+ }
+
+ /** Creates a new service ID. */
+ protected static ServiceID createServiceID() {
+ Uuid uuid = UuidFactory.generate();
+ return new ServiceID(
+ uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
+ }
+
+ /** Implement the Hello interface. */
+ public String sayHello() {
+ return "Hello, world!";
+ }
+
+ /**
+ * Implement the ServerProxyTrust interface to provide a verifier for
+ * secure smart proxies.
+ */
+ public TrustVerifier getProxyVerifier() {
+ return new Proxy.Verifier(serverProxy);
+ }
+
+ /**
+ * Returns a proxy object for this remote object.
+ *
+ * @return our proxy
+ */
+ public Object getProxy() {
+ return serverProxy;
+ }
+
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/Server.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ServerPermission.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ServerPermission.java?rev=819236&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ServerPermission.java (added)
+++ incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ServerPermission.java Sun Sep 27 00:15:03 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.jini.example.hello;
+
+import net.jini.security.AccessPermission;
+
+/**
+ * Represents permissions used to express the access control policy for the
+ * Server class. The name specifies the names of the method which you have
+ * permission to call using the matching rules provided by AccessPermission.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class ServerPermission extends AccessPermission {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Creates an instance with the specified target name.
+ *
+ * @param name the target name
+ */
+ public ServerPermission(String name) {
+ super(name);
+ }
+}
Propchange: incubator/river/jtsk/trunk/examples/hello/src/com/sun/jini/example/hello/ServerPermission.java
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/river/jtsk/trunk/qa/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/qa/build.xml?rev=819236&r1=819235&r2=819236&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/qa/build.xml (original)
+++ incubator/river/jtsk/trunk/qa/build.xml Sun Sep 27 00:15:03 2009
@@ -57,7 +57,7 @@
<path id="javadoc.classpath">
<path refid="river.classpath"/>
- <path location="${build.classes}"/>
+ <path location="${build.classes.dir}"/>
</path>
<path id="ext.dirs.path">