
private String getCookieFromURL(String spec) {
try {
URL url = new URL(spec);
URLConnection connection = null;
((HttpURLConnection) connection).setFollowRedirects(false);
connection = url.openConnection();
connection.getInputStream();
/* check if we are authorized */
if (connection != null) {
String headerField =
getHeaderField(connection, SET_COOKIE_HEADER);
return headerField.substring (headerField.indexOf('=') + 1,
headerField.indexOf(';'));
} else {
return null;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
PortForwarderAuthenticator pfa =
new PortForwarderAuthenticator() {
public PortForwarderCredentials getCredentials() {
cookie = getCookieFromURL(loginUrl);
if (cookie == null) {
return null;
}
cred.setAvayaToken(cookie);
return cred;
}
public PasswordAuthentication getProxyCredentials() {
LoginDialog loginDialog = new LoginDialog();
return new PasswordAuthentication(loginDialog.getUserId(),
loginDialog.getPassword()
.toCharArray());
}
};
portForwarder.setAuthenticator(pfa);
Adding a Port Forwarder Logger
A Port Forwarder logger must implement the PortForwarderLogger interface:
public void log(int logLevel, int logCode, Object[] params, Throwable
throwable);
public void log(int logLevel, String msg, Throwable throwable);
The first function is used when the Port Forwarder logs a message in the Messages.properties
file, i.e. messages of type PortForwarderConstants.LOG_LEVEL_INFO and
PortForwarderConstants.LOG_LEVEL_ERROR and the second one is used for messages of
Using the Port Forwarder API
260 User Guide
April 2013
Comments? [email protected]
Содержание 3050-VM
Страница 1: ...User Guide Avaya VPN Gateway Release 9 0 NN46120 104 Issue 04 04 April 2013 ...
Страница 4: ...4 User Guide April 2013 Comments infodev avaya com ...
Страница 12: ...12 User Guide April 2013 ...
Страница 20: ...New in this release 20 User Guide April 2013 Comments infodev avaya com ...
Страница 30: ...Introducing the VPN Gateway 30 User Guide April 2013 Comments infodev avaya com ...
Страница 36: ...Introducing the ASA 310 FIPS 36 User Guide April 2013 Comments infodev avaya com ...
Страница 74: ...Upgrading the AVG Software 74 User Guide April 2013 Comments infodev avaya com ...
Страница 86: ...Managing Users and Groups 86 User Guide April 2013 Comments infodev avaya com ...
Страница 130: ...The Command Line Interface 130 User Guide April 2013 Comments infodev avaya com ...
Страница 162: ...Supported Ciphers 162 User Guide April 2013 Comments infodev avaya com ...
Страница 212: ...Syslog Messages 212 User Guide April 2013 Comments infodev avaya com ...
Страница 242: ...Definition of Key Codes 242 User Guide April 2013 Comments infodev avaya com ...
Страница 259: ...Creating a Port Forwarder Authenticator User Guide April 2013 259 ...
Страница 265: ...This will print current statistics every 3 seconds Monitoring the Port Forwarder User Guide April 2013 265 ...
Страница 266: ...Using the Port Forwarder API 266 User Guide April 2013 Comments infodev avaya com ...
Страница 274: ...X 509 274 User Guide April 2013 Comments infodev avaya com ...