Commit 588f1ffd authored by Claes Sjofors's avatar Claes Sjofors

Java script fixes, and default priv for java environment changed to RtRead

parent 07c26ee1
......@@ -187,10 +187,13 @@ public class JopSpider {
"cli_arg4", "/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK", "/INDEX",
"/BASE", "/RETURNCOMMAND", "/WIDTH", "/HEIGHT", "/VERSION"}),
new CliTable( "SET", new String[] {"cli_arg1", "cli_arg2", "/NAME",
"/SOURCE", "/OBJECT", "/VALUE", "/BYPASS"}),
"/SOURCE", "/OBJECT", "/VALUE", "/BYPASS", "/PUBLICWRITE"}),
new CliTable( "EXAMPLE", new String[] {"/NAME", "/HIERARCHY"}),
new CliTable( "CHECK", new String[] {"cli_arg1", "/METHOD", "/OBJECT"}),
new CliTable( "CALL", new String[] {"cli_arg1", "/METHOD", "/OBJECT"})
new CliTable( "CALL", new String[] {"cli_arg1", "/METHOD", "/OBJECT"}),
new CliTable( "LOGIN", new String[] {"cli_arg1", "cli_arg2"}),
new CliTable( "LOGOUT", null),
new CliTable( "SHOW", new String[] {"cli_arg1"}),
};
......@@ -594,7 +597,6 @@ public class JopSpider {
if ( parameter.length() >= cli_arg1.length() &&
parameter.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "SET PARAMETER"
if ( root instanceof JopApplet) {
String name;
String value;
PwrtStatus sts;
......@@ -613,11 +615,36 @@ public class JopSpider {
return 0;
}
boolean bypass = cli.qualifierFound("/BYPASS");
if ( !bypass ) {
if ( bypass) {
System.out.println( "Bypass is obsolete");
}
boolean publicwrite = cli.qualifierFound("/PUBLICWRITE");
if ( publicwrite ) {
GdhrGetAttributeFlags retf = gdh.getAttributeFlags( name);
if ( retf.evenSts()) return 0;
if ( (retf.flags & Pwr.mAdef_publicwrite) == 0) {
System.out.println( "Not authorized");
return 0;
}
if ( ! gdh.isAuthorized( Pwr.mPrv_RtRead | Pwr.mPrv_RtWrite |
Pwr.mPrv_System | Pwr.mPrv_Maintenance |
Pwr.mPrv_Process | Pwr.mPrv_Instrument |
Pwr.mPrv_Operator1 | Pwr.mPrv_Operator2 |
Pwr.mPrv_Operator3 | Pwr.mPrv_Operator4 |
Pwr.mPrv_Operator5 | Pwr.mPrv_Operator6 |
Pwr.mPrv_Operator7 | Pwr.mPrv_Operator8 |
Pwr.mPrv_Operator9 | Pwr.mPrv_Operator10)) {
System.out.println( "Not authorized");
return 0;
}
}
else {
// Need RtWrite or System to set attribute
if ( ! gdh.isAuthorized(
Pwr.mPrv_RtWrite | Pwr.mPrv_System)) {
System.out.println( "No authorized");
if ( ! gdh.isAuthorized( Pwr.mPrv_RtWrite | Pwr.mPrv_System)) {
System.out.println( "Not authorized");
return 0;
}
}
......@@ -625,6 +652,7 @@ public class JopSpider {
// Get type of attribute
GdhrGetAttributeChar ret = gdh.getAttributeChar( name);
if ( ret.evenSts()) return 0;
System.out.println( "Char sts " + ret.sts);
if ( ret.typeId == Pwr.eType_Float32) {
float setValue = Float.parseFloat( value);
......@@ -654,7 +682,6 @@ public class JopSpider {
if ( sts.evenSts())
System.out.println( "setObjectInfoError " + sts);
}
}
String subwindow = "SUBWINDOW";
if ( subwindow.length() >= cli_arg1.length() &&
......@@ -858,6 +885,41 @@ public class JopSpider {
}
}
else if ( command.equals("LOGOUT")) {
gdh.logout();
}
else if ( command.equals("LOGIN")) {
if ( cli.qualifierFound("cli_arg1") && cli.qualifierFound("cli_arg2")) {
String username = cli.getQualValue("cli_arg1");
String passwd = cli.getQualValue("cli_arg2");
passwd = JopCrypt.crypt( "aa", passwd);
int sts = gdh.login( username, passwd);
if ( (sts & 1) == 1)
System.out.println( "User " + username + " logged in");
else
System.out.println( "User not authorized");
}
else {
System.out.println( "Cmd: Syntax error\n");
return 0;
}
}
else if ( command.equals("SHOW")) {
if ( cli.qualifierFound("cli_arg1")) {
String parameter = "USER";
String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
if ( parameter.length() >= cli_arg1.length() &&
parameter.substring(0,cli_arg1.length()).equals(cli_arg1)) {
// Command is "SHOW USER"
String username = gdh.getUser();
if ( username == null)
username = "Not logged in";
int priv = gdh.getPrivilege();
System.out.println( "User: " + username + " " + priv);
}
}
}
}
else {
System.out.println( "JopSpider: Parse error " + cli.getStsString());
......
......@@ -91,7 +91,7 @@ public class JopgCcm {
CdhrObjid reto = gdh.getRootList();
sts = reto.sts;
if ( reto.oddSts()) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -120,7 +120,7 @@ public class JopgCcm {
CdhrObjid reto = gdh.getNodeObject( 0);
sts = reto.sts;
if ( reto.oddSts()) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -156,7 +156,7 @@ public class JopgCcm {
CdhrObjid reto = gdh.getClassList( retc.classId);
sts = reto.sts;
if ( reto.oddSts()) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -193,7 +193,7 @@ public class JopgCcm {
reto = gdh.getNextObject( reto.objid);
sts = reto.sts;
if ( reto.oddSts()) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -275,7 +275,7 @@ public class JopgCcm {
sts = reto.sts;
}
if ( Ccm.ODD(sts)) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -313,7 +313,7 @@ public class JopgCcm {
sts = reto.sts;
}
if ( Ccm.ODD(sts)) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -351,7 +351,7 @@ public class JopgCcm {
sts = reto.sts;
}
if ( Ccm.ODD(sts)) {
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
CdhrString rets = gdh.objidToName( reto.objid, Cdh.mNName);
sts = rets.sts;
if ( rets.oddSts())
ret.rstring = rets.str;
......@@ -465,13 +465,14 @@ public class JopgCcm {
sts = 0;
}
}
if ( Ccm.EVEN(sts)) {
if ( args.length == 2) {
if ( Ccm.EVEN(sts))
args[1].value_int = sts;
else
args[1].value_int = 1;
args[1].value_returned = true;
args[1].var_decl = args[1].value_decl;
}
}
return ret;
}
}
......
......@@ -48,6 +48,7 @@ public class Cdh {
public static final int cManufactClassVolMin = (0 + (0 << 24) + (0 << 16) + (250 << 8) + 0);
public static final int cManufactClassVolMax = (0 + (0 << 24) + (0 << 16) + (254 << 8) + 254);
public static final int mNName = 0;
public static final int mName_volume = 1 << 0;
public static final int mName_path = 1 << 1;
public static final int mName_object = 1 << 2;
......
......@@ -57,7 +57,8 @@ public class Gdh {
private static String currentSystemGroup = null;
private static String currentUser = null;
private static String currentPassword = null;
private static int currentPrivilege = Pwr.mAccess_AllPwr;
private static int defaultPrivilege = Pwr.mPrv_RtRead;
private static int currentPrivilege = defaultPrivilege;
public Gdh( GdhApplIfc root) {
......@@ -140,7 +141,7 @@ public class Gdh {
currentSystemGroup = null;
currentUser = null;
currentPassword = null;
currentPrivilege = Pwr.mAccess_AllPwr;
currentPrivilege = defaultPrivilege;
}
/**
......@@ -156,6 +157,9 @@ public class Gdh {
public String getUser() {
return currentUser;
}
public int getPrivilege() {
return currentPrivilege;
}
/**
Check if the current users privileges matches the access.
......
......@@ -1503,6 +1503,10 @@ public class Gdh
{
return currentUser;
}
public int getPrivilege()
{
return currentPrivilege;
}
public boolean isAuthorized(int access)
......
......@@ -3083,7 +3083,7 @@ The label line is terminated with colon.
include
An script include-file containing functions can be included with the
#include statement. The default file extention is '.pwr_com'
#include statement. The default file extention is '.rtt_com'
<b>Example
......@@ -3808,7 +3808,7 @@ Returns the status of the operation.
string <t>name <t>name of the attribute to write to.
<arbitrary type)<t>value <t>the value to set.
int <t>publicwrite <t>if 1, write to and attribute defined as PublicWrite
int <t>publicwrite <t>if 1, write to an attribute defined as PublicWrite
<t> <t>is allowed also without the RtWrite privilege.
<b>Example
......
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