Package include.auth

Source Code of include.auth.DeAuthentication

package include.auth;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import village.webservice.VillageServiceInterfaceProxy;

public class DeAuthentication {

  /**
   * Function makes session identifier outdated.
   *
   * @param sid session identifier
   */
 
  public void logout (String sid){

    database.Session ses = null;
    String server;
    include.net.Server serv = new include.net.Server();
    Validation val = new Validation();

    System.out.println("[DeAuthentication] Executing funcion 'logout'. Parameters:");
    System.out.println("[DeAuthentication] sid: '" + sid + "'");
   
    server = sid.substring(sid.indexOf('@') + 1);
       
    if (serv.isMyName(server)){

      System.out.println("[DeAuthentication] Local execution.");
     
      if (val.validate(sid) != null) {
       
        System.out.println("[DeAuthentication] Session is valid");
       
        try {
          InitialContext ctx = new InitialContext();
          ses = (database.Session) ctx.lookup("ear3/CMPSession/local");
        } catch (NamingException e) {
          e.printStackTrace();
        }
     
        ses.remove(Integer.parseInt(sid.substring(0, sid.indexOf('@'))));
      } else
        System.out.println("[DeAuthentication] Session is invalid");
     
    } else {
      System.out.println("[DeAuthentication] Remote execution.");
      VillageServiceInterfaceProxy prox = new VillageServiceInterfaceProxy();
     
      village.webservice.VillageServiceInterface iface =
        prox.setEndpoint("http://"+server+prox.villagePort+prox.villageSuffix);


      try {
        iface.logout(sid);
      }
      catch(Exception cex){
        System.out.println("error");
        cex.printStackTrace();
      }
    }
    System.out.println("[DeAuthentication] End of function 'logout'.");
  }
}
TOP

Related Classes of include.auth.DeAuthentication

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.