home *** CD-ROM | disk | FTP | other *** search
/ ftp.rsa.com / 2014.05.ftp.rsa.com.tar / ftp.rsa.com / pub / partner_engineering / ClearTrust / Verity / ticket.jnc < prev    next >
Text File  |  2014-05-02  |  3KB  |  88 lines

  1. <%
  2. String serverSpec = null;
  3. if (serverSpec == null || serverSpec.equals("")){
  4.     serverSpec = (String)System.getProperty("VERITY_K2_HOSTPORT");
  5.  
  6. // <Bruce Bordelon>
  7. //  also check the context configuration for the VERITY_K2_HOSTPORT property
  8.     if (serverSpec == null || serverSpec.equals("")) {
  9.         serverSpec = (String)getServletConfig().getServletContext().getInitParameter("VERITY_K2_HOSTPORT");
  10. // </Bruce Bordelon>
  11.     }
  12.     if (serverSpec == null){
  13. %>
  14.         <i><FONT color="red"><b>Error: Failed to obtain serverspec.</i></b></head>
  15.         <body><FONT color="red"><br>Unable to determine the serverSpec from the
  16.         environment variable VERITY_K2_HOSTPORT.<br> Please set this env variable
  17.         to point to the proper K2 Broker/Server serverspec.
  18.         </body>
  19.         </html>
  20.  
  21. <%
  22.     return;
  23.     }
  24.  
  25.     String errorStr = null;
  26.  
  27.     
  28.     String username, passwd, domain, ticket;
  29.     HttpSession sess = request.getSession(true);
  30.     String logout = null;
  31.     {
  32.         try {
  33.             VSearch s0 = new VSearch();
  34.             s0.setServerSpec(serverSpec);
  35.                         
  36.             String userParam=null;
  37.             String ct_user = request.getHeader("HTTP_CT_REMOTE_USER");
  38.             s0.setK2UserName(ct_user);
  39.             userParam = "HTTP_CT_REMOTE_USER;="+ct_user;
  40.             s0.addUserParamCredential(userParam);
  41.             sess.putValue("user",ct_user);
  42.                                             
  43.             // I18N code: Set the charmap for the VSearch object. This will cause VDK
  44.             // to input and output data in this charset.
  45.             s0.setCharMap("1252");     
  46.             
  47.             ticket = s0.k2Login();
  48.                 
  49.             // Put the ticket as session variable
  50.             sess.setAttribute("ticket", ticket);
  51.             sess.setAttribute("user",ct_user);
  52.             
  53.             response.addCookie(new Cookie("SAMPLE_TEMPLATES_LOGGEDON","LoggedOn")); // set the ticket cookie
  54.  
  55.             // successfully obtained the ticket. so close the window            
  56.             
  57.         } catch (Exception e){
  58.             String errString = e.toString();
  59.             System.out.println("Got an exception" + errString);
  60.             if ((errString.indexOf("connection refused") >= 0) ||
  61.                 (errString.indexOf("Connection refused") >= 0) ||
  62.                 (errString.indexOf("Connection Refused") >= 0)) {
  63.                 errorStr = "<b>Login error: unable to connect to K2Server/Broker.</b>";
  64.             } else if (errString.indexOf("-303") >= 0) {
  65.                 errorStr = "<b>Incorrect username and password</b>";
  66.             } else if (errString.indexOf("-304") >= 0) {
  67.                 errorStr = "<b>Login error: No user credentials available (-304)<b>";
  68.             } else if (errString.indexOf("-305") >= 0) {
  69.                 errorStr = "<b> Login error: call to K2Ticket failed (-305)<b>";
  70.             } else if (errString.indexOf("-306") >= 0) {
  71.                 errorStr = "<b>Login error: K2Ticket server is not available (-306)<b>";
  72.             } else if (errString.indexOf("-1012") >= 0) {
  73.                 errorStr = "<b>Login error: -1012</b>";
  74.             } else if (errString.indexOf("-314") >= 0) {
  75.                 errorStr = "<b>Ticket error: ticket has expired (-314)<b>";
  76.             } else if (errString.indexOf("-80") >= 0) {
  77.                 errorStr = "<b>Ticket error: ticket is invalid (-80)<b>";
  78.             } else if (errString.indexOf("-14") >= 0) {
  79.                 errorStr = "<b>Ticket error: ticket is null (-14)<b>";
  80.             } else {
  81.                 errorStr =  errString ;
  82.             }        
  83.         }
  84.     
  85.     }
  86. %>
  87.  
  88.