import java.util.Observable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.handlers.HandlerUtil;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
*
* @param token a {@link org.springframework.security.authentication.UsernamePasswordAuthenticationToken} object.
*/
- public boolean authenticate(String username, String password){
+ public boolean authenticate(String username, String password){
+
+ // close all open editors, this will close all open conversations
+ // otherwise the users granted authorities might not be up to date
+ if(!StoreUtil.closeAll()){
+ return false;
+ }
+
+
try{
getConversationHolder().bind();
- UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
SecurityContextHolder.clearContext();
- Authentication authentication = CdmStore.getAuthenticationManager().authenticate(token);
- SecurityContextHolder.getContext().setAuthentication(authentication);
+
+ UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
+ Authentication authentication = CdmStore.getAuthenticationManager().authenticate(token);
+
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+
this.setChanged();
this.notifyObservers();
return true;