/*

Copyright (C) 2015 - Gareth Edwards / Rapid Information Systems

gareth.edwards@rapid-is.co.uk


This file is part of the Rapid Application Platform

Rapid is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as 
published by the Free Software Foundation, either version 3 of the 
License, or (at your option) any later version. The terms require you 
to include the original copyright, and the license notice in all redistributions.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
in a file named "COPYING".  If not, see <http://www.gnu.org/licenses/>.

*/

package com.rapid.security;

import java.lang.reflect.InvocationTargetException;

import javax.servlet.ServletContext;

import com.rapid.core.Application;
import com.rapid.server.RapidRequest;

public class FormSecurityAdapter extends RapidSecurityAdapter {
	
	// private instance methods
	protected User _formUser;

	// constructor
	
	public FormSecurityAdapter(ServletContext servletContext, Application application) throws SecurityException,IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
		// call the super constructor
		super(servletContext, application);
		// make the form user which all anonymous users will use
		_formUser = new User("public","Public form user","");
	}
	
	// overrides
	
	@Override
	public User getUser(RapidRequest rapidRequest) throws SecurityAdapaterException {
		// first try and get the user with the super method
		User user = super.getUser(rapidRequest);
		// if that didn'y find anyone set to an anonymous user
		if (user == null) user = _formUser;
		// return
		return user;
	}

	@Override
	public boolean checkUserPassword(RapidRequest rapidRequest,	String userName, String password) throws SecurityAdapaterException {
		// everyone is allowed
		return true;
	}
						
}
@@ -18,9 +18,9 @@
  201
-5
+7
  - G
@@ -1148,66 +1148,8 @@
 er %7B
-%0A%09%0A%09// private instance methods%0A%09protected User _formUser;
 %0A%0A%09/
@@ -1496,123 +1496,8 @@
 n);%0A
-%09%09// make the form user which all anonymous users will use%0A%09%09_formUser = new User(%22public%22,%22Public form user%22,%22%22);%0A
 %09%7D%0A%09
@@ -1722,17 +1722,17 @@
 at didn'
-y
+t
  find an
@@ -1748,61 +1748,151 @@
 to a
-n anonymous user%0A%09%09if (user == null) user = _
+ password-less user from the session / connection adapter%0A%09%09if (user == null) user = new User(rapidRequest.getUserName(),%22Public 
 form
-U
+ u
 ser
+%22,%22%22)
 ;%0A%09%09

Update to FormSecurityAdapter to use userName from Rapid request / Connection adapter