Revision 707b6237
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/LoginManager.java | ||
---|---|---|
39 | 39 |
* |
40 | 40 |
* @param token a {@link org.springframework.security.authentication.UsernamePasswordAuthenticationToken} object. |
41 | 41 |
*/ |
42 |
public void authenticate(String username, String password){
|
|
42 |
public boolean authenticate(String username, String password){
|
|
43 | 43 |
try{ |
44 | 44 |
getConversationHolder().bind(); |
45 | 45 |
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password); |
... | ... | |
47 | 47 |
SecurityContextHolder.clearContext(); |
48 | 48 |
Authentication authentication = CdmStore.getAuthenticationManager().authenticate(token); |
49 | 49 |
SecurityContextHolder.getContext().setAuthentication(authentication); |
50 |
this.setChanged(); |
|
51 |
this.notifyObservers(); |
|
52 |
return true; |
|
50 | 53 |
} |
51 | 54 |
catch(BadCredentialsException e){ |
52 | 55 |
StoreUtil.warningDialog("Could not authenticate", this, "Could not authenticate. Reason: Bad Credentials."); |
... | ... | |
57 | 60 |
catch(IllegalArgumentException e){ |
58 | 61 |
StoreUtil.warningDialog("Could not authenticate", this, "Could not authenticate. Reason: Username and/or Password empty."); |
59 | 62 |
} |
60 |
finally{ |
|
61 |
this.setChanged(); |
|
62 |
this.notifyObservers(); |
|
63 |
} |
|
63 |
return false; |
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
/** |
... | ... | |
100 | 100 |
} |
101 | 101 |
return conversation; |
102 | 102 |
} |
103 |
|
|
104 |
/** |
|
105 |
* Whether the current user has the role admin |
|
106 |
* |
|
107 |
* @return |
|
108 |
*/ |
|
109 |
public boolean isAdmin() { |
|
110 |
// FIXME until we have rights implemented properly we do this |
|
111 |
// by a simple string check. This has to change |
|
112 |
|
|
113 |
return "admin".equals(getAuthenticatedUser().getUsername()); |
|
114 |
} |
|
103 | 115 |
} |
Also available in: Unified diff
Merged with trunk