/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: CLILogin.java,v 1.2 2008/06/25 05:41:27 qcheng Exp $
*
*/
/**
* Portions Copyrighted 2011-2014 ForgeRock AS
*/
public class CLILogin {
// Later more constructors can be added, as per requirements.
}
// Retunrs true if logged in, else returns false. It is just a convenience
// method to check the login status.
public boolean isLoggedIn() {
return isSessionValid();
}
// Returns the SessionId associated with this Session
return cookieValue;
}
// Return the SSOToken associated with this login object
return ssotoken;
}
// Returns true if the session associated with CLILogin object is valid,
// else returns false
public boolean isSessionValid() {
return validateSession(cookieValue);
}
// Returns the output of accessing a URL
try {
} catch (Exception e) {
}
return str;
}
// Returns the cookies associated with the login. Will be implemented later
return null;
}
// logout the user
public void logout() {
try {
}
cookieValue = null;
} catch (SSOException e) {
}
}
// Returns true if login is successful else false.
public boolean login() {
{
return false;
}
boolean loggedin = false;
try {
+ gotoUrl);
if (cookieValue == null)
return false;
// authenticate user using LDAP module through POST
// check if really logged in or not
loggedin = isSessionValid();
}
if (!loggedin)
logout();
return loggedin;
}
// Returns true if the session associated with CLILogin object is valid,
// else returns false
if (cookieValue == null)
return false;
try {
return true;
} else {
return false;
}
} catch (SSOException e) {
}
return false;
}
// Get the iPlanetDirectoryPro cookie from the header, strip off
// the cookie name, domain, and path to get the value, it must be
// included in the next post to the auth server, the cookie anme
// should be taken from the platform.conf
+ url);
return null;
}
return cookie;
}
connection.setDoOutput(true);
// don't follow redirects since we don't care about them
// and the auth will do a final redirect after successful
// authentication. Instead we will just check the session
// to see if auth suceeded.
HttpURLConnection.setFollowRedirects(false);
// Must get the input stream in order to complete the post even
// though we don't care about the response.
}
throws IOException, ProtocolException {
connection.setDoOutput(true);
// read output from server
.getInputStream()));
if (print) {
int len;
char[] buf = new char[1024];
}
}
return strOutput;
}
// System.out.println("cookie=" + cookie);
while (true) {
if (temp == -1) {
return cookie;
} else {
// System.out.println("cookie=" + newCookie);
}
}
}
}