278
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.setNortelToken(cookie);
return cred;
}
public PasswordAuthentication getProxyCredentials() {
LoginDialog loginDialog = new LoginDialog();
return new PasswordAuthentication(loginDialog.getUserId()
,
loginDialog.getPassword(
)
.toCharArray(
));
}
};
portForwarder.setAuthenticator(pfa);
Nortel VPN Gateway
User Guide
NN46120-104
02.01
Standard
14 April 2008
Copyright © 2007-2008 Nortel Networks
.
Содержание NN46120-104
Страница 1: ...Nortel VPN Gateway User Guide Release 7 1 Document Revision 02 01 www nortel com NN46120 104 216368 G...
Страница 277: ...Example 277 Nortel VPN Gateway User Guide NN46120 104 02 01 Standard 14 April 2008 Copyright 2007 2008 Nortel Networks...
Страница 281: ...Example 281 Nortel VPN Gateway User Guide NN46120 104 02 01 Standard 14 April 2008 Copyright 2007 2008 Nortel Networks...
Страница 299: ......