Finish OpenId implementation.

This commit is contained in:
Paulo Gustavo Veiga
2013-03-17 23:17:55 -03:00
parent 94356a5773
commit 9b21c77485
16 changed files with 80 additions and 47 deletions

View File

@@ -20,7 +20,7 @@ package com.wisemapping.security;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationSchema;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.User;
import com.wisemapping.service.UserService;
import org.jetbrains.annotations.NotNull;
@@ -60,10 +60,15 @@ public class UserDetailsService
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.setAuthenticationSchema(AuthenticationSchema.OPENID);
tUser.setAuthenticationType(AuthenticationType.OPENID);
tUser.setAuthenticatorUri(token.getIdentityUrl());
result = userService.createUser(tUser, false, false);
} catch (WiseMappingException e) {
throw new IllegalStateException(e);

View File

@@ -2,7 +2,7 @@ package com.wisemapping.security.ldap;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.AuthenticationSchema;
import com.wisemapping.model.AuthenticationType;
import com.wisemapping.model.User;
import com.wisemapping.security.UserDetails;
import com.wisemapping.service.UserService;
@@ -65,7 +65,7 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
user.setActivationDate(now);
try {
user.setAuthenticationSchema(AuthenticationSchema.LDAP);
user.setAuthenticationType(AuthenticationType.LDAP);
user = userService.createUser(user, false, false);
} catch (WiseMappingException e) {
throw new IllegalStateException(e);