/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ws.access.user; import java.util.ArrayList; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; /** * * @author jonas */ @WebService() public class UserAccess { List users; public UserAccess() { users = new ArrayList(); } /** * Web service operation to add an User to the system */ @WebMethod(operationName = "addUser") public boolean addUser(@WebParam(name = "login") String login, @WebParam(name = "password") String password) { User user = new User(); user.setLogin(login); user.setPassword(password); if(!users.contains(user)) { //if the user is not already on the list users.add(user); // add the user and return true to say everything has gone OK return true; } else { // user is already on the list. return false; // Return false to say no one has been added to the list } } /** * Web service operation to check user login */ @WebMethod(operationName = "checkUser") public boolean checkUser(@WebParam(name = "login") String login, @WebParam(name = "password") String password) { User user = new User(); user.setLogin(login); user.setPassword(password); if(users.contains(user)) { //if the user is on the list return true; // let it login, return OK } else { // user isn't on the list return false; // return 'there is a problem here' } } }