Merge pull request #558 from patriot1burke/master

rename classes
This commit is contained in:
Bill Burke 2014-07-25 10:45:22 -04:00
commit a6b38397ea
12 changed files with 48 additions and 50 deletions

View file

@ -1,7 +1,5 @@
package org.keycloak.representations.idm; package org.keycloak.representations.idm;
import org.keycloak.representations.FederationProviderRepresentation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -58,7 +56,7 @@ public class RealmRepresentation {
protected Map<String, String> smtpServer; protected Map<String, String> smtpServer;
protected Map<String, String> ldapServer; protected Map<String, String> ldapServer;
protected List<AuthenticationProviderRepresentation> authenticationProviders; protected List<AuthenticationProviderRepresentation> authenticationProviders;
protected List<FederationProviderRepresentation> federationProviders; protected List<UserFederationProviderRepresentation> userFederationProviders;
protected String loginTheme; protected String loginTheme;
protected String accountTheme; protected String accountTheme;
protected String adminTheme; protected String adminTheme;
@ -471,11 +469,11 @@ public class RealmRepresentation {
this.auditListeners = auditListeners; this.auditListeners = auditListeners;
} }
public List<FederationProviderRepresentation> getFederationProviders() { public List<UserFederationProviderRepresentation> getUserFederationProviders() {
return federationProviders; return userFederationProviders;
} }
public void setFederationProviders(List<FederationProviderRepresentation> federationProviders) { public void setUserFederationProviders(List<UserFederationProviderRepresentation> userFederationProviders) {
this.federationProviders = federationProviders; this.userFederationProviders = userFederationProviders;
} }
} }

View file

@ -1,11 +1,11 @@
package org.keycloak.representations; package org.keycloak.representations.idm;
import java.util.Map; import java.util.Map;
/** /**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/ */
public class FederationProviderRepresentation { public class UserFederationProviderRepresentation {
private String id; private String id;
private String providerName; private String providerName;
@ -41,7 +41,7 @@ public class FederationProviderRepresentation {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
FederationProviderRepresentation that = (FederationProviderRepresentation) o; UserFederationProviderRepresentation that = (UserFederationProviderRepresentation) o;
if (!id.equals(that.id)) return false; if (!id.equals(that.id)) return false;

View file

@ -267,12 +267,12 @@ public class LDAPFederationProvider implements UserFederationProvider {
@Override @Override
public void preRemove(RealmModel realm) { public void preRemove(RealmModel realm) {
//To change body of implemented methods use File | Settings | File Templates. // complete Don't think we have to do anything
} }
@Override @Override
public void preRemove(RealmModel realm, RoleModel role) { public void preRemove(RealmModel realm, RoleModel role) {
//To change body of implemented methods use File | Settings | File Templates. // complete I don't think we have to do anything here
} }
public boolean validPassword(String username, String password) { public boolean validPassword(String username, String password) {

View file

@ -165,9 +165,9 @@ public interface RealmModel extends RoleContainerModel {
void setAuthenticationProviders(List<AuthenticationProviderModel> authenticationProviders); void setAuthenticationProviders(List<AuthenticationProviderModel> authenticationProviders);
List<UserFederationProviderModel> getFederationProviders(); List<UserFederationProviderModel> getUserFederationProviders();
void setFederationProviders(List<UserFederationProviderModel> providers); void setUserFederationProviders(List<UserFederationProviderModel> providers);
String getLoginTheme(); String getLoginTheme();

View file

@ -20,7 +20,7 @@ public class UserFederationManager implements UserProvider {
@Override @Override
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) { public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles); UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles);
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = session.getProvider(UserFederationProvider.class, federation.getProviderName()); UserFederationProvider fed = session.getProvider(UserFederationProvider.class, federation.getProviderName());
return fed.addUser(realm, user); return fed.addUser(realm, user);
} }
@ -36,7 +36,7 @@ public class UserFederationManager implements UserProvider {
@Override @Override
public UserModel addUser(RealmModel realm, String username) { public UserModel addUser(RealmModel realm, String username) {
UserModel user = session.userStorage().addUser(realm, username); UserModel user = session.userStorage().addUser(realm, username);
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
return fed.addUser(realm, user); return fed.addUser(realm, user);
} }
@ -45,7 +45,7 @@ public class UserFederationManager implements UserProvider {
protected UserFederationProvider getFederationLink(RealmModel realm, UserModel user) { protected UserFederationProvider getFederationLink(RealmModel realm, UserModel user) {
if (user.getFederationLink() == null) return null; if (user.getFederationLink() == null) return null;
for (UserFederationProviderModel fed : realm.getFederationProviders()) { for (UserFederationProviderModel fed : realm.getUserFederationProviders()) {
if (fed.getId().equals(user.getFederationLink())) { if (fed.getId().equals(user.getFederationLink())) {
return getFederationProvider(fed); return getFederationProvider(fed);
} }
@ -95,7 +95,7 @@ public class UserFederationManager implements UserProvider {
} }
return user; return user;
} }
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
user = fed.getUserById(id, realm); user = fed.getUserById(id, realm);
if (user != null) return user; if (user != null) return user;
@ -113,7 +113,7 @@ public class UserFederationManager implements UserProvider {
} }
return user; return user;
} }
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
user = fed.getUserByUsername(username, realm); user = fed.getUserByUsername(username, realm);
if (user != null) return user; if (user != null) return user;
@ -131,7 +131,7 @@ public class UserFederationManager implements UserProvider {
} }
return user; return user;
} }
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
user = fed.getUserByEmail(email, realm); user = fed.getUserByEmail(email, realm);
if (user != null) return user; if (user != null) return user;
@ -149,7 +149,7 @@ public class UserFederationManager implements UserProvider {
} }
return user; return user;
} }
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
user = fed.getUserBySocialLink(socialLink, realm); user = fed.getUserBySocialLink(socialLink, realm);
if (user != null) return user; if (user != null) return user;
@ -185,7 +185,7 @@ public class UserFederationManager implements UserProvider {
results.addAll(users.values()); results.addAll(users.values());
return results; return results;
} }
List<UserFederationProviderModel> federationProviders = realm.getFederationProviders(); List<UserFederationProviderModel> federationProviders = realm.getUserFederationProviders();
for (int i = federationProviders.size() - 1; i >= 0; i--) { for (int i = federationProviders.size() - 1; i >= 0; i--) {
UserFederationProviderModel federation = federationProviders.get(i); UserFederationProviderModel federation = federationProviders.get(i);
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
@ -219,7 +219,7 @@ public class UserFederationManager implements UserProvider {
results.addAll(users.values()); results.addAll(users.values());
return results; return results;
} }
List<UserFederationProviderModel> federationProviders = realm.getFederationProviders(); List<UserFederationProviderModel> federationProviders = realm.getUserFederationProviders();
for (int i = federationProviders.size() - 1; i >= 0; i--) { for (int i = federationProviders.size() - 1; i >= 0; i--) {
UserFederationProviderModel federation = federationProviders.get(i); UserFederationProviderModel federation = federationProviders.get(i);
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
@ -253,7 +253,7 @@ public class UserFederationManager implements UserProvider {
results.addAll(users.values()); results.addAll(users.values());
return results; return results;
} }
List<UserFederationProviderModel> federationProviders = realm.getFederationProviders(); List<UserFederationProviderModel> federationProviders = realm.getUserFederationProviders();
for (int i = federationProviders.size() - 1; i >= 0; i--) { for (int i = federationProviders.size() - 1; i >= 0; i--) {
UserFederationProviderModel federation = federationProviders.get(i); UserFederationProviderModel federation = federationProviders.get(i);
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
@ -285,7 +285,7 @@ public class UserFederationManager implements UserProvider {
@Override @Override
public void preRemove(RealmModel realm) { public void preRemove(RealmModel realm) {
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
fed.preRemove(realm); fed.preRemove(realm);
} }
@ -294,7 +294,7 @@ public class UserFederationManager implements UserProvider {
@Override @Override
public void preRemove(RealmModel realm, RoleModel role) { public void preRemove(RealmModel realm, RoleModel role) {
for (UserFederationProviderModel federation : realm.getFederationProviders()) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) {
UserFederationProvider fed = getFederationProvider(federation); UserFederationProvider fed = getFederationProvider(federation);
fed.preRemove(realm, role); fed.preRemove(realm, role);
} }

View file

@ -14,7 +14,7 @@ import org.keycloak.models.SocialLinkModel;
import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserCredentialModel;
import org.keycloak.models.UserModel; import org.keycloak.models.UserModel;
import org.keycloak.models.UserSessionModel; import org.keycloak.models.UserSessionModel;
import org.keycloak.representations.FederationProviderRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.representations.idm.ApplicationRepresentation; import org.keycloak.representations.idm.ApplicationRepresentation;
import org.keycloak.representations.idm.AuthenticationProviderRepresentation; import org.keycloak.representations.idm.AuthenticationProviderRepresentation;
import org.keycloak.representations.idm.ClaimRepresentation; import org.keycloak.representations.idm.ClaimRepresentation;
@ -143,17 +143,17 @@ public class ModelToRepresentation {
} }
rep.setAuthenticationProviders(authProviderReps); rep.setAuthenticationProviders(authProviderReps);
} }
List<UserFederationProviderModel> fedProviderModels = realm.getFederationProviders(); List<UserFederationProviderModel> fedProviderModels = realm.getUserFederationProviders();
if (fedProviderModels.size() > 0) { if (fedProviderModels.size() > 0) {
List<FederationProviderRepresentation> fedProviderReps = new ArrayList<FederationProviderRepresentation>(); List<UserFederationProviderRepresentation> fedProviderReps = new ArrayList<UserFederationProviderRepresentation>();
for (UserFederationProviderModel model : fedProviderModels) { for (UserFederationProviderModel model : fedProviderModels) {
FederationProviderRepresentation fedProvRep = new FederationProviderRepresentation(); UserFederationProviderRepresentation fedProvRep = new UserFederationProviderRepresentation();
fedProvRep.setId(model.getId()); fedProvRep.setId(model.getId());
fedProvRep.setProviderName(model.getProviderName()); fedProvRep.setProviderName(model.getProviderName());
fedProvRep.setConfig(model.getConfig()); fedProvRep.setConfig(model.getConfig());
fedProviderReps.add(fedProvRep); fedProviderReps.add(fedProvRep);
} }
rep.setFederationProviders(fedProviderReps); rep.setUserFederationProviders(fedProviderReps);
} }
return rep; return rep;
} }

View file

@ -17,7 +17,7 @@ import org.keycloak.models.SocialLinkModel;
import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserCredentialModel;
import org.keycloak.models.UserCredentialValueModel; import org.keycloak.models.UserCredentialValueModel;
import org.keycloak.models.UserModel; import org.keycloak.models.UserModel;
import org.keycloak.representations.FederationProviderRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.representations.idm.ApplicationRepresentation; import org.keycloak.representations.idm.ApplicationRepresentation;
import org.keycloak.representations.idm.AuthenticationLinkRepresentation; import org.keycloak.representations.idm.AuthenticationLinkRepresentation;
import org.keycloak.representations.idm.AuthenticationProviderRepresentation; import org.keycloak.representations.idm.AuthenticationProviderRepresentation;
@ -215,9 +215,9 @@ public class RepresentationToModel {
newRealm.setAuthenticationProviders(authProviderModels); newRealm.setAuthenticationProviders(authProviderModels);
} }
if (rep.getFederationProviders() != null) { if (rep.getUserFederationProviders() != null) {
List<UserFederationProviderModel> providerModels = convertFederationProviders(rep.getFederationProviders()); List<UserFederationProviderModel> providerModels = convertFederationProviders(rep.getUserFederationProviders());
newRealm.setFederationProviders(providerModels); newRealm.setUserFederationProviders(providerModels);
} }
// create users and their role mappings and social mappings // create users and their role mappings and social mappings
@ -287,9 +287,9 @@ public class RepresentationToModel {
realm.setAuthenticationProviders(authProviderModels); realm.setAuthenticationProviders(authProviderModels);
} }
if (rep.getFederationProviders() != null) { if (rep.getUserFederationProviders() != null) {
List<UserFederationProviderModel> providerModels = convertFederationProviders(rep.getFederationProviders()); List<UserFederationProviderModel> providerModels = convertFederationProviders(rep.getUserFederationProviders());
realm.setFederationProviders(providerModels); realm.setUserFederationProviders(providerModels);
} }
if ("GENERATE".equals(rep.getPublicKey())) { if ("GENERATE".equals(rep.getPublicKey())) {
@ -315,10 +315,10 @@ public class RepresentationToModel {
return result; return result;
} }
private static List<UserFederationProviderModel> convertFederationProviders(List<FederationProviderRepresentation> providers) { private static List<UserFederationProviderModel> convertFederationProviders(List<UserFederationProviderRepresentation> providers) {
List<UserFederationProviderModel> result = new ArrayList<UserFederationProviderModel>(); List<UserFederationProviderModel> result = new ArrayList<UserFederationProviderModel>();
for (FederationProviderRepresentation representation : providers) { for (UserFederationProviderRepresentation representation : providers) {
UserFederationProviderModel model = new UserFederationProviderModel(representation.getId(), representation.getProviderName(), UserFederationProviderModel model = new UserFederationProviderModel(representation.getId(), representation.getProviderName(),
representation.getConfig()); representation.getConfig());
result.add(model); result.add(model);

View file

@ -606,15 +606,15 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public List<UserFederationProviderModel> getFederationProviders() { public List<UserFederationProviderModel> getUserFederationProviders() {
if (updated != null) return updated.getFederationProviders(); if (updated != null) return updated.getUserFederationProviders();
return cached.getFederationProviders(); return cached.getFederationProviders();
} }
@Override @Override
public void setFederationProviders(List<UserFederationProviderModel> providers) { public void setUserFederationProviders(List<UserFederationProviderModel> providers) {
getDelegateForUpdate(); getDelegateForUpdate();
updated.setFederationProviders(providers); updated.setUserFederationProviders(providers);
} }
@Override @Override

View file

@ -122,7 +122,7 @@ public class CachedRealm {
requiredCredentials = model.getRequiredCredentials(); requiredCredentials = model.getRequiredCredentials();
authenticationProviders = model.getAuthenticationProviders(); authenticationProviders = model.getAuthenticationProviders();
federationProviders = model.getFederationProviders(); federationProviders = model.getUserFederationProviders();
smtpConfig.putAll(model.getSmtpConfig()); smtpConfig.putAll(model.getSmtpConfig());
socialConfig.putAll(model.getSocialConfig()); socialConfig.putAll(model.getSocialConfig());

View file

@ -727,7 +727,7 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public List<UserFederationProviderModel> getFederationProviders() { public List<UserFederationProviderModel> getUserFederationProviders() {
List<FederationProviderEntity> entities = realm.getFederationProviders(); List<FederationProviderEntity> entities = realm.getFederationProviders();
List<FederationProviderEntity> copy = new ArrayList<FederationProviderEntity>(); List<FederationProviderEntity> copy = new ArrayList<FederationProviderEntity>();
for (FederationProviderEntity entity : entities) { for (FederationProviderEntity entity : entities) {
@ -751,7 +751,7 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public void setFederationProviders(List<UserFederationProviderModel> providers) { public void setUserFederationProviders(List<UserFederationProviderModel> providers) {
List<FederationProviderEntity> newEntities = new ArrayList<FederationProviderEntity>(); List<FederationProviderEntity> newEntities = new ArrayList<FederationProviderEntity>();
int counter = 1; int counter = 1;
for (UserFederationProviderModel model : providers) { for (UserFederationProviderModel model : providers) {

View file

@ -791,7 +791,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
updateRealm(); updateRealm();
} }
@Override @Override
public List<UserFederationProviderModel> getFederationProviders() { public List<UserFederationProviderModel> getUserFederationProviders() {
List<FederationProviderEntity> entities = realm.getFederationProviders(); List<FederationProviderEntity> entities = realm.getFederationProviders();
List<UserFederationProviderModel> result = new ArrayList<UserFederationProviderModel>(); List<UserFederationProviderModel> result = new ArrayList<UserFederationProviderModel>();
for (FederationProviderEntity entity : entities) { for (FederationProviderEntity entity : entities) {
@ -802,7 +802,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
} }
@Override @Override
public void setFederationProviders(List<UserFederationProviderModel> providers) { public void setUserFederationProviders(List<UserFederationProviderModel> providers) {
List<FederationProviderEntity> entities = new ArrayList<FederationProviderEntity>(); List<FederationProviderEntity> entities = new ArrayList<FederationProviderEntity>();
for (UserFederationProviderModel model : providers) { for (UserFederationProviderModel model : providers) {
FederationProviderEntity entity = new FederationProviderEntity(); FederationProviderEntity entity = new FederationProviderEntity();

View file

@ -62,7 +62,7 @@ public class FederationProvidersIntegrationTest {
UserFederationProviderModel ldapProvider = new UserFederationProviderModel(null, LDAPFederationProviderFactory.PROVIDER_NAME, ldapConfig); UserFederationProviderModel ldapProvider = new UserFederationProviderModel(null, LDAPFederationProviderFactory.PROVIDER_NAME, ldapConfig);
appRealm.setFederationProviders(Arrays.asList(ldapProvider)); appRealm.setUserFederationProviders(Arrays.asList(ldapProvider));
// Configure LDAP // Configure LDAP
ldapRule.getEmbeddedServer().setupLdapInRealm(appRealm); ldapRule.getEmbeddedServer().setupLdapInRealm(appRealm);