Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirusCheckPlugin4Rosetta
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
VirusCheckPlugin4Rosetta
Commits
249763e8
Commit
249763e8
authored
11 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- added support to getAgent()
parent
f46982d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
+41
-1
41 additions, 1 deletion
...tta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
with
41 additions
and
1 deletion
java/org/slub/rosetta/dps/repository/plugin/SLUBVirusCheckClamAVPlugin.java
+
41
−
1
View file @
249763e8
...
@@ -40,6 +40,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
...
@@ -40,6 +40,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
//private static final ExLogger log = ExLogger.getExLogger(SLUBVirusCheckClamAVPlugin.class);
//private static final ExLogger log = ExLogger.getExLogger(SLUBVirusCheckClamAVPlugin.class);
private
static
final
int
DEFAULT_CHUNK_SIZE
=
2048
;
private
static
final
int
DEFAULT_CHUNK_SIZE
=
2048
;
private
static
final
byte
[]
INSTREAM
=
"zINSTREAM\0"
.
getBytes
();
private
static
final
byte
[]
INSTREAM
=
"zINSTREAM\0"
.
getBytes
();
private
static
final
byte
[]
VERSION
=
"zVERSION\0"
.
getBytes
();
private
static
final
String
RESPONSEOK
=
"stream: OK"
;
private
static
final
String
RESPONSEOK
=
"stream: OK"
;
private
static
final
String
FOUND_SUFFIX
=
"FOUND"
;
private
static
final
String
FOUND_SUFFIX
=
"FOUND"
;
private
static
final
String
STREAM_PREFIX
=
"stream: "
;
private
static
final
String
STREAM_PREFIX
=
"stream: "
;
...
@@ -144,7 +145,45 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
...
@@ -144,7 +145,45 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
}
}
public
String
getAgent
()
{
public
String
getAgent
()
{
return
"clamd"
;
try
{
// create a socket
Socket
socket
=
new
Socket
();
//socket.connect( new InetSocketAddress(getHost()));
socket
.
connect
(
new
InetSocketAddress
(
getHost
(),
getPort
()));
try
{
socket
.
setSoTimeout
(
getTimeOut
()
);
}
catch
(
SocketException
e
)
{
System
.
out
.
println
(
"Could not set socket timeout to "
+
getTimeOut
()
+
"ms "
+
e
);
//log.error( "Could not set socket timeout to " + getTimeOut() + "ms", e);
}
DataOutputStream
dos
=
null
;
response
=
""
;
try
{
dos
=
new
DataOutputStream
(
socket
.
getOutputStream
());
dos
.
write
(
VERSION
);
int
read
;
byte
[]
buffer
=
new
byte
[
DEFAULT_CHUNK_SIZE
];
dos
.
flush
();
read
=
socket
.
getInputStream
().
read
(
buffer
);
if
(
read
>
0
)
response
=
new
String
(
buffer
,
0
,
read
);
}
finally
{
if
(
dos
!=
null
)
try
{
dos
.
close
();
}
catch
(
IOException
e
)
{
// log.debug("exception closing DOS", e);
System
.
out
.
println
(
"exception closing DOS "
+
e
);
}
try
{
socket
.
close
();
}
catch
(
IOException
e
)
{
// log.debug("exception closing socket", e);
System
.
out
.
println
(
"exception closing socket "
+
e
);
}
}
return
response
;
}
catch
(
IOException
e
)
{
//log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e);
System
.
out
.
println
(
"exception creation socket, clamd not available at host="
+
host
+
"port="
+
port
+
" "
+
e
);
setStatus
(
Status
.
FAILED
);
setSignature
(
"ERROR: clamd not available"
);
return
"ERROR: clamd not available"
;
}
}
}
public
boolean
isVirusFree
()
{
public
boolean
isVirusFree
()
{
...
@@ -155,6 +194,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
...
@@ -155,6 +194,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
// stand alone check
// stand alone check
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SLUBVirusCheckClamAVPlugin
plugin
=
new
SLUBVirusCheckClamAVPlugin
(
"127.0.0.1"
,
3310
,
60
);
SLUBVirusCheckClamAVPlugin
plugin
=
new
SLUBVirusCheckClamAVPlugin
(
"127.0.0.1"
,
3310
,
60
);
System
.
out
.
println
(
"Agent: "
+
plugin
.
getAgent
()
);
for
(
String
file:
args
)
{
for
(
String
file:
args
)
{
plugin
.
scan
(
file
);
plugin
.
scan
(
file
);
System
.
out
.
println
(
"RESULT: "
+
plugin
.
isVirusFree
()
+
" SIGNATURE: "
+
plugin
.
getOutput
());
System
.
out
.
println
(
"RESULT: "
+
plugin
.
isVirusFree
()
+
" SIGNATURE: "
+
plugin
.
getOutput
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment