2
2
3
3
import java .io .File ;
4
4
import java .io .FileInputStream ;
5
- // import java.io.FileOutputStream; // Only needed when debugging the code
5
+ import java .io .FileOutputStream ; // for debugging only
6
6
import java .io .IOException ;
7
+ import java .text .DateFormat ;
8
+ import java .text .SimpleDateFormat ;
7
9
import java .io .BufferedInputStream ;
8
10
import java .io .ByteArrayInputStream ;
9
11
import java .util .ArrayList ;
10
12
import java .util .Collection ;
13
+ import java .util .Date ;
11
14
import java .util .List ;
15
+ import java .util .TimeZone ;
12
16
13
17
import com .drew .imaging .ImageMetadataReader ;
14
18
import com .drew .imaging .ImageProcessingException ;
@@ -116,27 +120,35 @@ public String getAuthor() {
116
120
public static String [] scanForLocationInImageBoth (byte [] data ) {
117
121
String [] results = { EmptyString , EmptyString , EmptyString };
118
122
119
- /* // Extreme debugging code for making sure data from Burp/ZAP/new-proxy gets into
120
- // ILS. This code is very slow and not to be compiled in, even with if(debug)
121
- // types of constructs. This code this will save the image file to disk for binary
122
- // import debugging.
123
- String t[] = new String[3];
124
- try{
125
- FileOutputStream o = new FileOutputStream(new File("/tmp/output.jpg"));
126
- o.write(data);
127
- o.close();
128
- } catch (IOException e) {
129
- t[0] = "IOException Exception " + e.toString();
123
+ // Extreme debugging code for making sure data from Burp/ZAP/new-proxy gets into
124
+ // ILS. This code is very slow and not to be compiled in, even with if(debug)
125
+ // types of constructs. This code this will save the image file to disk for binary
126
+ // import debugging.
127
+ /*
128
+ if (false) {
129
+ String t[] = { EmptyString, EmptyString, EmptyString };
130
+ try{
131
+ TimeZone tz = TimeZone.getTimeZone("UTC");
132
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); // Quoted "Z" to indicate UTC, no timezone offset
133
+ df.setTimeZone(tz);
134
+ String nowAsISO = df.format(new Date());
135
+ FileOutputStream o = new FileOutputStream(new File("/tmp/ILS-debug-" + nowAsISO + ".jpg"));
136
+ o.write(data);
137
+ o.close();
138
+ } catch (IOException e) {
139
+ t[0] = "IOException Exception " + e.toString();
140
+ t[1] = t[0];
141
+ t[2] = t[0];
142
+ return t;
143
+ }
144
+ t[0] = "Scanning " + data.length + "\n\n";
130
145
t[1] = t[0];
131
146
t[2] = t[0];
132
- return t;
147
+ // return t;
148
+ // --- if you use this return line, remember to comment out rest of function.
133
149
}
134
- t[0] = "Scanning " + data.length + "\n\n";
135
- t[1] = t[0];
136
- t[2] = t[0];
137
- // return t; /* --- if you use this line, remember to comment out rest of function.
138
- */
139
-
150
+ */
151
+
140
152
try {
141
153
BufferedInputStream is = new BufferedInputStream (new ByteArrayInputStream (data , 0 , data .length ));
142
154
Metadata md = ImageMetadataReader .readMetadata (is );
@@ -147,24 +159,26 @@ public static String[] scanForLocationInImageBoth(byte[] data) {
147
159
results = scanForPrivacy (md );
148
160
149
161
if (tmp [0 ].length () > 0 ) {
150
- // minor formatting if we have both.
162
+ // minor formatting update if we have both Location and Privacy .
151
163
results [0 ] = tmp [0 ] + "" + results [0 ];
152
164
results [1 ] = "<ul>" + tmp [1 ] + results [1 ] + "</ul>" ;
153
165
results [2 ] = " " + tmp [2 ] + results [2 ];
154
166
167
+ /*
155
168
// AGAIN: this is for extreme debugging
156
- // results[0] = "DBG: " + t[0] + "\n\n" + results[0];
157
- // results[1] = "DBG: " + t[1] + "\n\n" + results[1];
158
- // results[2] = "DBG: " + t[2] + "\n\n" + results[2];
169
+ results[0] = "DBG: " + t[0] + "\n\n" + results[0];
170
+ results[1] = "DBG: " + t[1] + "\n\n" + results[1];
171
+ results[2] = "DBG: " + t[2] + "\n\n" + results[2];
172
+ */
159
173
}
160
174
161
175
162
176
} catch (ImageProcessingException e ) {
163
177
// bad image, just ignore processing exceptions
164
- // DEBUG: return new String("ImageProcessingException " + e.toString());
178
+ // DEBUG: return new String("ImageProcessingException: " + e.toString());
165
179
} catch (IOException e ) {
166
180
// bad file or something, just ignore
167
- // DEBUG: return new String("IOException " + e.toString());
181
+ // DEBUG: return new String("IOException: " + e.toString());
168
182
}
169
183
170
184
return results ;
@@ -376,7 +390,7 @@ public static String[] scanForLocation(Metadata md) {
376
390
PanasonicMakernoteDirectory .TAG_LANDMARK ,
377
391
PanasonicMakernoteDirectory .TAG_LOCATION ,
378
392
PanasonicMakernoteDirectory .TAG_STATE ,
379
- //PanasonicMakernoteDirectory.TAG_WORLD_TIME_LOCATION //not 100% sure, but this might expose timezone aka location - I only see value "HOME".
393
+ //PanasonicMakernoteDirectory.TAG_WORLD_TIME_LOCATION // might expose timezone aka location - but I only see value "HOME" in my samples .
380
394
};
381
395
382
396
if (panasonicDirColl != null ) {
0 commit comments