/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.plugin.deskmanager.command.security;

import org.geomajas.command.Command;
import org.geomajas.plugin.deskmanager.command.security.dto.AuthenticateUserRequest;
import org.geomajas.plugin.deskmanager.command.security.dto.AuthenticateUserResponse;
import org.geomajas.plugin.deskmanager.security.LoginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Command that will retrieve the profiles of a user for a specific geodesk.
 *
 * @author Jan Venstermans
 */
@Component(AuthenticateUserRequest.COMMAND)
public class AuthenticateUserCommand implements Command<AuthenticateUserRequest, AuthenticateUserResponse> {

	private final Logger log = LoggerFactory.getLogger(AuthenticateUserCommand.class);

	@Autowired
	private LoginService loginService;

	public AuthenticateUserResponse getEmptyCommandResponse() {
		return new AuthenticateUserResponse();
	}

	public void execute(AuthenticateUserRequest request, AuthenticateUserResponse response) throws Exception {
		try {
			String token = loginService.checkLogin(request.getUserName(), request.getPassword());
			response.setSecurityToken(token);
			log.info("Autentication Request for " + request.getUserName() + " successfully executed.");
		} catch (Exception ex) {
			log.error("Autentication exception for username " + request.getUserName(), ex);
			throw ex;
		}
	}
}
@@ -741,16 +741,72 @@
 ervice;%0A
+import org.geomajas.security.GeomajasSecurityException;%0A
 import o
@@ -1824,16 +1824,32 @@
  catch (
+GeomajasSecurity
 Exceptio
@@ -1946,17 +1946,71 @@
 %0A%09%09%09
-throw ex;
+// return an empty response, in complyance with static security
 %0A%09%09%7D

make deskmanager security respond as static security: no exception