home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / login.js < prev    next >
Encoding:
Text File  |  2004-07-12  |  2.1 KB  |  76 lines

  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *     http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. // Step 1 -- Retrieve helper "beans" from the BSF framework
  17.  
  18. request      = bsf.lookupBean( "request" )
  19. logger       = bsf.lookupBean( "logger" )
  20. actionMap    = bsf.lookupBean( "actionMap" )
  21.  
  22. // Step 2 -- Perform the action
  23.  
  24. logger.debug( "START login.js" )
  25.  
  26. // Retrieve things from the request
  27. // NOTE: they are all of type java.lang.String
  28.  
  29. uwid     = request.getParameter( "uwid" )
  30. password = request.getParameter( "password" )
  31.  
  32. logger.debug( "Raw" )
  33. logger.debug( "  uwid     [" + uwid + "]" )
  34. //logger.debug( "  password [" + password + "]" )
  35.  
  36. // Hack since either the guy we stole the code from or
  37. // Bruce has made an implementation error
  38.  
  39. password = password + "\0\0\0\0\0\0\0\0\0"
  40.  
  41. //logger.debug( "Cooked" )
  42. //logger.debug( "  password [" + password + "]" )
  43.  
  44. try
  45. {
  46.  
  47.     session = request.getSession(true)
  48.  
  49.     radius = new Packages.RadiusClient( "engine.uwaterloo.ca","1812","7sjU2xbHa31s2" )
  50.     result = radius.Authenticate( uwid, password )
  51.  
  52.     if ( radius.ACCESS_ACCEPT == result )
  53.     {
  54.         logger.debug( "Authentication succeeded" )
  55.         
  56.         // Get (and optionally create) and populate the session
  57.         
  58.         session.setAttribute( "uwid", uwid )
  59.         
  60.         actionMap.put( "scriptaction-continue", "" )    
  61.     }
  62.     else
  63.     {
  64.         logger.debug( "Authentication failed" )
  65.         session.setAttribute( "results", "<FAILURE>Incorrect User ID or Password</FAILURE>" )
  66.     }
  67.  
  68. }
  69. catch( ex )
  70. {
  71.     logger.debug( "Caught Exception" )
  72.     logger.debug( "  " + ex )
  73. }
  74.  
  75. logger.debug( "END login.js" )
  76.