Revision a84a1660
Added by Andreas Kohlbecker almost 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/LoginManager.java | ||
---|---|---|
13 | 13 |
import java.util.Observable; |
14 | 14 |
|
15 | 15 |
import org.eclipse.core.runtime.IProgressMonitor; |
16 |
import org.eclipse.ui.IEditorPart; |
|
16 | 17 |
import org.eclipse.ui.IMemento; |
18 |
import org.eclipse.ui.IWorkbenchPage; |
|
19 |
import org.eclipse.ui.IWorkbenchPart; |
|
20 |
import org.eclipse.ui.IWorkbenchWindow; |
|
21 |
import org.eclipse.ui.editors.text.EditorsUI; |
|
22 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
17 | 23 |
import org.springframework.security.authentication.BadCredentialsException; |
18 | 24 |
import org.springframework.security.authentication.LockedException; |
19 | 25 |
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
... | ... | |
46 | 52 |
* |
47 | 53 |
* @param token a {@link org.springframework.security.authentication.UsernamePasswordAuthenticationToken} object. |
48 | 54 |
*/ |
49 |
public boolean authenticate(String username, String password){ |
|
55 |
public boolean authenticate(String username, String password){ |
|
56 |
|
|
57 |
// close all open editors, this will close all open conversations |
|
58 |
// otherwise the users granted authorities might not be up to date |
|
59 |
if(!StoreUtil.closeAll()){ |
|
60 |
return false; |
|
61 |
} |
|
62 |
|
|
63 |
|
|
50 | 64 |
try{ |
51 | 65 |
getConversationHolder().bind(); |
52 |
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password); |
|
53 | 66 |
|
54 | 67 |
SecurityContextHolder.clearContext(); |
55 |
Authentication authentication = CdmStore.getAuthenticationManager().authenticate(token); |
|
56 |
SecurityContextHolder.getContext().setAuthentication(authentication); |
|
68 |
|
|
69 |
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password); |
|
70 |
Authentication authentication = CdmStore.getAuthenticationManager().authenticate(token); |
|
71 |
|
|
72 |
SecurityContextHolder.getContext().setAuthentication(authentication); |
|
73 |
|
|
57 | 74 |
this.setChanged(); |
58 | 75 |
this.notifyObservers(); |
59 | 76 |
return true; |
Also available in: Unified diff
closing all editors when switching to new user