SourceForge.net Logo

JCas - Client

 
Home | Documentation | Support | Download | Get Involved | Related Sites

JCas User Guide

        Introduction
        Setup
        First CAS server
        Access Control
        JDBC Database Authorization
        JAAS User Authorization
        SSL Setup
        JSP Taglib
        JCas Client
        JLL - JAAS Login Library

Reference

        Release Notes
        JCas Configuration
        FAQ
        Help Forum

JCas Developers

        API Javadocs
        CAS Specification

Overview

JCas is delivered with a built-in CAS client. This client, fully written in Java, enables you both to request CAS authorizations by command-line and programmatically by integrating the Java class into your code.

Command Line Usage

The CAS client can be used as follows:
    java -cp jcas.jar cas.JCasClient <host> <port> <scheme> <user> <password> -ssl|-nossl
    					
All arguments are mandatory, so you cannot omit them. The last argument defines if the request should be made using SSL encryption (which should be switched on by default in CAS servers) or not.

A typical request would be:

    java -cp jcas.jar cas.JCasClient localhost 6688 MY_SCHEME MY_USER MY_PASSWORD -ssl
    					
This would usually result in an output like this:
    RC           = true
    ErrorCode    =
    ErrorMessage =
    Server       = JCas/1.0
    Cookie       = kjawezrb891254hijjiowqpoijqw732nfh21ofnvuz3mbaweto
    SSL          = true
    					
Attributes that do not apply for a specific response are left empty. In the above example, ErrorCode and ErrorMessage are blank because the request succeeded.

The client does not indicate success or failure by a return code. This will be made available in near future.

CAS client class

It is possible to integrate a CAS client into your own Java applications. JCasClient in package cas is written for that specific purpose. Its usage is very simple, after instantiation of an object, you set the various request properties (such as username, password, scheme, etc.) and then ask the object for the response values. Here is an excerpt from the main method of this class that actually implements the command line usage:
    JCasClient client = new JCasClient();
    
    client.setServer(args[0]);                          // Hostname of server
    client.setPort(Integer.parseInt(args[1]));          // Port of server
    client.setScheme(args[2]);                          // Name of scheme
    client.setUser(args[3]);                            // Username to authorize
    client.setPassword(args[4]);                        // Password of user
    client.setSSL(args[5].equals("-ssl"));              // SSL encryption or not
    client.setCloseConnection(true);                    // Do not reuse connection
    
    System.out.println("RC           = "+client.getReturnCode());
    System.out.println("ErrorCode    = "+client.getErrorCode());
    System.out.println("ErrorMessage = "+client.getErrorMessage());
    System.out.println("Server       = "+client.getServerName());
    System.out.println("Cookie       = "+client.getResponseCookie());
    System.out.println("SSL          = "+(client.isSSL() ? "enabled" : "disabled"));
    					
For further description of the class, please refer to the API documentation.