import java.net.*;
import java.io.*;
import javax.net.*;
import javax.net.ssl.*;
class AuthTWN {
String TWNServ =
"loginnet.passport.com";
public void AuthTWN() {
}
try {
this.
USRPass =
URLEncoder.
encode(Password,
"UTF-8");
SSLSocketFactory ssl = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) ssl.createSocket(this.TWNServ, 443);
Challenge =
URLDecoder.
decode(Challenge,
"UTF-8");
Challenge = Challenge.replaceAll(",", "&");
Challenge = Challenge.replaceAll("&", "&");
buf2.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buf2.append("<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\"><Header>");
buf2.append("<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">");
buf2.append("<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>");
buf2.append("<ps:BinaryVersion>4</ps:BinaryVersion>");
buf2.append("<ps:UIVersion>1</ps:UIVersion>");
buf2.append("<ps:Cookies></ps:Cookies>");
buf2.append("<ps:RequestParams>AQAAAAIAAABsYwQAAAAzMDg0</ps:RequestParams>");
buf2.append("</ps:AuthInfo>");
buf2.append("<wsse:Security>");
buf2.append("<wsse:UsernameToken Id=\"user\">");
buf2.append("<wsse:Username>" + Email + "</wsse:Username>");
buf2.append("<wsse:Password>" + Password + "</wsse:Password>");
buf2.append("</wsse:UsernameToken>");
buf2.append("</wsse:Security>");
buf2.append("</Header>");
buf2.append("<Body>");
buf2.append("<ps:RequestMultipleSecurityTokens xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"RSTS\">");
buf2.append("<wst:RequestSecurityToken Id=\"RST0\">");
buf2.append("<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>");
buf2.append("<wsp:AppliesTo>");
buf2.append("<wsa:EndpointReference>");
buf2.append("<wsa:Address>http://Passport.NET/tb</wsa:Address>");
buf2.append("</wsa:EndpointReference>");
buf2.append("</wsp:AppliesTo>");
buf2.append("</wst:RequestSecurityToken>");
buf2.append("<wst:RequestSecurityToken Id=\"RST1\">");
buf2.append("<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>");
buf2.append("<wsp:AppliesTo>");
buf2.append("<wsa:EndpointReference>");
buf2.append("<wsa:Address>messenger.msn.com</wsa:Address>");
buf2.append("</wsa:EndpointReference>");
buf2.append("</wsp:AppliesTo>");
buf2.append("<wsse:PolicyReference URI=\"?" + Challenge + "\"></wsse:PolicyReference>");
buf2.append("</wst:RequestSecurityToken>");
buf2.append("</ps:RequestMultipleSecurityTokens>");
buf2.append("</Body></Envelope>");
buf.append("POST " + TWNPage + " HTTP/1.1" + "\r\n");
buf.append("Accept: text/*" + "\r\n");
buf.append("User-Agent: TomsMSNBot/3.0" + "\r\n");
buf.append("Host: " + TWNServ + "\r\n");
buf.append("Content-Length: " + buf2.length() + "\r\n");
buf.append("Connection: Keep-Alive" + "\r\n");
buf.append("Cache-Control: no-cache" + "\r\n");
buf.append("\r\n");
buf.append(buf2.toString());
pw.print(buf.toString());
pw.flush();
buf2 = null;
boolean DoLoop = true;
int Length = 0;
while(DoLoop) {
if(str.substring(0,15).equals("Content-Length:")) {
String[] DataArray = str.
split(" ");
Length =
Integer.
parseInt(DataArray
[1]) +
2;
for(int i = 0; i < Length; i++) {
int c = br.read();
buf.append((char) c);
}
String[] temp = data.
split("BinarySecurityToken");
data = temp[1];
data = data.substring(15, (data.length()-7));
data = data.replaceAll("&", "&");
this.ReturnVal = data;
DoLoop = false;
}
}
}
}
finally {
return this.ReturnVal;
}
}
}