KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > authentication > basic > DefaultAuthenticationManager


1 /*
2  ************************************************************************************
3  * Copyright (C) 2001-2006 Openbravo S.L.
4  * Licensed under the Apache Software License version 2.0
5  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6  * Unless required by applicable law or agreed to in writing, software distributed
7  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8  * CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations under the License.
10  ************************************************************************************
11  */

12
13 package org.openbravo.authentication.basic;
14
15 import java.io.IOException JavaDoc;
16 import org.openbravo.authentication.AuthenticationException;
17 import javax.servlet.ServletException JavaDoc;
18 import javax.servlet.http.HttpServlet JavaDoc;
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
21 import org.openbravo.authentication.AuthenticationManager;
22 import org.openbravo.base.HttpBaseUtils;
23 import org.openbravo.base.secureApp.VariablesHistory;
24 import org.openbravo.database.ConnectionProvider;
25
26 /**
27  *
28  * @author adrianromero
29  */

30 public class DefaultAuthenticationManager implements AuthenticationManager {
31
32   private ConnectionProvider conn = null;
33   private String JavaDoc strServletSinIdentificar = null;
34
35   /** Creates a new instance of DefaultAuthenticationManager */
36   public DefaultAuthenticationManager() {
37   }
38
39   public String JavaDoc authenticate(HttpServletRequest JavaDoc request) throws AuthenticationException, ServletException JavaDoc, IOException JavaDoc {
40
41     String JavaDoc sUserId = (String JavaDoc) request.getSession(true).getAttribute("#Authenticated_user");
42
43     if (sUserId == null || sUserId.equals("")) return null;
44     else return sUserId;
45   }
46
47   public void logout(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws ServletException JavaDoc, IOException JavaDoc {
48
49     request.getSession(true).removeAttribute("#Authenticated_user");
50     response.sendRedirect(HttpBaseUtils.getLocalAddress(request) + "/security/Menu.html");
51   }
52 }
53
Popular Tags