Commit e65cf387 authored by Claes Sjofors's avatar Claes Sjofors

Web site can be opened from another than the process/operator station

parent 645fa0ba
......@@ -55,6 +55,7 @@ public class JopApplet extends JApplet
{
public JopSession session;
public JopEngine engine;
String pwrHost;
public JopApplet()
{
......@@ -62,6 +63,8 @@ public class JopApplet extends JApplet
public void init() {
String instance = this.getParameter("instance");
pwrHost = getParameter( "pwrhost");
System.out.println( "Parameter pwrhost: " + pwrHost);
engine = new JopEngine(1000, (Object)this);
session = new JopSession( engine, (Object)this);
......@@ -89,4 +92,7 @@ public class JopApplet extends JApplet
public String[][] getParameterInfo() {
return null;
}
public String getPwrHost() {
return pwrHost;
}
}
......@@ -105,6 +105,7 @@ public class JopOpWindowApplet extends JopApplet
size = new Dimension( 300, 900);
setSize( size);
engine.setFrameReady();
}
public void start() {
......
......@@ -136,12 +136,13 @@ public class Gdh
{
try
{
URL url = ((JApplet)root).getCodeBase();
if(trace)
{
System.out.println("Opening socket to " + url.getHost());
String pwrHost = ((jpwr.jop.JopApplet)root).getPwrHost();
if ( pwrHost == null) {
URL url = ((JApplet)root).getDocumentBase();
pwrHost = url.getHost();
}
gdhSocket = new Socket(url.getHost(), 4445);
System.out.println("Opening socket to " + pwrHost);
gdhSocket = new Socket(pwrHost, 4445);
out = new ObjectOutputStream(new BufferedOutputStream(gdhSocket.getOutputStream()));
in = new ObjectInputStream(new BufferedInputStream(gdhSocket.getInputStream()));
......
......@@ -39,6 +39,7 @@
function=$1
src_file=$2
systemname=$3
signature=$4
if [ $function == "java_web" ]; then
......@@ -73,6 +74,25 @@ if [ $function == "java_web" ]; then
jar -uf $jarfile *.jpg
fi
if [ "$signature" != "" ]; then
storepass=${signature#*/}
passopt=""
if [ "$storepass" != "$signature" ]; then
signature=${signature%/*}
passopt="-storepass "$storepass
fi
jars=`eval ls $pwrp_web/*.jar`
for jarfile in $jars; do
ok="jar verified."
res=`eval jarsigner -verify $jarfile $signature`
if [ "$res" != "$ok" ]; then
echo "-- Signature $signature set to $jarfile"
jarsigner $passopt $jarfile $signature
fi
done
fi
fi
fi
......@@ -117,7 +137,25 @@ if [ $function == "java" ]; then
jar -uf $jarfile *.jpg
jar -uf $jarfileweb *.jpg
fi
if [ "$signature" != "" ]; then
storepass=${signature#*/}
passopt=""
if [ "$storepass" != "$signature" ]; then
signature=${signature%/*}
passopt="-storepass "$storepass
fi
jars=`eval ls $pwrp_web/*.jar`
for jarfile in $jars; do
ok="jar verified."
res=`eval jarsigner -verify $jarfile $signature`
if [ "$res" != "$ok" ]; then
echo "-- Signature $signature set to $jarfile"
jarsigner $passopt $jarfile $signature
fi
done
fi
fi
fi
......
......@@ -234,6 +234,46 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Name of Proview host when web interface is opened from another
! site than the process or operator station.
!*/
Object PwrHost $Attribute 18
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! @Summary Signature alias set to the project archive.
! To be able to open the web interface from another site than
! the process or operator station, the host name of the process
! station has to be stated in PwrHost and a signature has to be
! applied to the jar-files of the web site. The signature is an
! alias created by keytool and is stated in AppletSignature.
!
! In this example a signature with the alias pwrkey is created with
! a validity of 100 years
!
! > keytool -genkey -alias pwrkey
! > keytool -selfcert -alias pwrkey -validity 36500
!
! The alias should be signed to all jarfiles in $pwrp_web,
! pwr_rt_client.jar, pwr_jop.jar, pwr_jopc.jar etc. This is done with
! jarsigner
!
! > jarsigner $pwrp_web/pwr_rt_client.jar pwrkey
!
! The project specific jarfile will automatically be signed if the
! alias is stated in AppletSignature. Note that the passphrase for the
! keystore has to be entered in the terminal window. It is possible to
! state the passphrase in the AppletSignature after the alias and a '/',
! eg 'pwrkey/mypassphrase'.
!*/
Object AppletSignature $Attribute 19
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! A message created by an ASup or DSup object gets the
! same identity as the supervised object. Messages
! produced in an application by means of mh_ApplMessage
......
......@@ -771,6 +771,7 @@ void wb_build::webgraph( pwr_tOid oid)
pwr_tFileName graph_name, dir;
char dev[80], type[80];
int version;
pwr_tString80 appletsignature = "";
wb_object o = m_session.object(oid);
if ( !o) {
......@@ -861,8 +862,31 @@ void wb_build::webgraph( pwr_tOid oid)
MsgWindow::message('W', cmd, msgw_ePop_No, oid);
}
else {
// Get signature from WebHandler
for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) {
if ( p.cid() == pwr_cClass_WebHandler) {
wb_attribute a = m_session.attribute( p.oid(), "RtBody", "AppletSignature");
if ( !a) {
m_sts = a.sts();
return;
}
a.value( appletsignature);
if ( !a) {
m_sts = a.sts();
return;
}
dcli_trim( appletsignature, appletsignature);
break;
}
}
Ge *gectx = m_wnav->ge_new( graph_name, 1);
strcpy( cmd, "export java");
if ( strcmp( appletsignature, "") == 0)
strcpy( cmd, "export java");
else
sprintf( cmd, "export java /signature=\"%s\"", appletsignature);
m_sts = gectx->command( cmd);
if ( evenSts()) {
msg_GetMsg( m_sts, cmd, sizeof(cmd));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment