Adding A Port Forwarder Logger - Avaya VPN Gateway User Manual

Vpn gateway
Table of Contents

Advertisement

Using the Port Forwarder API
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
260
User Guide
Comments? infodev@avaya.com
April 2013

Advertisement

Table of Contents
loading

This manual is also suitable for:

3050-vmAvg 3050-vm3070-vmAvg 3070-vm3090-vmAvg 3090-vm

Table of Contents