Remove openid
This commit is contained in:
@@ -45,9 +45,6 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||
@Value("${security.type}")
|
||||
private String securityType;
|
||||
|
||||
@Value("${security.openid.enabled}")
|
||||
private Boolean openIdEnabled;
|
||||
|
||||
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
||||
|
||||
request.setAttribute("google.analytics.enabled", analyticsEnabled);
|
||||
@@ -55,7 +52,6 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||
request.setAttribute("google.ads.enabled", adsEnabled);
|
||||
request.setAttribute("site.homepage", siteHomepage);
|
||||
request.setAttribute("security.type", securityType);
|
||||
request.setAttribute("security.openid.enabled", openIdEnabled);
|
||||
|
||||
|
||||
// If the property could not be resolved, try to infer one from the request...
|
||||
|
@@ -19,24 +19,16 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.openid.OpenIDAttribute;
|
||||
import org.springframework.security.openid.OpenIDAuthenticationToken;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserDetailsService
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService, org.springframework.security.core.userdetails.AuthenticationUserDetailsService<OpenIDAuthenticationToken> {
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService{
|
||||
private UserService userService;
|
||||
private String adminUser;
|
||||
|
||||
@@ -51,76 +43,76 @@ public class UserDetailsService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public UserDetails loadUserDetails(@NotNull OpenIDAuthenticationToken token) throws UsernameNotFoundException {
|
||||
// @Override
|
||||
// @NotNull
|
||||
// public UserDetails loadUserDetails(@NotNull OpenIDAuthenticationToken token) throws UsernameNotFoundException {
|
||||
//
|
||||
// final User tUser = buildUserFromToken(token);
|
||||
// final User dbUser = userService.getUserBy(tUser.getEmail());
|
||||
//
|
||||
// final User result;
|
||||
// if (dbUser != null) {
|
||||
// if (!token.getIdentityUrl().equals(dbUser.getAuthenticatorUri())) {
|
||||
// throw new IllegalStateException("Identity url for this user can not change:" + token.getIdentityUrl());
|
||||
// }
|
||||
// result = dbUser;
|
||||
// } else {
|
||||
// try {
|
||||
// tUser.setAuthenticationType(AuthenticationType.OPENID);
|
||||
// tUser.setAuthenticatorUri(token.getIdentityUrl());
|
||||
//
|
||||
// result = userService.createUser(tUser, false, false);
|
||||
// } catch (WiseMappingException e) {
|
||||
// throw new IllegalStateException(e);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return new UserDetails(result, isAdmin(result.getEmail()));
|
||||
// }
|
||||
|
||||
final User tUser = buildUserFromToken(token);
|
||||
final User dbUser = userService.getUserBy(tUser.getEmail());
|
||||
|
||||
final User result;
|
||||
if (dbUser != null) {
|
||||
if (!token.getIdentityUrl().equals(dbUser.getAuthenticatorUri())) {
|
||||
throw new IllegalStateException("Identity url for this user can not change:" + token.getIdentityUrl());
|
||||
}
|
||||
result = dbUser;
|
||||
} else {
|
||||
try {
|
||||
tUser.setAuthenticationType(AuthenticationType.OPENID);
|
||||
tUser.setAuthenticatorUri(token.getIdentityUrl());
|
||||
|
||||
result = userService.createUser(tUser, false, false);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
}
|
||||
return new UserDetails(result, isAdmin(result.getEmail()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private User buildUserFromToken(@NotNull OpenIDAuthenticationToken token) {
|
||||
final User result = new User();
|
||||
|
||||
String lastName = null;
|
||||
String firstName = null;
|
||||
String email = null;
|
||||
String fullName = null;
|
||||
|
||||
final List<OpenIDAttribute> attributes = token.getAttributes();
|
||||
for (OpenIDAttribute attribute : attributes) {
|
||||
if (attribute.getName().equals("email")) {
|
||||
email = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("firstname")) {
|
||||
firstName = attribute.getValues().get(0);
|
||||
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("lastname")) {
|
||||
lastName = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("fullname")) {
|
||||
fullName = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
}
|
||||
if (lastName == null || firstName == null) {
|
||||
result.setFirstname(fullName);
|
||||
result.setLastname("");
|
||||
} else {
|
||||
result.setLastname(lastName);
|
||||
result.setFirstname(firstName);
|
||||
}
|
||||
result.setEmail(email);
|
||||
result.setPassword("");
|
||||
|
||||
final Calendar now = Calendar.getInstance();
|
||||
result.setActivationDate(now);
|
||||
return result;
|
||||
}
|
||||
// @NotNull
|
||||
// private User buildUserFromToken(@NotNull OpenIDAuthenticationToken token) {
|
||||
// final User result = new User();
|
||||
//
|
||||
// String lastName = null;
|
||||
// String firstName = null;
|
||||
// String email = null;
|
||||
// String fullName = null;
|
||||
//
|
||||
// final List<OpenIDAttribute> attributes = token.getAttributes();
|
||||
// for (OpenIDAttribute attribute : attributes) {
|
||||
// if (attribute.getName().equals("email")) {
|
||||
// email = attribute.getValues().get(0);
|
||||
// }
|
||||
//
|
||||
// if (attribute.getName().equals("firstname")) {
|
||||
// firstName = attribute.getValues().get(0);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (attribute.getName().equals("lastname")) {
|
||||
// lastName = attribute.getValues().get(0);
|
||||
// }
|
||||
//
|
||||
// if (attribute.getName().equals("fullname")) {
|
||||
// fullName = attribute.getValues().get(0);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (lastName == null || firstName == null) {
|
||||
// result.setFirstname(fullName);
|
||||
// result.setLastname("");
|
||||
// } else {
|
||||
// result.setLastname(lastName);
|
||||
// result.setFirstname(firstName);
|
||||
// }
|
||||
// result.setEmail(email);
|
||||
// result.setPassword("");
|
||||
//
|
||||
// final Calendar now = Calendar.getInstance();
|
||||
// result.setActivationDate(now);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private boolean isAdmin(@Nullable String email) {
|
||||
return email != null && adminUser != null && email.trim().endsWith(adminUser);
|
||||
|
@@ -45,16 +45,16 @@ public class LoginController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loginopenid", method = RequestMethod.GET)
|
||||
protected ModelAndView showLoginOpenIdPage() {
|
||||
final User user = Utils.getUser(false);
|
||||
ModelAndView result;
|
||||
if (user != null) {
|
||||
result = new ModelAndView("forward:/c/maps/");
|
||||
} else {
|
||||
result = new ModelAndView("loginopenid");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// @RequestMapping(value = "loginopenid", method = RequestMethod.GET)
|
||||
// protected ModelAndView showLoginOpenIdPage() {
|
||||
// final User user = Utils.getUser(false);
|
||||
// ModelAndView result;
|
||||
// if (user != null) {
|
||||
// result = new ModelAndView("forward:/c/maps/");
|
||||
// } else {
|
||||
// result = new ModelAndView("loginopenid");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@@ -48,11 +48,6 @@ public class PublicPagesController {
|
||||
return "crew";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "GCFInstall")
|
||||
public String showGCFInstallationPage() {
|
||||
return "GCFInstall";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "keyboard")
|
||||
public String newsPage() {
|
||||
return "keyboard";
|
||||
|
Reference in New Issue
Block a user