01: /*
02: * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.wso2.esb.services;
18:
19: import org.apache.axis2.AxisFault;
20: import org.apache.axis2.context.MessageContext;
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.wso2.esb.ServiceBusManager;
24:
25: /*
26: * This is a POJO for login admin service
27: */
28:
29: public class LoginAdmin extends AbstractESBAdmin {
30:
31: private static final Log log = LogFactory.getLog(LoginAdmin.class);
32:
33: public boolean login(String username, String password)
34: throws AxisFault {
35:
36: log.debug("Atempting login for user : " + username);
37: if ((username == null) || (password == null)
38: || username.trim().equals("")
39: || password.trim().equals("")) {
40: MessageContext.getCurrentMessageContext()
41: .getServiceGroupContext().setProperty(LOGGED,
42: "false");
43:
44: return false;
45: }
46: // temprary lets allow everyone to acess FixMe Via server.xml or via Database
47:
48: ServiceBusManager manager = ServiceBusManager.getInstance();
49: boolean logged = manager.authenticate(username, password);
50:
51: if (logged) {
52: MessageContext.getCurrentMessageContext()
53: .getServiceGroupContext().setProperty(LOGGED,
54: "true");
55: log.info("User : " + username + " logged into the system");
56: return true;
57: } else {
58: MessageContext.getCurrentMessageContext()
59: .getServiceGroupContext().setProperty(LOGGED,
60: "false");
61: log.info("User : " + username
62: + " was denied access into the system");
63: return false;
64: }
65:
66: }
67:
68: public void logout() throws AxisFault {
69: MessageContext.getCurrentMessageContext()
70: .getServiceGroupContext().setProperty(LOGGED, "false");
71: log.info("User logged out of the system");
72: }
73:
74: /*
75: TODO set the registration of the WSO2 ESB properly
76: TODO we need a registry or database to hold this.
77: */
78:
79: public boolean isServerRegistered() throws AxisFault {
80: return true;
81: }
82:
83: }
|