forked from s1th/system_i_audit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas4sysval.java
106 lines (86 loc) · 3.06 KB
/
as4sysval.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//Java program to get System Values
//import com.ibm.as400.access.*;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.SystemValueGroup;
import com.ibm.as400.access.SystemValue;
import com.ibm.as400.access.SystemValueList;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Vector;
class as4sysval
{
public static void main (String[] args)
{
AS400 sys = null; //AS400 system
String system = args[0]; //iSeries ip address
Vector systemValues = null; //vector to hold system values
String newline = System.getProperty("line.separator");
String outFileName = args[3] + "\\as4.system.values.txt";
try
{
BufferedWriter outFile = new BufferedWriter(new FileWriter(outFileName));
String outLine = "";
//connect to system
sys = new AS400(system,args[1],args[2]);
//retrieve the security related system valuse and any other that we specify
String svName = "Security Related Values";
String svDescription = "The relevant security related system values.";
//get all security related system values
SystemValueGroup svGroup = new SystemValueGroup(sys,svName,svDescription,SystemValueList.GROUP_SEC);
//add/remove some
svGroup.add("QAUTOVRT");
svGroup.add("QATNPGM");
svGroup.remove("QDSPSGNINF");
svGroup.remove("QSCANFS");
svGroup.remove("QSCANFSCTL");
//retrieve system values vector
systemValues = svGroup.getSystemValues();
//process system values, do analysis, and write out file
for (int i = 0; i < systemValues.size(); i++)
{
//retrieve data
SystemValue sv = (SystemValue)systemValues.elementAt(i);
//system val's name
String name = (String) sv.getName();
//setting
Object val = sv.getValue();
//description
String desc = sv.getDescription();
//need to determine it's class to make sure the casting goes smoothly
//have to cast to either a String or array of Strings
String cls = val.getClass().toString();
if (cls.equals("class [Ljava.lang.String;"))
{
//array of strings
String[] arr = (String[])val;
String outValue = "[";
for (int j = 0; j < arr.length; j++)
{
outValue = outValue + arr[j] + " ";
}
outValue = outValue + "]";
//write out to file
outLine = name + "|" + outValue + "|" + desc + newline;
}else
{
//just a string or integer, so get string representation and go from there
String outValue = sv.getValue().toString();
outLine = name + "|" + outValue + "|" + desc + newline;
}
//write output
outFile.write(outLine);
}
outFile.flush();
outFile.close();
sys.disconnectAllServices();
}catch (Exception e)
{
System.out.println("Error occurred during processing.");
e.printStackTrace();
System.out.println("");
System.out.println("***If processing at SMWE, make sure Secure Client is not running***");
System.exit(1);
}
System.exit(0);
} //end main() method
} //end AS4SystemValues class