Pokud je nastaveno přihlašování proti AD nebo LDAP serveru, tak zmizí
nabídka "Změnit heslo". closes #174
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.security;
|
||||
|
||||
public enum AuthMethod {
|
||||
|
||||
DATABASE,
|
||||
LDAP,
|
||||
AD
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public class AuthPopulator implements LdapAuthoritiesPopulator {
|
||||
public AuthPopulator(UserService userService, RoleService roleService) {
|
||||
this.userService = userService;
|
||||
this.roleService = roleService;
|
||||
userService.setAuthMethod(AuthMethod.LDAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package info.bukova.isspst.services.users;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.security.AuthMethod;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -33,6 +34,7 @@ public class AdUserCtxMapper implements UserDetailsContextMapper {
|
||||
public AdUserCtxMapper(UserService userService, RoleService roleService) {
|
||||
this.userService = userService;
|
||||
this.roleService = roleService;
|
||||
userService.setAuthMethod(AuthMethod.AD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.data.UserSettingsData;
|
||||
import info.bukova.isspst.security.AuthMethod;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@@ -24,4 +25,7 @@ public interface UserService extends UserDetailsService, Service<User> {
|
||||
public UserSettingsData getUserSettings(User user);
|
||||
public UserSettingsData getUserSettings();
|
||||
public void setUserSettings(UserSettingsData settings);
|
||||
public void setAuthMethod(AuthMethod method);
|
||||
public AuthMethod getAuthMethod();
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.data.UserSettingsData;
|
||||
import info.bukova.isspst.security.AuthMethod;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
import info.bukova.isspst.services.StringXmlMarshaller;
|
||||
//import info.bukova.isspst.services.LazyLoader;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -34,9 +36,11 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
private StringXmlMarshaller<UserSettingsData> marshaller;
|
||||
private AuthMethod authMethod;
|
||||
|
||||
public UserServiceImpl(Marshaller marshaller, Unmarshaller unmarshaller) {
|
||||
this.marshaller = new StringXmlMarshaller<UserSettingsData>(marshaller, unmarshaller, UserSettingsData.class);
|
||||
authMethod = AuthMethod.DATABASE;
|
||||
}
|
||||
|
||||
public void setEncoder(PasswordEncoder encoder) {
|
||||
@@ -202,4 +206,14 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
return Constants.PERM_EDIT_OWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthMethod(AuthMethod method) {
|
||||
this.authMethod = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthMethod getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package info.bukova.isspst.ui;
|
||||
|
||||
import info.bukova.isspst.security.AuthMethod;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
public class MainMenu
|
||||
@@ -10,6 +14,8 @@ public class MainMenu
|
||||
private String contextPath;
|
||||
|
||||
private String moduleUrl;
|
||||
@WireVariable
|
||||
private UserService userService;
|
||||
|
||||
@Init
|
||||
public void init()
|
||||
@@ -55,4 +61,8 @@ public class MainMenu
|
||||
Window window = (Window) Executions.createComponents("/settings/userSettings.zul", null, null);
|
||||
window.doModal();
|
||||
}
|
||||
|
||||
public boolean isCanChangePassword() {
|
||||
return userService.getAuthMethod() == AuthMethod.DATABASE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,8 @@
|
||||
<menuitem
|
||||
image=""
|
||||
label="${labels.ChangePassword}…"
|
||||
onClick="@command('passwd')" />
|
||||
onClick="@command('passwd')"
|
||||
visible="@load(vm.canChangePassword)" />
|
||||
<menuitem
|
||||
image="/img/unlock-016.png"
|
||||
label="${labels.Logout}"
|
||||
|
||||
Reference in New Issue
Block a user