SAS Life Science Analytics Framework and the clinical data products from SAS

Login authentication in your Java application against SDD users (API)

Reply
SAS Employee
Posts: 1

Login authentication in your Java application against SDD users (API)

So, you are writing a custom application (web or otherwise) that will involve talking to SAS Drug Development?  Likely you have a database that stores the users natively, or perhaps you talk to an active directory network authentication area.   But, if you are interested in authenticating your users right to SDD, as they login to your application, the SDD Java API can be used for this purpose. 

Your application will of course still need to know of users, i.e. a database/table in your application area, so that you can manage sessions and activity.    But if you tag your users (some or all) with a flag that indicates they are also a user of SAS Drug Development, you can do an authentication right at SDD as they login, and even carry around a session to SDD for fetching and setting information.

First, ensure your application has configuration to point to SDD, perhaps in a config file, or part of your application constants, say:

public class const_myapp {

:

    public static String url_SDDWebServices = "https://<your URL to SDD>:443/";

:

Next, you will of course need to include the latest API files in your classpath.   Important note:   The server and client (your web app) MUST match in terms of versions for the API jar files.  If the do not, you get errors trying to connect about a version mismatch

Next, during a login attempt to your application, you of course catch the user ID and password, and would try a login to SDD through web services.   Suppose you have a class, say, sdd_webservice, who does services and odds and ends for talking to SDD.    A member of this class could be an actual web service session to SDD (com.sas.hls.client.Session).   If you store an object of this class (after login) in your application's memory, you'll have an active connection to talk to SDD as your users navigates your application.   Remember to do a log out of the web service session at the appropriate time though!  (more on this later)

So,

sdd_webservice mySDDServices = new sdd_webservice();

mySDDServices.login(user, pass);

:

<some session variable> = mySDDServices.session;

--> now you can collect such a session variable in your application and use it to fetch SDD information, show to the user, etc.  

One way to do the login() method (assuming it returns a string of error text, or something like true/false for good session/bad session:

try {

    this.session = SessionFactory.newSession(new URL(const_myapp.url_SDDWebServices), user, pass);

       if ( !this.session.isValid()) {

            ret = "ERROR@: web service login failed";

        }

}

catch (Exception e) {

    String excp = e.toString();

    etc..

}

thiss.session= .. sets the object's local Session object with the working session to be used later in your application.

A logout method might then look like:

try {

    if (this.session != null)

        this.session.invalidate();

    }

catch (Exception e) {

    ret = "ERROR@ " + e;

}

.. such that:

mySDDServices.logout();

.. is called when a user logs out of your application, or at other appropriate time.

With that session hanging around in your application, now you can talk to SDD about user information, groups, roles, and all the API offers.  But that is for another discussion thread!

Ask a Question
Discussion stats
  • 0 replies
  • 357 views
  • 0 likes
  • 1 in conversation