Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openconnect
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
mirror
openconnect
Commits
42918c34
Commit
42918c34
authored
Aug 05, 2018
by
Daniel Lenski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
describe and set protocol in Java test application
parent
1391c86c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
java/README
java/README
+1
-1
java/src/com/example/LibTest.java
java/src/com/example/LibTest.java
+39
-5
No files found.
java/README
View file @
42918c34
...
...
@@ -11,7 +11,7 @@ From the top level, run:
make
cd java
ant
sudo java -Djava.library.path=../.libs -jar dist/example.jar <server_
ip>
sudo java -Djava.library.path=../.libs -jar dist/example.jar <server_
name> [protocol]
If ocproxy[1] is installed somewhere in your $PATH, this can be run as a
non-root user and it should be pingable from across the VPN.
...
...
java/src/com/example/LibTest.java
View file @
42918c34
...
...
@@ -204,12 +204,30 @@ public final class LibTest {
System
.
out
.
println
(
""
);
}
private
static
void
describeProtocol
(
LibOpenConnect
.
VPNProto
vp
)
{
ArrayList
<
String
>
flags
=
new
ArrayList
<
String
>();
if
((
vp
.
flags
&
LibOpenConnect
.
OC_PROTO_PROXY
)
!=
0
)
flags
.
add
(
"proxy"
);
if
((
vp
.
flags
&
LibOpenConnect
.
OC_PROTO_CSD
)
!=
0
)
flags
.
add
(
"CSD"
);
if
((
vp
.
flags
&
LibOpenConnect
.
OC_PROTO_AUTH_CERT
)
!=
0
)
flags
.
add
(
"auth-cert"
);
if
((
vp
.
flags
&
LibOpenConnect
.
OC_PROTO_AUTH_OTP
)
!=
0
)
flags
.
add
(
"auth-otp"
);
if
((
vp
.
flags
&
LibOpenConnect
.
OC_PROTO_AUTH_OTP
)
!=
0
)
flags
.
add
(
"auth-stoken"
);
System
.
out
.
println
(
" "
+
vp
.
name
+
") PRETTY_NAME="
+
vp
.
prettyName
+
", DESCRIPTION="
+
vp
.
description
+
", FLAGS="
+
String
.
join
(
"+"
,
flags
));
}
public
static
void
main
(
String
argv
[])
{
System
.
loadLibrary
(
"openconnect-wrapper"
);
LibOpenConnect
lib
=
new
TestLib
();
String
server_name
,
protocol
;
if
(
argv
.
length
!=
1
)
die
(
"usage: LibTest <server_name>"
);
if
(
argv
.
length
!=
1
&&
argv
.
length
!=
2
)
die
(
"usage: LibTest <server_name> [protocol]"
);
server_name
=
argv
[
0
];
protocol
=
argv
.
length
==
2
?
argv
[
1
]
:
null
;
System
.
out
.
println
(
"OpenConnect version: "
+
lib
.
getVersion
());
System
.
out
.
println
(
" PKCS="
+
lib
.
hasPKCS11Support
()
+
...
...
@@ -217,13 +235,29 @@ public final class LibTest {
", STOKEN="
+
lib
.
hasStokenSupport
()
+
", OATH="
+
lib
.
hasOATHSupport
()
+
", YUBIOATH="
+
lib
.
hasYubiOATHSupport
());
System
.
out
.
println
(
"Supported protocols:"
);
for
(
LibOpenConnect
.
VPNProto
vp
:
lib
.
getSupportedProtocols
())
describeProtocol
(
vp
);
if
(
protocol
==
null
)
{
System
.
out
.
println
(
"Using default VPN protocol of "
+
lib
.
getProtocol
());
}
else
{
System
.
out
.
println
(
"Setting VPN protocol to "
+
protocol
);
if
(
lib
.
setProtocol
(
protocol
)
!=
0
)
die
(
"Error setting VPN protocol"
);
}
lib
.
setReportedOS
(
"win"
);
lib
.
setLogLevel
(
lib
.
PRG_DEBUG
);
//lib.setTokenMode(LibOpenConnect.OC_TOKEN_MODE_STOKEN, null);
if
(
new
File
(
"csd.sh"
).
exists
())
{
lib
.
setCSDWrapper
(
"csd.sh"
,
null
,
null
);
String
csd_wrapper
=
"./csd-"
+
lib
.
getProtocol
()
+
".sh"
;
if
(
new
File
(
csd_wrapper
).
exists
())
{
System
.
out
.
println
(
"Using CSD wrapper script "
+
csd_wrapper
);
lib
.
setCSDWrapper
(
csd_wrapper
,
null
,
null
);
}
else
{
System
.
out
.
println
(
"Skipping CSD wrapper (script "
+
csd_wrapper
+
" doesn't exist)"
);
}
lib
.
parseURL
(
argv
[
0
]
);
lib
.
parseURL
(
server_name
);
lib
.
setSystemTrust
(
true
);
int
ret
=
lib
.
obtainCookie
();
if
(
ret
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment