Log the user in

Note: See the sample files XMLApiAdapter.java and login.jsp.

Your application needs a method that logs users in to Adobe Connect. A login method needs to open a connection to the server, call the login action, and get the XML response. The method also needs to read the value of the BREEZESESSION cookie from the response header and store the value.

The simplest form of the login action is:

https://example.com/api/xml?action=login&login=joy@example.com 
        &password=jazz

You might also need to add session , account-id , or domain parameters to the login action (see Log in from an application for more ways to call login ).

A successful login returns this response, with a status code of ok :

<?xml version="1.0" encoding="utf-8" ?>  
<results> 
    <status code="ok" />  
</results>

Build the base request URL

The login method should first build the base request URL to send to the server. In the sample, the breezeUrl method builds a URL like this:

http://example.com/api/xml?action=

The method also adds an action name and query string that you pass to it. This is the full method:

protected URL breezeUrl(String action, String queryString) 
            throws MalformedURLException { 
    return new URL(getBaseUrl() + "/api/xml?" + "action=" + action 
            + (queryString != null ? ('&' + queryString) : "")); 
}

Send the user’s login information

The login method calls the login action, opens the connection to the server, reads the BREEZESESSION cookie from the response header, and then checks for a status code of ok in the response:

protected void login() throws XMLApiException { 
    try { 
        if (breezesession != null) 
            logout(); 
 
        URL loginUrl = breezeUrl("login", "login=" + getLogin() 
                + "&password=" + getPassword()); 
 
        URLConnection conn = loginUrl.openConnection(); 
        conn.connect(); 
 
        InputStream resultStream = conn.getInputStream(); 
        Document doc = new SAXBuilder(false).build(resultStream); 
 
        String breezesessionString = (String) (conn 
                .getHeaderField("Set-Cookie")); 
 
        StringTokenizer st = new StringTokenizer(breezesessionString, "="); 
        String sessionName = null; 
 
        if (st.countTokens() > 1) 
            sessionName = st.nextToken(); 
 
        if (sessionName != null    &&  
            sessionName.equals("BREEZESESSION")) { 
            String breezesessionNext = st.nextToken(); 
            int semiIndex = breezesessionNext.indexOf(';'); 
            breezesession = breezesessionNext.substring(0, semiIndex); 
        }  
 
        Element root = doc.getRootElement(); 
        String status = getStatus(root); 
        if (breezesession == null || !"ok".equalsIgnoreCase(status)) 
            throw new XMLApiException("Could not log into Adobe Connect."); 
    } catch (IOException ioe) { 
            throw new XMLApiException(IO_ERROR, ioe); 
    } catch (JDOMException jde) { 
            throw new XMLApiException(PARSE_ERROR, jde); 
    } 
}

// Ethnio survey code removed