Issues logiing into CMS through Oxyge, methods work fine whe
Posted: Mon Oct 07, 2013 7:56 pm
In the process of trying to integrate some of my previous CMS based work into Oxygen I'm running into a problem where I can't actually authenticate on the server when calling my classes from within an Oxygen Extension.
Here's some of the relevant code that is causing the problem. It works fine when used outside of the Oxygen environment but calling it from an extension always return an authentication failure.
And here's the pertinent part of the DocatoSessionCookie
Right now I'm at a bit of a loss as to what could be causing the issue so if anyone has any ideas I'm open.
-Kit
Here's some of the relevant code that is causing the problem. It works fine when used outside of the Oxygen environment but calling it from an extension always return an authentication failure.
Code: Select all
private int processLoginRequest(String hostURL)
throws CMSConnectionException, CMSAuthenticationFailure,
UnsupportedEncodingException {
{
DocatoSessionCookie cookie = DocatoSessionCookie.getSessionCookie(
hostURL, false);
cookie.setPath("dil-login.do");
String login = URLEncoder.encode(LOGINID, "UTF-8");
String password = URLEncoder.encode(PASSWORD, "UTF-8");
cookie.setData("project=Freescale&username=" + login + "&password="
+ password);
ONLINE = false;
StringBuffer buf = new StringBuffer();
try {
InputStream input = cookie.request();
if (input == null)
System.err.println("NULL INPUTSTREAM");
<snip...>
}
catch (IOException e) {
System.out.println("IO Exception: ");
debug("IOException: " + hostURL, e);
e.printStackTrace();
// throw new CMSConnectionException(hostURL);
}
}
Code: Select all
public InputStream request() throws IOException {
URL url = new URL(surl);
URLConnection conn = url.openConnection();
conn.setRequestProperty("user-agent", "SWING");
if (cookie != null && !cookie.equals("")) {
conn.setRequestProperty("Cookie", cookie);
}
if (data != null) {
conn.setDoOutput(true);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
conn.getOutputStream()));
out.write(data);
out.flush();
try{
out.close();
}
catch(Exception ex){}
}
String c = conn.getHeaderField("Set-Cookie");
if (c != null && !c.equals(""))
cookie = c;
InputStream inputStream = conn.getInputStream();
return inputStream;
} // end request
Right now I'm at a bit of a loss as to what could be causing the issue so if anyone has any ideas I'm open.
-Kit