Merge pull request #498 from stianst/master
Rename loginName to username
This commit is contained in:
commit
0647590170
40 changed files with 89 additions and 89 deletions
|
@ -70,7 +70,7 @@ public class AuthenticationProviderManager {
|
|||
AuthenticationLinkModel authLink = user.getAuthenticationLink();
|
||||
if (authLink == null) {
|
||||
// User not yet linked with any authenticationProvider. Find provider with biggest priority where he is and link
|
||||
AuthUser authUser = getUser(user.getLoginName());
|
||||
AuthUser authUser = getUser(user.getUsername());
|
||||
authLink = new AuthenticationLinkModel(authUser.getProviderName(), authUser.getId());
|
||||
user.setAuthenticationLink(authLink);
|
||||
logger.infof("User '%s' linked with provider '%s'", authUser.getUsername(), authUser.getProviderName());
|
||||
|
@ -85,10 +85,10 @@ public class AuthenticationProviderManager {
|
|||
}
|
||||
|
||||
try {
|
||||
checkCorrectAuthLink(delegate, providerModel, authLink, user.getLoginName());
|
||||
checkCorrectAuthLink(delegate, providerModel, authLink, user.getUsername());
|
||||
|
||||
AuthProviderStatus currentResult = delegate.validatePassword(realm, providerModel.getConfig(), user.getLoginName(), password);
|
||||
logger.debugf("Authentication provider '%s' finished with '%s' for authentication of '%s'", delegate.getName(), currentResult.toString(), user.getLoginName());
|
||||
AuthProviderStatus currentResult = delegate.validatePassword(realm, providerModel.getConfig(), user.getUsername(), password);
|
||||
logger.debugf("Authentication provider '%s' finished with '%s' for authentication of '%s'", delegate.getName(), currentResult.toString(), user.getUsername());
|
||||
return currentResult;
|
||||
} catch (AuthenticationProviderException ape) {
|
||||
logger.warn(ape.getMessage(), ape);
|
||||
|
@ -105,7 +105,7 @@ public class AuthenticationProviderManager {
|
|||
if (providerModel.isPasswordUpdateSupported()) {
|
||||
AuthenticationProvider delegate = getProvider(providerModel.getProviderName());
|
||||
if (delegate != null) {
|
||||
AuthUser authUser = delegate.getUser(realm, providerModel.getConfig(), user.getLoginName());
|
||||
AuthUser authUser = delegate.getUser(realm, providerModel.getConfig(), user.getUsername());
|
||||
if (authUser != null) {
|
||||
// Linking existing user supported just for "model" provider. In other cases throw exception
|
||||
if (providerModel.getProviderName().equals(AuthenticationProviderModel.DEFAULT_PROVIDER.getProviderName())) {
|
||||
|
@ -120,7 +120,7 @@ public class AuthenticationProviderManager {
|
|||
String userIdInProvider = delegate.registerUser(realm, providerModel.getConfig(), user);
|
||||
authLink = new AuthenticationLinkModel(providerModel.getProviderName(), userIdInProvider);
|
||||
user.setAuthenticationLink(authLink);
|
||||
logger.infof("User '%s' registered in provider '%s' and linked", user.getLoginName(), providerModel.getProviderName());
|
||||
logger.infof("User '%s' registered in provider '%s' and linked", user.getUsername(), providerModel.getProviderName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class AuthenticationProviderManager {
|
|||
}
|
||||
|
||||
if (authLink == null) {
|
||||
logger.warnf("No providers found where password update is supported for user '%s'", user.getLoginName());
|
||||
logger.warnf("No providers found where password update is supported for user '%s'", user.getUsername());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class AuthenticationProviderManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
String username = user.getLoginName();
|
||||
String username = user.getUsername();
|
||||
|
||||
// Update just if password update is supported
|
||||
if (providerModel.isPasswordUpdateSupported()) {
|
||||
|
@ -152,7 +152,7 @@ public class AuthenticationProviderManager {
|
|||
|
||||
checkCorrectAuthLink(delegate, providerModel, authLink, username);
|
||||
|
||||
if (delegate.updateCredential(realm,providerModel.getConfig(), user.getLoginName(), password)) {
|
||||
if (delegate.updateCredential(realm,providerModel.getConfig(), user.getUsername(), password)) {
|
||||
logger.debugf("Updated password in authentication provider '%s' for user '%s'", providerName, username);
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,7 @@ public abstract class AbstractModelAuthenticationProvider implements Authenticat
|
|||
@Override
|
||||
public String registerUser(RealmModel currentRealm, Map<String, String> config, UserModel user) throws AuthenticationProviderException {
|
||||
RealmModel realm = getRealm(currentRealm, config);
|
||||
UserModel newUser = realm.addUser(user.getLoginName());
|
||||
UserModel newUser = realm.addUser(user.getUsername());
|
||||
newUser.setFirstName(user.getFirstName());
|
||||
newUser.setLastName(user.getLastName());
|
||||
newUser.setEmail(user.getEmail());
|
||||
|
@ -80,7 +80,7 @@ public abstract class AbstractModelAuthenticationProvider implements Authenticat
|
|||
protected abstract RealmModel getRealm(RealmModel currentRealm, Map<String, String> config) throws AuthenticationProviderException;
|
||||
|
||||
protected AuthUser createAuthenticatedUserInstance(UserModel user) {
|
||||
return new AuthUser(user.getId(), user.getLoginName(), getName())
|
||||
return new AuthUser(user.getId(), user.getUsername(), getName())
|
||||
.setName(user.getFirstName(), user.getLastName())
|
||||
.setEmail(user.getEmail());
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class PicketlinkAuthenticationProvider implements AuthenticationProvider
|
|||
IdentityManager identityManager = getIdentityManager(realm);
|
||||
|
||||
try {
|
||||
User picketlinkUser = new User(user.getLoginName());
|
||||
User picketlinkUser = new User(user.getUsername());
|
||||
picketlinkUser.setFirstName(user.getFirstName());
|
||||
picketlinkUser.setLastName(user.getLastName());
|
||||
picketlinkUser.setEmail(user.getEmail());
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PropertiesAuthenticationProvider implements AuthenticationProvider
|
|||
@Override
|
||||
public String registerUser(RealmModel realm, Map<String, String> configuration, UserModel user) throws AuthenticationProviderException {
|
||||
// Registration ignored
|
||||
return user.getLoginName();
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -211,7 +211,7 @@ public class ModelExporter {
|
|||
|
||||
this.propertiesManager.setBasicPropertiesFromModel(userModel, userEntity);
|
||||
|
||||
userEntity.setLoginName(userModel.getLoginName());
|
||||
userEntity.setUsername(userModel.getUsername());
|
||||
userEntity.setRealmId(realm.getId());
|
||||
|
||||
// authentication links
|
||||
|
|
|
@ -243,7 +243,7 @@ public class ModelImporter {
|
|||
List<UserEntity> users = this.importReader.readEntities(fileName, UserEntity.class);
|
||||
for (UserEntity userEntity : users) {
|
||||
RealmModel realm = session.getRealm(userEntity.getRealmId());
|
||||
UserModel user = realm.addUser(userEntity.getId(), userEntity.getLoginName());
|
||||
UserModel user = realm.addUser(userEntity.getId(), userEntity.getUsername());
|
||||
|
||||
// We need to remove defaultRoles here as realm.addUser is automatically adding them. We may add them later during roles mapping processing
|
||||
for (RoleModel role : user.getRoleMappings()) {
|
||||
|
|
|
@ -22,7 +22,7 @@ public class AccountBean {
|
|||
}
|
||||
|
||||
public String getUsername() {
|
||||
return user.getLoginName();
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
|
|
|
@ -16,9 +16,9 @@ public interface UserModel {
|
|||
|
||||
String getId();
|
||||
|
||||
String getLoginName();
|
||||
String getUsername();
|
||||
|
||||
void setLoginName(String loginName);
|
||||
void setUsername(String username);
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.keycloak.models.UserModel;
|
|||
*/
|
||||
public class UserEntity extends AbstractIdentifiableEntity {
|
||||
|
||||
private String loginName;
|
||||
private String username;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
|
@ -30,12 +30,12 @@ public class UserEntity extends AbstractIdentifiableEntity {
|
|||
private List<SocialLinkEntity> socialLinks;
|
||||
private AuthenticationLinkEntity authenticationLink;
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName) {
|
||||
this.loginName = loginName;
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
|
|
|
@ -47,15 +47,15 @@ public class UserAdapter implements UserModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getLoginName() {
|
||||
if (updated != null) return updated.getLoginName();
|
||||
return cached.getLoginName();
|
||||
public String getUsername() {
|
||||
if (updated != null) return updated.getUsername();
|
||||
return cached.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginName(String loginName) {
|
||||
public void setUsername(String username) {
|
||||
getDelegateForUpdate();
|
||||
updated.setLoginName(loginName);
|
||||
updated.setUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Set;
|
|||
*/
|
||||
public class CachedUser {
|
||||
private String id;
|
||||
private String loginName;
|
||||
private String username;
|
||||
private String usernameKey;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
@ -38,8 +38,8 @@ public class CachedUser {
|
|||
|
||||
public CachedUser(RealmModel realm, UserModel user) {
|
||||
this.id = user.getId();
|
||||
this.loginName = user.getLoginName();
|
||||
this.usernameKey = realm.getId() + "." + this.loginName;
|
||||
this.username = user.getUsername();
|
||||
this.usernameKey = realm.getId() + "." + this.username;
|
||||
this.firstName = user.getFirstName();
|
||||
this.lastName = user.getLastName();
|
||||
this.attributes.putAll(user.getAttributes());
|
||||
|
@ -63,8 +63,8 @@ public class CachedUser {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getUsernameKey() {
|
||||
|
|
|
@ -93,8 +93,8 @@ public class JpaModelProvider implements ModelProvider {
|
|||
|
||||
@Override
|
||||
public UserModel getUserByUsername(String username, RealmModel realmModel) {
|
||||
TypedQuery<UserEntity> query = em.createNamedQuery("getRealmUserByLoginName", UserEntity.class);
|
||||
query.setParameter("loginName", username);
|
||||
TypedQuery<UserEntity> query = em.createNamedQuery("getRealmUserByUsername", UserEntity.class);
|
||||
query.setParameter("username", username);
|
||||
RealmEntity realm = em.getReference(RealmEntity.class, realmModel.getId());
|
||||
query.setParameter("realm", realm);
|
||||
List<UserEntity> results = query.getResultList();
|
||||
|
@ -130,7 +130,7 @@ public class JpaModelProvider implements ModelProvider {
|
|||
}
|
||||
|
||||
for (UserEntity u : em.createQuery("from UserEntity u where u.realm = :realm", UserEntity.class).setParameter("realm", realm).getResultList()) {
|
||||
adapter.removeUser(u.getLoginName());
|
||||
adapter.removeUser(u.getUsername());
|
||||
}
|
||||
|
||||
em.remove(realm);
|
||||
|
@ -185,7 +185,7 @@ public class JpaModelProvider implements ModelProvider {
|
|||
|
||||
@Override
|
||||
public List<UserModel> searchForUser(String search, RealmModel realm) {
|
||||
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where u.realm = :realm and ( lower(u.loginName) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search )", UserEntity.class);
|
||||
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where u.realm = :realm and ( lower(u.username) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search )", UserEntity.class);
|
||||
RealmEntity realmEntity = em.getReference(RealmEntity.class, realm.getId());
|
||||
query.setParameter("realm", realmEntity);
|
||||
query.setParameter("search", "%" + search.toLowerCase() + "%");
|
||||
|
@ -202,7 +202,7 @@ public class JpaModelProvider implements ModelProvider {
|
|||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||
String attribute = null;
|
||||
if (entry.getKey().equals(UserModel.LOGIN_NAME)) {
|
||||
attribute = "lower(loginName)";
|
||||
attribute = "lower(username)";
|
||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.FIRST_NAME)) {
|
||||
attribute = "lower(firstName)";
|
||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.LAST_NAME)) {
|
||||
|
|
|
@ -462,7 +462,7 @@ public class RealmAdapter implements RealmModel {
|
|||
public UserModel addUser(String id, String username) {
|
||||
UserEntity entity = new UserEntity();
|
||||
entity.setId(id);
|
||||
entity.setLoginName(username);
|
||||
entity.setUsername(username);
|
||||
entity.setRealm(realm);
|
||||
em.persist(entity);
|
||||
em.flush();
|
||||
|
@ -483,8 +483,8 @@ public class RealmAdapter implements RealmModel {
|
|||
|
||||
@Override
|
||||
public boolean removeUser(String name) {
|
||||
TypedQuery<UserEntity> query = em.createNamedQuery("getRealmUserByLoginName", UserEntity.class);
|
||||
query.setParameter("loginName", name);
|
||||
TypedQuery<UserEntity> query = em.createNamedQuery("getRealmUserByUsername", UserEntity.class);
|
||||
query.setParameter("username", name);
|
||||
query.setParameter("realm", realm);
|
||||
List<UserEntity> results = query.getResultList();
|
||||
if (results.size() == 0) return false;
|
||||
|
|
|
@ -53,13 +53,13 @@ public class UserAdapter implements UserModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getLoginName() {
|
||||
return user.getLoginName();
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginName(String loginName) {
|
||||
user.setLoginName(loginName);
|
||||
public void setUsername(String username) {
|
||||
user.setUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,21 +35,21 @@ import java.util.Set;
|
|||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="getRealmUserById", query="select u from UserEntity u where u.id = :id and u.realm = :realm"),
|
||||
@NamedQuery(name="getRealmUserByLoginName", query="select u from UserEntity u where u.loginName = :loginName and u.realm = :realm"),
|
||||
@NamedQuery(name="getRealmUserByUsername", query="select u from UserEntity u where u.username = :username and u.realm = :realm"),
|
||||
@NamedQuery(name="getRealmUserByEmail", query="select u from UserEntity u where u.email = :email and u.realm = :realm"),
|
||||
@NamedQuery(name="getRealmUserByLastName", query="select u from UserEntity u where u.lastName = :lastName and u.realm = :realm"),
|
||||
@NamedQuery(name="getRealmUserByFirstLastName", query="select u from UserEntity u where u.firstName = :first and u.lastName = :last and u.realm = :realm")
|
||||
})
|
||||
@Entity
|
||||
@Table(uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "realm", "loginName" }),
|
||||
@UniqueConstraint(columnNames = { "realm", "username" }),
|
||||
@UniqueConstraint(columnNames = { "realm", "emailConstraint" })
|
||||
})
|
||||
public class UserEntity {
|
||||
@Id
|
||||
protected String id;
|
||||
|
||||
protected String loginName;
|
||||
protected String username;
|
||||
protected String firstName;
|
||||
protected String lastName;
|
||||
protected String email;
|
||||
|
@ -89,12 +89,12 @@ public class UserEntity {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName) {
|
||||
this.loginName = loginName;
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class MongoModelProvider implements ModelProvider {
|
|||
@Override
|
||||
public UserModel getUserByUsername(String username, RealmModel realm) {
|
||||
DBObject query = new QueryBuilder()
|
||||
.and("loginName").is(username)
|
||||
.and("username").is(username)
|
||||
.and("realmId").is(realm.getId())
|
||||
.get();
|
||||
MongoUserEntity user = getMongoStore().loadSingleEntity(MongoUserEntity.class, query, invocationContext);
|
||||
|
@ -226,7 +226,7 @@ public class MongoModelProvider implements ModelProvider {
|
|||
QueryBuilder builder = new QueryBuilder().and(
|
||||
new QueryBuilder().and("realmId").is(realm.getId()).get(),
|
||||
new QueryBuilder().or(
|
||||
new QueryBuilder().put("loginName").regex(caseInsensitivePattern).get(),
|
||||
new QueryBuilder().put("username").regex(caseInsensitivePattern).get(),
|
||||
new QueryBuilder().put("email").regex(caseInsensitivePattern).get(),
|
||||
nameBuilder.get()
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class MongoModelProvider implements ModelProvider {
|
|||
|
||||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||
if (entry.getKey().equals(UserModel.LOGIN_NAME)) {
|
||||
queryBuilder.and("loginName").regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
||||
queryBuilder.and("username").regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.FIRST_NAME)) {
|
||||
queryBuilder.and(UserModel.FIRST_NAME).regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
||||
|
||||
|
|
|
@ -503,7 +503,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
protected UserAdapter addUserEntity(String id, String username) {
|
||||
MongoUserEntity userEntity = new MongoUserEntity();
|
||||
userEntity.setId(id);
|
||||
userEntity.setLoginName(username);
|
||||
userEntity.setUsername(username);
|
||||
// Compatibility with JPA model, which has user disabled by default
|
||||
// userEntity.setEnabled(true);
|
||||
userEntity.setRealmId(getId());
|
||||
|
@ -515,7 +515,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
@Override
|
||||
public boolean removeUser(String name) {
|
||||
DBObject query = new QueryBuilder()
|
||||
.and("loginName").is(name)
|
||||
.and("username").is(name)
|
||||
.and("realmId").is(getId())
|
||||
.get();
|
||||
return getMongoStore().removeEntities(MongoUserEntity.class, query, invocationContext);
|
||||
|
|
|
@ -49,13 +49,13 @@ public class UserAdapter extends AbstractMongoAdapter<MongoUserEntity> implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getLoginName() {
|
||||
return user.getLoginName();
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginName(String loginName) {
|
||||
user.setLoginName(loginName);
|
||||
public void setUsername(String username) {
|
||||
user.setUsername(username);
|
||||
updateUser();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class MongoRoleEntity extends RoleEntity implements MongoIdentifiableEnti
|
|||
|
||||
List<MongoUserEntity> users = mongoStore.loadEntities(MongoUserEntity.class, query, invContext);
|
||||
for (MongoUserEntity user : users) {
|
||||
logger.info("Removing role " + getName() + " from user " + user.getLoginName());
|
||||
logger.info("Removing role " + getName() + " from user " + user.getUsername());
|
||||
mongoStore.pullItemFromList(user, "roleIds", getId(), invContext);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class MongoRoleEntity extends RoleEntity implements MongoIdentifiableEnti
|
|||
|
||||
users = mongoStore.loadEntities(MongoUserEntity.class, query, invContext);
|
||||
for (MongoUserEntity user : users) {
|
||||
logger.info("Removing scope " + getName() + " from user " + user.getLoginName());
|
||||
logger.info("Removing scope " + getName() + " from user " + user.getUsername());
|
||||
mongoStore.pullItemFromList(user, "scopeIds", getId(), invContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.keycloak.models.mongo.api.context.MongoStoreInvocationContext;
|
|||
*/
|
||||
@MongoCollection(collectionName = "users")
|
||||
@MongoIndexes({
|
||||
@MongoIndex(fields = { "realmId", "loginName" }, unique = true),
|
||||
@MongoIndex(fields = { "realmId", "username" }, unique = true),
|
||||
@MongoIndex(fields = { "emailIndex" }, unique = true, sparse = true),
|
||||
})
|
||||
public class MongoUserEntity extends UserEntity implements MongoIdentifiableEntity {
|
||||
|
|
|
@ -160,7 +160,7 @@ public class AdapterTest extends AbstractModelTest {
|
|||
RoleModel appRole = app.addRole("test");
|
||||
user.grantRole(appRole);
|
||||
|
||||
SocialLinkModel socialLink = new SocialLinkModel("google", "google1", user.getLoginName());
|
||||
SocialLinkModel socialLink = new SocialLinkModel("google", "google1", user.getUsername());
|
||||
realmModel.addSocialLink(user, socialLink);
|
||||
|
||||
UserCredentialModel cred = new UserCredentialModel();
|
||||
|
@ -312,7 +312,7 @@ public class AdapterTest extends AbstractModelTest {
|
|||
{
|
||||
ArrayList<String> users = new ArrayList<String>();
|
||||
for (UserModel u : adapter.searchUsers("ole alver", realmModel)) {
|
||||
users.add(u.getLoginName());
|
||||
users.add(u.getUsername());
|
||||
}
|
||||
String[] usernames = users.toArray(new String[users.size()]);
|
||||
Arrays.sort(usernames);
|
||||
|
@ -625,7 +625,7 @@ public class AdapterTest extends AbstractModelTest {
|
|||
realmManager.getRealmByName("JUGGLER1").addUser("user2");
|
||||
commit();
|
||||
try {
|
||||
realmManager.getRealmByName("JUGGLER1").getUser("user2").setLoginName("user1");
|
||||
realmManager.getRealmByName("JUGGLER1").getUser("user2").setUsername("user1");
|
||||
commit();
|
||||
Assert.fail("Expected exception");
|
||||
} catch (ModelDuplicateException e) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class AuthProvidersExternalModelTest extends AbstractModelTest {
|
|||
Assert.assertEquals(AuthenticationManager.AuthenticationStatus.SUCCESS, am.authenticateForm(null, realm2, formData));
|
||||
UserModel john2 = realm2.getUser("john");
|
||||
Assert.assertNotNull(john2);
|
||||
Assert.assertEquals("john", john2.getLoginName());
|
||||
Assert.assertEquals("john", john2.getUsername());
|
||||
Assert.assertEquals("John", john2.getFirstName());
|
||||
Assert.assertEquals("Doe", john2.getLastName());
|
||||
Assert.assertEquals("john@email.org", john2.getEmail());
|
||||
|
|
|
@ -89,7 +89,7 @@ public class AuthProvidersLDAPTest extends AbstractModelTest {
|
|||
Assert.assertEquals(AuthenticationManager.AuthenticationStatus.SUCCESS, am.authenticateForm(null, realm, formData));
|
||||
UserModel john = realm.getUser("johnkeycloak");
|
||||
Assert.assertNotNull(john);
|
||||
Assert.assertEquals("johnkeycloak", john.getLoginName());
|
||||
Assert.assertEquals("johnkeycloak", john.getUsername());
|
||||
Assert.assertEquals("John", john.getFirstName());
|
||||
Assert.assertEquals("Doe", john.getLastName());
|
||||
Assert.assertEquals("john@email.org", john.getEmail());
|
||||
|
|
|
@ -173,7 +173,7 @@ public class ImportTest extends AbstractModelTest {
|
|||
Assert.assertTrue(facebookFound && twitterFound && googleFound);
|
||||
|
||||
UserModel foundSocialUser = realm.getUserBySocialLink(new SocialLinkModel("facebook", "facebook1", "fbuser1"));
|
||||
Assert.assertEquals(foundSocialUser.getLoginName(), socialUser.getLoginName());
|
||||
Assert.assertEquals(foundSocialUser.getUsername(), socialUser.getUsername());
|
||||
Assert.assertNull(realm.getUserBySocialLink(new SocialLinkModel("facebook", "not-existing", "not-existing")));
|
||||
|
||||
SocialLinkModel foundSocialLink = realm.getSocialLink(socialUser, "facebook");
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MultipleRealmsTest extends AbstractModelTest {
|
|||
public void testUsers() {
|
||||
UserModel r1user1 = realm1.getUser("user1");
|
||||
UserModel r2user1 = realm2.getUser("user1");
|
||||
Assert.assertEquals(r1user1.getLoginName(), r2user1.getLoginName());
|
||||
Assert.assertEquals(r1user1.getUsername(), r2user1.getUsername());
|
||||
Assert.assertNotEquals(r1user1.getId(), r2user1.getId());
|
||||
|
||||
// Test password
|
||||
|
|
|
@ -111,7 +111,7 @@ public class UserModelTest extends AbstractModelTest {
|
|||
}
|
||||
|
||||
public static void assertEquals(UserModel expected, UserModel actual) {
|
||||
Assert.assertEquals(expected.getLoginName(), actual.getLoginName());
|
||||
Assert.assertEquals(expected.getUsername(), actual.getUsername());
|
||||
Assert.assertEquals(expected.getFirstName(), actual.getFirstName());
|
||||
Assert.assertEquals(expected.getLastName(), actual.getLastName());
|
||||
Assert.assertArrayEquals(expected.getRequiredActions().toArray(), actual.getRequiredActions().toArray());
|
||||
|
|
|
@ -31,7 +31,7 @@ public class UpsSecurityApplication extends KeycloakApplication {
|
|||
RealmManager manager = new RealmManager(session);
|
||||
RealmModel master = manager.getKeycloakAdminstrationRealm();
|
||||
UserModel admin = master.getUser("admin");
|
||||
if (admin != null) master.removeUser(admin.getLoginName());
|
||||
if (admin != null) master.removeUser(admin.getUsername());
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
session.close();
|
||||
|
|
|
@ -69,7 +69,7 @@ public class AuthenticationManager {
|
|||
if (session == null) return;
|
||||
UserModel user = session.getUser();
|
||||
|
||||
logger.infov("Logging out: {0} ({1})", user.getLoginName(), session.getId());
|
||||
logger.infov("Logging out: {0} ({1})", user.getUsername(), session.getId());
|
||||
|
||||
realm.removeUserSession(session);
|
||||
expireIdentityCookie(realm, uriInfo);
|
||||
|
@ -343,7 +343,7 @@ public class AuthenticationManager {
|
|||
|
||||
private boolean checkEnabled(UserModel user) {
|
||||
if (!user.isEnabled()) {
|
||||
logger.warn("AccountProvider is disabled, contact admin. " + user.getLoginName());
|
||||
logger.warn("AccountProvider is disabled, contact admin. " + user.getUsername());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ModelToRepresentation {
|
|||
public static UserRepresentation toRepresentation(UserModel user) {
|
||||
UserRepresentation rep = new UserRepresentation();
|
||||
rep.setId(user.getId());
|
||||
rep.setUsername(user.getLoginName());
|
||||
rep.setUsername(user.getUsername());
|
||||
rep.setLastName(user.getLastName());
|
||||
rep.setFirstName(user.getFirstName());
|
||||
rep.setEmail(user.getEmail());
|
||||
|
@ -190,7 +190,7 @@ public class ModelToRepresentation {
|
|||
rep.setId(session.getId());
|
||||
rep.setStart(((long)session.getStarted()) * 1000L);
|
||||
rep.setLastAccess(((long)session.getLastSessionRefresh())* 1000L);
|
||||
rep.setUser(session.getUser().getLoginName());
|
||||
rep.setUser(session.getUser().getUsername());
|
||||
rep.setIpAddress(session.getIpAddress());
|
||||
for (ClientModel client : session.getClientAssociations()) {
|
||||
if (client instanceof ApplicationModel) {
|
||||
|
|
|
@ -370,7 +370,7 @@ public class RealmManager {
|
|||
if (rep.getUsers() != null) {
|
||||
for (UserRepresentation userRep : rep.getUsers()) {
|
||||
UserModel user = createUser(newRealm, userRep);
|
||||
userMap.put(user.getLoginName(), user);
|
||||
userMap.put(user.getUsername(), user);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ResourceAdminManager {
|
|||
for (Map.Entry<String, UserStats> entry : stats.getUsers().entrySet()) {
|
||||
UserModel user = realm.getUserById(entry.getKey());
|
||||
if (user == null) continue;
|
||||
newUsers.put(user.getLoginName(), entry.getValue());
|
||||
newUsers.put(user.getUsername(), entry.getValue());
|
||||
|
||||
}
|
||||
stats.setUsers(newUsers);
|
||||
|
|
|
@ -262,7 +262,7 @@ public class TokenManager {
|
|||
|
||||
public void initClaims(IDToken token, ClientModel model, UserModel user) {
|
||||
if (ClaimMask.hasUsername(model.getAllowedClaimsMask())) {
|
||||
token.setPreferredUsername(user.getLoginName());
|
||||
token.setPreferredUsername(user.getUsername());
|
||||
}
|
||||
if (ClaimMask.hasEmail(model.getAllowedClaimsMask())) {
|
||||
token.setEmail(user.getEmail());
|
||||
|
@ -284,7 +284,7 @@ public class TokenManager {
|
|||
token.subject(user.getId());
|
||||
token.audience(realm.getName());
|
||||
token.issuedNow();
|
||||
token.issuedFor(client.getLoginName());
|
||||
token.issuedFor(client.getUsername());
|
||||
token.issuer(realm.getName());
|
||||
if (realm.getAccessTokenLifespan() > 0) {
|
||||
token.expiration(Time.currentTime() + realm.getAccessTokenLifespan());
|
||||
|
|
|
@ -514,7 +514,7 @@ public class AccountService {
|
|||
if (realm.getSocialLinks(user).size() > 1 || user.getAuthenticationLink() != null) {
|
||||
realm.removeSocialLink(user, providerId);
|
||||
|
||||
logger.debug("Social provider " + providerId + " removed successfully from user " + user.getLoginName());
|
||||
logger.debug("Social provider " + providerId + " removed successfully from user " + user.getUsername());
|
||||
|
||||
audit.event(EventType.REMOVE_SOCIAL_LINK).client(auth.getClient()).user(auth.getUser())
|
||||
.detail(Details.USERNAME, link.getSocialUserId() + "@" + link.getSocialProvider())
|
||||
|
|
|
@ -381,7 +381,7 @@ public class RequiredActionsService {
|
|||
}
|
||||
|
||||
private UserModel getUser(AccessCodeEntry accessCode) {
|
||||
return realm.getUser(accessCode.getUser().getLoginName());
|
||||
return realm.getUser(accessCode.getUser().getUsername());
|
||||
}
|
||||
|
||||
private Response redirectOauth(UserModel user, AccessCodeEntry accessCode) {
|
||||
|
|
|
@ -212,7 +212,7 @@ public class SocialResource {
|
|||
}
|
||||
|
||||
realm.addSocialLink(authenticatedUser, socialLink);
|
||||
logger.debug("Social provider " + provider.getId() + " linked with user " + authenticatedUser.getLoginName());
|
||||
logger.debug("Social provider " + provider.getId() + " linked with user " + authenticatedUser.getUsername());
|
||||
|
||||
audit.success();
|
||||
return Response.status(302).location(UriBuilder.fromUri(redirectUri).build()).build();
|
||||
|
|
|
@ -830,7 +830,7 @@ public class TokenService {
|
|||
UserModel user = authResult.getUser();
|
||||
UserSessionModel session = authResult.getSession();
|
||||
|
||||
logger.debug(user.getLoginName() + " already logged in.");
|
||||
logger.debug(user.getUsername() + " already logged in.");
|
||||
audit.user(user).session(session).detail(Details.AUTH_METHOD, "sso");
|
||||
return oauth.processAccessCode(scopeParam, state, redirect, client, user, session, null, false, "sso", audit);
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class AdminConsole {
|
|||
displayName = displayName != null ? displayName + " " + user.getLastName() : user.getLastName();
|
||||
}
|
||||
} else {
|
||||
displayName = user.getLoginName();
|
||||
displayName = user.getUsername();
|
||||
}
|
||||
|
||||
RealmModel masterRealm = getAdminstrationRealm(realmManager);
|
||||
|
|
|
@ -182,7 +182,7 @@ public class AdminRoot {
|
|||
|
||||
AdminAuth auth = authenticateRealmAdminRequest(headers);
|
||||
if (auth != null) {
|
||||
logger.info("authenticated admin access for: " + auth.getUser().getLoginName());
|
||||
logger.info("authenticated admin access for: " + auth.getUser().getUsername());
|
||||
}
|
||||
|
||||
Cors.add(request).allowedOrigins(auth.getToken()).allowedMethods("GET", "PUT", "POST", "DELETE").auth().build(response);
|
||||
|
|
|
@ -127,7 +127,7 @@ public class UsersResource {
|
|||
UserModel user = realm.addUser(rep.getUsername());
|
||||
updateUserFromRep(user, rep);
|
||||
|
||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(user.getLoginName()).build()).build();
|
||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(user.getUsername()).build()).build();
|
||||
} catch (ModelDuplicateException e) {
|
||||
return Flows.errors().exists("User exists with same username or email");
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class PerfTools {
|
|||
public void deleteUsers(@PathParam("realm") String realmName) {
|
||||
RealmModel realm = session.getRealmByName(realmName);
|
||||
for (UserModel user : realm.getUsers()) {
|
||||
realm.removeUser(user.getLoginName());
|
||||
realm.removeUser(user.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue