broker fixes

This commit is contained in:
Bill Burke 2015-03-18 21:58:04 -04:00
parent 3912c60ebc
commit b26277a17c
46 changed files with 336 additions and 469 deletions

View file

@ -117,11 +117,11 @@ public class SAMLIdentityProvider extends AbstractIdentityProvider<SAMLIdentityP
PublicKey publicKey = realm.getPublicKey(); PublicKey publicKey = realm.getPublicKey();
if (privateKey == null) { if (privateKey == null) {
throw new IdentityBrokerException("Identity Provider [" + getConfig().getName() + "] wants a signed authentication request. But the Realm [" + realm.getName() + "] does not have a private key."); throw new IdentityBrokerException("Identity Provider [" + getConfig().getAlias() + "] wants a signed authentication request. But the Realm [" + realm.getName() + "] does not have a private key.");
} }
if (publicKey == null) { if (publicKey == null) {
throw new IdentityBrokerException("Identity Provider [" + getConfig().getName() + "] wants a signed authentication request. But the Realm [" + realm.getName() + "] does not have a public key."); throw new IdentityBrokerException("Identity Provider [" + getConfig().getAlias() + "] wants a signed authentication request. But the Realm [" + realm.getName() + "] does not have a public key.");
} }
KeyPair keypair = new KeyPair(publicKey, privateKey); KeyPair keypair = new KeyPair(publicKey, privateKey);
@ -301,7 +301,7 @@ public class SAMLIdentityProvider extends AbstractIdentityProvider<SAMLIdentityP
authnBinding = JBossSAMLURIConstants.SAML_HTTP_POST_BINDING.get(); authnBinding = JBossSAMLURIConstants.SAML_HTTP_POST_BINDING.get();
} }
String assertionConsumerService = uriInfo.getBaseUriBuilder().path("realms").path(realm.getName()).path("broker").path(getConfig().getId()).build().toString(); String assertionConsumerService = uriInfo.getBaseUriBuilder().path("realms").path(realm.getName()).path("broker").path(getConfig().getAlias()).build().toString();

View file

@ -47,8 +47,7 @@
<constraints nullable="false"/> <constraints nullable="false"/>
</column> </column>
<column name="ENABLED" type="BOOLEAN" defaultValueBoolean="false"/> <column name="ENABLED" type="BOOLEAN" defaultValueBoolean="false"/>
<column name="PROVIDER_NONIMAL_ID" type="VARCHAR(255)"/> <column name="PROVIDER_ALIAS" type="VARCHAR(255)"/>
<column name="PROVIDER_NAME" type="VARCHAR(255)"/>
<column name="PROVIDER_ID" type="VARCHAR(255)"/> <column name="PROVIDER_ID" type="VARCHAR(255)"/>
<column name="UPDATE_PROFILE_FIRST_LOGIN" type="BOOLEAN" defaultValueBoolean="false"/> <column name="UPDATE_PROFILE_FIRST_LOGIN" type="BOOLEAN" defaultValueBoolean="false"/>
<column name="STORE_TOKEN" type="BOOLEAN" defaultValueBoolean="false"/> <column name="STORE_TOKEN" type="BOOLEAN" defaultValueBoolean="false"/>
@ -95,7 +94,7 @@
<addForeignKeyConstraint baseColumnNames="IDENTITY_PROVIDER_ID" baseTableName="CLIENT_IDENTITY_PROVIDER_MAPPING" constraintName="FK_7CELWNIBJI49AVXSRTUF6XJ12" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/> <addForeignKeyConstraint baseColumnNames="IDENTITY_PROVIDER_ID" baseTableName="CLIENT_IDENTITY_PROVIDER_MAPPING" constraintName="FK_7CELWNIBJI49AVXSRTUF6XJ12" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/>
<addForeignKeyConstraint baseColumnNames="CLIENT_ID" baseTableName="CLIENT_IDENTITY_PROVIDER_MAPPING" constraintName="FK_56ELWNIBJI49AVXSRTUF6XJ23" referencedColumnNames="ID" referencedTableName="CLIENT"/> <addForeignKeyConstraint baseColumnNames="CLIENT_ID" baseTableName="CLIENT_IDENTITY_PROVIDER_MAPPING" constraintName="FK_56ELWNIBJI49AVXSRTUF6XJ23" referencedColumnNames="ID" referencedTableName="CLIENT"/>
<addForeignKeyConstraint baseColumnNames="REALM_ID" baseTableName="REALM_SUPPORTED_LOCALES" constraintName="FK_SUPPORTED_LOCALES_REALM" referencedColumnNames="ID" referencedTableName="REALM"/> <addForeignKeyConstraint baseColumnNames="REALM_ID" baseTableName="REALM_SUPPORTED_LOCALES" constraintName="FK_SUPPORTED_LOCALES_REALM" referencedColumnNames="ID" referencedTableName="REALM"/>
<addUniqueConstraint columnNames="PROVIDER_NONIMAL_ID" constraintName="UK_2DAELWNIBJI49AVXSRTUF6XJ33" tableName="IDENTITY_PROVIDER"/> <addUniqueConstraint columnNames="PROVIDER_ALIAS, REALM_ID" constraintName="UK_2DAELWNIBJI49AVXSRTUF6XJ33" tableName="IDENTITY_PROVIDER"/>
<addUniqueConstraint columnNames="IDENTITY_PROVIDER_ID,CLIENT_ID" constraintName="UK_7CAELWNIBJI49AVXSRTUF6XJ12" tableName="CLIENT_IDENTITY_PROVIDER_MAPPING"/> <addUniqueConstraint columnNames="IDENTITY_PROVIDER_ID,CLIENT_ID" constraintName="UK_7CAELWNIBJI49AVXSRTUF6XJ12" tableName="CLIENT_IDENTITY_PROVIDER_MAPPING"/>
<addColumn tableName="REALM"> <addColumn tableName="REALM">

View file

@ -25,15 +25,13 @@ import java.util.Map;
*/ */
public class IdentityProviderRepresentation { public class IdentityProviderRepresentation {
protected String id; protected String alias;
protected String internalId; protected String internalId;
protected String providerId; protected String providerId;
protected String name;
protected boolean enabled = true; protected boolean enabled = true;
protected boolean updateProfileFirstLogin = true; protected boolean updateProfileFirstLogin = true;
protected boolean storeToken; protected boolean storeToken;
protected boolean authenticateByDefault; protected boolean authenticateByDefault;
protected String groupName;
protected Map<String, String> config = new HashMap<String, String>(); protected Map<String, String> config = new HashMap<String, String>();
public String getInternalId() { public String getInternalId() {
@ -44,12 +42,12 @@ public class IdentityProviderRepresentation {
this.internalId = internalId; this.internalId = internalId;
} }
public String getId() { public String getAlias() {
return this.id; return this.alias;
} }
public void setId(String id) { public void setAlias(String alias) {
this.id = id; this.alias = alias;
} }
public String getProviderId() { public String getProviderId() {
@ -60,14 +58,6 @@ public class IdentityProviderRepresentation {
this.providerId = providerId; this.providerId = providerId;
} }
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getConfig() { public Map<String, String> getConfig() {
return this.config; return this.config;
} }
@ -107,12 +97,4 @@ public class IdentityProviderRepresentation {
public void setStoreToken(boolean storeToken) { public void setStoreToken(boolean storeToken) {
this.storeToken = storeToken; this.storeToken = storeToken;
} }
public String getGroupName() {
return this.groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
} }

View file

@ -34,7 +34,7 @@ public class AccountFederatedIdentityBean {
int availableIdentities = 0; int availableIdentities = 0;
if (identityProviders != null && !identityProviders.isEmpty()) { if (identityProviders != null && !identityProviders.isEmpty()) {
for (IdentityProviderModel provider : identityProviders) { for (IdentityProviderModel provider : identityProviders) {
String providerId = provider.getId(); String providerId = provider.getAlias();
FederatedIdentityModel identity = getIdentity(identities, providerId); FederatedIdentityModel identity = getIdentity(identities, providerId);
@ -49,7 +49,7 @@ public class AccountFederatedIdentityBean {
.queryParam("stateChecker", stateChecker) .queryParam("stateChecker", stateChecker)
.build().toString(); .build().toString();
FederatedIdentityEntry entry = new FederatedIdentityEntry(identity, provider.getId(), provider.getName(), actionUrl); FederatedIdentityEntry entry = new FederatedIdentityEntry(identity, provider.getAlias(), actionUrl);
this.identities.add(entry); this.identities.add(entry);
} }
} }
@ -79,13 +79,11 @@ public class AccountFederatedIdentityBean {
private FederatedIdentityModel federatedIdentityModel; private FederatedIdentityModel federatedIdentityModel;
private final String providerId; private final String providerId;
private final String providerName;
private final String actionUrl; private final String actionUrl;
public FederatedIdentityEntry(FederatedIdentityModel federatedIdentityModel, String providerId, String providerName, String actionUrl) { public FederatedIdentityEntry(FederatedIdentityModel federatedIdentityModel, String providerId, String actionUrl) {
this.federatedIdentityModel = federatedIdentityModel; this.federatedIdentityModel = federatedIdentityModel;
this.providerId = providerId; this.providerId = providerId;
this.providerName = providerName;
this.actionUrl = actionUrl; this.actionUrl = actionUrl;
} }
@ -93,10 +91,6 @@ public class AccountFederatedIdentityBean {
return providerId; return providerId;
} }
public String getProviderName() {
return providerName;
}
public String getUserId() { public String getUserId() {
return federatedIdentityModel != null ? federatedIdentityModel.getUserId() : null; return federatedIdentityModel != null ? federatedIdentityModel.getUserId() : null;
} }

View file

@ -170,7 +170,7 @@ module.config([ '$routeProvider', function($routeProvider) {
}, },
controller : 'RealmIdentityProviderCtrl' controller : 'RealmIdentityProviderCtrl'
}) })
.when('/realms/:realm/identity-provider-settings/provider/:provider_id/:id', { .when('/realms/:realm/identity-provider-settings/provider/:provider_id/:alias', {
templateUrl : function(params){ return resourceUrl + '/partials/realm-identity-provider-' + params.provider_id + '.html'; }, templateUrl : function(params){ return resourceUrl + '/partials/realm-identity-provider-' + params.provider_id + '.html'; },
resolve : { resolve : {
realm : function(RealmLoader) { realm : function(RealmLoader) {
@ -188,7 +188,7 @@ module.config([ '$routeProvider', function($routeProvider) {
}, },
controller : 'RealmIdentityProviderCtrl' controller : 'RealmIdentityProviderCtrl'
}) })
.when('/realms/:realm/identity-provider-settings/provider/:provider_id/:id/export', { .when('/realms/:realm/identity-provider-settings/provider/:provider_id/:alias/export', {
templateUrl : resourceUrl + '/partials/realm-identity-provider-export.html', templateUrl : resourceUrl + '/partials/realm-identity-provider-export.html',
resolve : { resolve : {
realm : function(RealmLoader) { realm : function(RealmLoader) {

View file

@ -1183,11 +1183,9 @@ module.controller('ApplicationProtocolMapperCtrl', function($scope, realm, serve
$scope.mapper = angular.copy(mapper); $scope.mapper = angular.copy(mapper);
var oldCopy = angular.copy($scope.realm); var oldCopy = angular.copy($scope.realm);
$scope.changed = false; $scope.changed = false;
$scope.boolval = true;
$scope.boolvalId = 'boolval';
console.log('protocol: ' + protocol); console.log('protocol: ' + protocol);
var protocolMappers = serverInfo.protocolMapperTypes[protocol]; var protocolMappers = serverInfo.protocolMapperTypes[$scope.protocol];
for (var i = 0; i < protocolMappers.length; i++) { for (var i = 0; i < protocolMappers.length; i++) {
if (protocolMappers[i].id == mapper.protocolMapper) { if (protocolMappers[i].id == mapper.protocolMapper) {
$scope.mapperType = protocolMappers[i]; $scope.mapperType = protocolMappers[i];

View file

@ -638,44 +638,93 @@ module.controller('RealmDefaultRolesCtrl', function ($scope, Realm, realm, appli
}); });
module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload, $http, realm, instance, providerFactory, IdentityProvider, serverInfo, $location, Notifications) { module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload, $http, realm, instance, providerFactory, IdentityProvider, serverInfo, $location, Notifications, Dialog) {
console.log('RealmIdentityProviderCtrl'); console.log('RealmIdentityProviderCtrl');
$scope.realm = angular.copy(realm); $scope.realm = angular.copy(realm);
$scope.initSamlProvider = function() {
$scope.nameIdFormats = [
{
format: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
name: "Transient"
},
{
format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
name: "Persistent"
},
{
format: "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
name: "Email"
},
{
format: "urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos",
name: "Kerberos"
},
{
format: "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName",
name: "X.509 Subject Name"
},
{
format: "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName",
name: "Windows Domain Qualified Name"
},
{
format: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
name: "Unspecified"
}
];
if (instance && instance.alias) {
} else {
$scope.identityProvider.config.nameIDPolicyFormat = $scope.nameIdFormats[0].format;
}
}
$scope.hidePassword = true; $scope.hidePassword = true;
$scope.getBoolean = function(value) { if (instance && instance.alias) {
if (value == 'true') {
return true;
} else if (value == 'false') {
return false;
} else {
return value;
}
}
if (instance && instance.id) {
$scope.identityProvider = angular.copy(instance); $scope.identityProvider = angular.copy(instance);
$scope.newIdentityProvider = false; $scope.newIdentityProvider = false;
} else { } else {
$scope.identityProvider = {}; $scope.identityProvider = {};
$scope.identityProvider.config = {}; $scope.identityProvider.config = {};
$scope.identityProvider.id = ""; $scope.identityProvider.alias = providerFactory.name;
$scope.identityProvider.providerId = providerFactory.id; $scope.identityProvider.providerId = providerFactory.id;
$scope.identityProvider.name = providerFactory.name;
$scope.identityProvider.enabled = true; $scope.identityProvider.enabled = true;
$scope.identityProvider.updateProfileFirstLogin = true; $scope.identityProvider.updateProfileFirstLogin = true;
$scope.identityProvider.authenticateByDefault = false; $scope.identityProvider.authenticateByDefault = false;
$scope.newIdentityProvider = true; $scope.newIdentityProvider = true;
} }
$scope.changed = $scope.newIdentityProvider;
$scope.$watch('identityProvider', function() {
if (!angular.equals($scope.identityProvider, instance)) {
$scope.changed = true;
}
}, true);
$scope.serverInfo = serverInfo; $scope.serverInfo = serverInfo;
$scope.allProviders = angular.copy(serverInfo.identityProviders); $scope.allProviders = angular.copy(serverInfo.identityProviders);
$scope.configuredProviders = angular.copy(realm.identityProviders); $scope.configuredProviders = angular.copy(realm.identityProviders);
$scope.$watch(function() {
return $location.path();
}, function() {
$scope.path = $location.path().substring(1).split("/");
});
$scope.files = []; $scope.files = [];
$scope.importFile = false; $scope.importFile = false;
$scope.importUrl = false; $scope.importUrl = false;
@ -689,9 +738,23 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
$scope.importUrl = false; $scope.importUrl = false;
$scope.importFile = false; $scope.importFile = false;
$scope.files = null; $scope.files = null;
};
var setConfig = function(data) {
for (var key in data) {
$scope.identityProvider.config[key] = data[key];
}
} }
$scope.uploadFile = function() { $scope.uploadFile = function() {
if (!$scope.identityProvider.alias) {
Notifications.error("You must specify an alias");
return;
}
var input = {
providerId: providerFactory.id
}
//$files: an array of files selected, each file has name, size, and type. //$files: an array of files selected, each file has name, size, and type.
for (var i = 0; i < $scope.files.length; i++) { for (var i = 0; i < $scope.files.length; i++) {
var $file = $scope.files[i]; var $file = $scope.files[i];
@ -699,7 +762,7 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
url: authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import', url: authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import',
// method: POST or PUT, // method: POST or PUT,
// headers: {'headerKey': 'headerValue'}, withCredential: true, // headers: {'headerKey': 'headerValue'}, withCredential: true,
data: $scope.identityProvider, data: input,
file: $file file: $file
/* set file formData name for 'Content-Desposition' header. Default: 'file' */ /* set file formData name for 'Content-Desposition' header. Default: 'file' */
//fileFormDataName: myFile, //fileFormDataName: myFile,
@ -708,8 +771,9 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
}).progress(function(evt) { }).progress(function(evt) {
console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total)); console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total));
}).success(function(data, status, headers) { }).success(function(data, status, headers) {
$location.url("/realms/" + realm.realm + "/identity-provider-settings"); setConfig(data);
Notifications.success("The " + $scope.identityProvider.name + " provider has been created."); $scope.clearFileSelect();
Notifications.success("The IDP metadata has been loaded from file.");
}).error(function() { }).error(function() {
Notifications.error("The file can not be uploaded. Please verify the file."); Notifications.error("The file can not be uploaded. Please verify the file.");
}); });
@ -717,13 +781,22 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
}; };
$scope.importFrom = function() { $scope.importFrom = function() {
$scope.identityProvider.fromUrl = $scope.fromUrl; if (!$scope.identityProvider.alias) {
$http.post(authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import', $scope.identityProvider) Notifications.error("You must specify an alias");
return;
}
var input = {
fromUrl: $scope.fromUrl,
providerId: providerFactory.id
}
$http.post(authUrl + '/admin/realms/' + realm.realm + '/identity-provider/import-config', input)
.success(function(data, status, headers) { .success(function(data, status, headers) {
$location.url("/realms/" + realm.realm + "/identity-provider-settings"); setConfig(data);
Notifications.success("The " + $scope.identityProvider.name + " provider has been created."); $scope.fromUrl = null;
$scope.importUrl = false;
Notifications.success("Imported config information from url.");
}).error(function() { }).error(function() {
Notifications.error("The provider can not be imported. Please verify the url."); Notifications.error("Config can not be imported. Please verify the url.");
}); });
}; };
$scope.$watch('fromUrl', function(newVal, oldVal){ $scope.$watch('fromUrl', function(newVal, oldVal){
@ -756,24 +829,30 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
$scope.callbackUrl = $location.absUrl().replace(/\/admin.*/, "/realms/") + realm.realm + "/broker/" ; $scope.callbackUrl = $location.absUrl().replace(/\/admin.*/, "/realms/") + realm.realm + "/broker/" ;
$scope.addProvider = function(provider) { $scope.addProvider = function(provider) {
console.log('addProvider');
$location.url("/create/identity-provider/" + realm.realm + "/" + provider.id); $location.url("/create/identity-provider/" + realm.realm + "/" + provider.id);
}; };
$scope.remove = function() { $scope.remove = function() {
IdentityProvider.delete({ Dialog.confirmDelete($scope.identityProvider.alias, 'provider', function() {
realm: $scope.realm.realm, $scope.identityProvider.$remove({
id: $scope.identityProvider.id realm : realm.realm,
}, $scope.identityProvider, function () { alias : $scope.identityProvider.alias
$scope.changed = false; }, function() {
$location.url("/realms/" + realm.realm + "/identity-provider-settings"); $location.url("/realms/" + realm.realm + "/identity-provider-settings");
Notifications.success("The " + $scope.identityProvider.name + " provider has been deleted."); Notifications.success("The application has been deleted.");
});
}); });
}; };
$scope.save = function() { $scope.save = function() {
if ($scope.newIdentityProvider) { if ($scope.newIdentityProvider) {
IdentityProvider.create({ if (!$scope.identityProvider.alias) {
realm: $scope.realm.realm Notifications.error("You must specify an alias");
return;
}
IdentityProvider.save({
realm: $scope.realm.realm, alias: ''
}, $scope.identityProvider, function () { }, $scope.identityProvider, function () {
$location.url("/realms/" + realm.realm + "/identity-provider-settings"); $location.url("/realms/" + realm.realm + "/identity-provider-settings");
Notifications.success("The " + $scope.identityProvider.name + " provider has been created."); Notifications.success("The " + $scope.identityProvider.name + " provider has been created.");
@ -789,6 +868,11 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
} }
}; };
$scope.cancel = function() {
$location.url("/realms/" + realm.realm + "/identity-provider-settings");
};
$scope.reset = function() { $scope.reset = function() {
$scope.identityProvider = {}; $scope.identityProvider = {};
$scope.configuredProviders = angular.copy($scope.realm.identityProviders); $scope.configuredProviders = angular.copy($scope.realm.identityProviders);
@ -798,39 +882,6 @@ module.controller('RealmIdentityProviderCtrl', function($scope, $filter, $upload
$scope.hidePassword = flag; $scope.hidePassword = flag;
}; };
$scope.getBoolean = function(value) {
if (value == 'true') {
return true;
} else if (value == 'false') {
return false;
} else {
return value;
}
}
$scope.initSamlProvider = function() {
if (instance && instance.id) {
$scope.identityProvider.config.validateSignature = $scope.getBoolean($scope.identityProvider.config.validateSignature);
$scope.identityProvider.config.forceAuthn = $scope.getBoolean($scope.identityProvider.config.forceAuthn);
$scope.identityProvider.config.postBindingAuthnRequest = $scope.getBoolean($scope.identityProvider.config.postBindingAuthnRequest);
$scope.identityProvider.config.postBindingResponse = $scope.getBoolean($scope.identityProvider.config.postBindingResponse);
$scope.identityProvider.config.wantAuthnRequestsSigned = $scope.getBoolean($scope.identityProvider.config.wantAuthnRequestsSigned);
} else {
$scope.identityProvider.config.validateSignature = true;
$scope.identityProvider.config.postBindingAuthnRequest = true;
$scope.identityProvider.config.postBindingResponse = true;
$scope.identityProvider.config.wantAuthnRequestsSigned = true;
$scope.identityProvider.config.nameIDPolicyFormat = 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient';
}
}
$scope.initKerberosProvider = function() {
if (instance && instance.id) {
$scope.identityProvider.config.debug = $scope.getBoolean($scope.identityProvider.config.debug);
} else {
$scope.identityProvider.config.debug = false;
}
}
}); });
module.controller('RealmIdentityProviderExportCtrl', function(realm, identityProvider, $scope, $http, IdentityProviderExport) { module.controller('RealmIdentityProviderExportCtrl', function(realm, identityProvider, $scope, $http, IdentityProviderExport) {
@ -840,7 +891,7 @@ module.controller('RealmIdentityProviderExportCtrl', function(realm, identityPro
$scope.exported = ""; $scope.exported = "";
$scope.exportedType = ""; $scope.exportedType = "";
var url = IdentityProviderExport.url({realm: realm.realm, id: identityProvider.id}) ; var url = IdentityProviderExport.url({realm: realm.realm, alias: identityProvider.alias}) ;
$http.get(url).success(function(data, status, headers, config) { $http.get(url).success(function(data, status, headers, config) {
$scope.exportedType = headers('Content-Type'); $scope.exportedType = headers('Content-Type');
$scope.exported = data; $scope.exported = data;

View file

@ -303,7 +303,7 @@ module.factory('IdentityProviderLoader', function(Loader, IdentityProvider, $rou
return Loader.get(IdentityProvider, function () { return Loader.get(IdentityProvider, function () {
return { return {
realm: $route.current.params.realm, realm: $route.current.params.realm,
id: $route.current.params.id alias: $route.current.params.alias
} }
}); });
}); });

View file

@ -1102,15 +1102,10 @@ module.factory('PasswordPolicy', function() {
}); });
module.factory('IdentityProvider', function($resource) { module.factory('IdentityProvider', function($resource) {
return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:id', { return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias', {
realm : '@realm' realm : '@realm',
alias : '@alias'
}, { }, {
create : {
method : 'POST'
},
delete : {
method : 'DELETE'
},
update: { update: {
method : 'PUT' method : 'PUT'
} }
@ -1118,11 +1113,11 @@ module.factory('IdentityProvider', function($resource) {
}); });
module.factory('IdentityProviderExport', function($resource) { module.factory('IdentityProviderExport', function($resource) {
var url = authUrl + '/admin/realms/:realm/identity-provider/instances/:id/export'; var url = authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/export';
return { return {
url : function(parameters) url : function(parameters)
{ {
return url.replace(':realm', parameters.realm).replace(':id', parameters.id); return url.replace(':realm', parameters.realm).replace(':alias', parameters.alias);
} }
} }
}); });

View file

@ -5,10 +5,10 @@
<div id="content"> <div id="content">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Identity Providers</a></li> <li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Identity Providers</a></li>
<li class="active"><a href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.id}}">{{identityProvider.name}} Provider</a></li> <li class="active"><a href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.alias}}">{{identityProvider.alias}} Provider</a></li>
<li class="active">{{identityProvider.name}} Provider Export</li> <li class="active">{{identityProvider.alias}} Provider Export</li>
</ol> </ol>
<h2 class="pull-left">{{identityProvider.name}} Provider Export</h2> <h2 class="pull-left">{{identityProvider.alias}} Provider Export</h2>
<form class="form-horizontal" name="realmForm" novalidate> <form class="form-horizontal" name="realmForm" novalidate>
<fieldset class="border-top"> <fieldset class="border-top">
<div class="form-group"> <div class="form-group">

View file

@ -18,13 +18,6 @@
</div> </div>
<span tooltip-placement="right" tooltip="The alias unique identifies an identity provider and it is also used to build the redirect uri." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip="The alias unique identifies an identity provider and it is also used to build the redirect uri." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group clearfix">
<label class="col-sm-2 control-label" for="name">Name <span class="required">*</span></label>
<div class="col-sm-4">
<input class="form-control" id="name" type="text" ng-model="identityProvider.name" required>
</div>
<span tooltip-placement="right" tooltip="The friendly name for this identity provider." class="fa fa-info-circle"></span>
</div>
<div class="form-group clearfix"> <div class="form-group clearfix">
<label class="col-sm-2 control-label" for="authorizationUrl">Authorization Url <span class="required">*</span></label> <label class="col-sm-2 control-label" for="authorizationUrl">Authorization Url <span class="required">*</span></label>
<div class="col-sm-4"> <div class="col-sm-4">

View file

@ -5,26 +5,19 @@
<div id="content"> <div id="content">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Identity Providers</a></li> <li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Identity Providers</a></li>
<li class="active">{{identityProvider.name}} Provider Settings</li> <li class="active">{{identityProvider.alias}} Provider Settings</li>
</ol> </ol>
<h2 class="pull-left">{{identityProvider.name}} Provider Settings</h2> <h2 class="pull-left">{{identityProvider.alias}} Provider Settings</h2>
<p class="subtitle"><span class="required">*</span> Required fields</p> <p class="subtitle"><span class="required">*</span> Required fields</p>
<form class="form-horizontal" name="realmForm" novalidate> <form class="form-horizontal" name="realmForm" novalidate>
<fieldset> <fieldset>
<div class="form-group clearfix"> <div class="form-group clearfix">
<label class="col-sm-2 control-label" for="identifier">Alias <span class="required">*</span></label> <label class="col-sm-2 control-label" for="identifier">Alias <span class="required">*</span></label>
<div class="col-sm-4"> <div class="col-sm-4">
<input class="form-control" id="identifier" type="text" ng-model="identityProvider.id" data-ng-readonly="!newIdentityProvider" required> <input class="form-control" id="identifier" type="text" ng-model="identityProvider.alias" data-ng-readonly="!newIdentityProvider" required>
</div> </div>
<span tooltip-placement="right" tooltip="The alias unique identifies an identity provider and it is also used to build the redirect uri." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip="The alias unique identifies an identity provider and it is also used to build the redirect uri." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group clearfix">
<label class="col-sm-2 control-label" for="name">Name <span class="required">*</span></label>
<div class="col-sm-4">
<input class="form-control" id="name" type="text" ng-model="identityProvider.name" required>
</div>
<span tooltip-placement="right" tooltip="The friendly name for this identity provider." class="fa fa-info-circle"></span>
</div>
<div class="form-group" data-ng-show="newIdentityProvider && !importFile"> <div class="form-group" data-ng-show="newIdentityProvider && !importFile">
<label class="col-sm-2 control-label" for="fromUrl">Import From Url</label> <label class="col-sm-2 control-label" for="fromUrl">Import From Url</label>
<div class="col-sm-4"> <div class="col-sm-4">
@ -54,14 +47,8 @@
<div class="form-group clearfix" data-ng-show="!importFile && !importUrl"> <div class="form-group clearfix" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="nameIDPolicyFormat">NameID Policy Format</label> <label class="col-sm-2 control-label" for="nameIDPolicyFormat">NameID Policy Format</label>
<div class="col-sm-4"> <div class="col-sm-4">
<select id="nameIDPolicyFormat" ng-model="identityProvider.config.nameIDPolicyFormat"> <select id="nameIDPolicyFormat" ng-model="identityProvider.config.nameIDPolicyFormat"
<option value="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">Transient</option> ng-options="nameFormat.format as nameFormat.name for nameFormat in nameIdFormats">
<option value="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">Persistent</option>
<option value="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">Email</option>
<option value="urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos">Kerberos</option>
<option value="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">X.509 Subject Name</option>
<option value="urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName">Windows Domain Qualified Name</option>
<option value="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">Unspecified</option>
</select> </select>
<!-- <input class="form-control" id="nameIDPolicyFormat" type="text" ng-model="identityProvider.config.nameIDPolicyFormat"> --> <!-- <input class="form-control" id="nameIDPolicyFormat" type="text" ng-model="identityProvider.config.nameIDPolicyFormat"> -->
</div> </div>
@ -77,35 +64,35 @@
<div class="form-group" data-ng-show="!importFile && !importUrl"> <div class="form-group" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="wantAuthnRequestsSigned">Want AuthnRequests Signed</label> <label class="col-sm-2 control-label" for="wantAuthnRequestsSigned">Want AuthnRequests Signed</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="identityProvider.config.wantAuthnRequestsSigned" id="wantAuthnRequestsSigned" onoffswitch /> <input ng-model="identityProvider.config.wantAuthnRequestsSigned" id="wantAuthnRequestsSigned" value="'true'" onoffswitchmodel />
</div> </div>
<span tooltip-placement="right" tooltip=" Indicates whether the identity provider expects signed a AuthnRequest." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip=" Indicates whether the identity provider expects signed a AuthnRequest." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group" data-ng-show="!importFile && !importUrl"> <div class="form-group" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="forceAuthn">Force Authentication</label> <label class="col-sm-2 control-label" for="forceAuthn">Force Authentication</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="identityProvider.config.forceAuthn" id="forceAuthn" onoffswitch /> <input ng-model="identityProvider.config.forceAuthn" id="forceAuthn" value="'true'" onoffswitchmodel />
</div> </div>
<span tooltip-placement="right" tooltip=" Indicates whether the identity provider must authenticate the presenter directly rather than rely on a previous security context." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip=" Indicates whether the identity provider must authenticate the presenter directly rather than rely on a previous security context." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group" data-ng-show="!importFile && !importUrl"> <div class="form-group" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="validateSignature">Validate Signature</label> <label class="col-sm-2 control-label" for="validateSignature">Validate Signature</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="identityProvider.config.validateSignature" id="validateSignature" onoffswitch /> <input ng-model="identityProvider.config.validateSignature" id="validateSignature" value="'true'" onoffswitchmodel />
</div> </div>
<span tooltip-placement="right" tooltip="Enable/disable signature validation of SAML responses." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip="Enable/disable signature validation of SAML responses." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group" data-ng-show="!importFile && !importUrl"> <div class="form-group" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="postBindingResponse">HTTP-POST Binding Response</label> <label class="col-sm-2 control-label" for="postBindingResponse">HTTP-POST Binding Response</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="identityProvider.config.postBindingResponse" id="postBindingResponse" onoffswitch /> <input ng-model="identityProvider.config.postBindingResponse" id="postBindingResponse" value="'true'" onoffswitchmodel />
</div> </div>
<span tooltip-placement="right" tooltip="Indicates whether the identity provider must respond to the AuthnRequest using HTTP-POST binding. If false, HTTP-REDIRECT binding will be used." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip="Indicates whether the identity provider must respond to the AuthnRequest using HTTP-POST binding. If false, HTTP-REDIRECT binding will be used." class="fa fa-info-circle"></span>
</div> </div>
<div class="form-group" data-ng-show="!importFile && !importUrl"> <div class="form-group" data-ng-show="!importFile && !importUrl">
<label class="col-sm-2 control-label" for="postBindingAuthnRequest">HTTP-POST Binding for AuthnRequest</label> <label class="col-sm-2 control-label" for="postBindingAuthnRequest">HTTP-POST Binding for AuthnRequest</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="identityProvider.config.postBindingAuthnRequest" id="postBindingAuthnRequest" onoffswitch /> <input ng-model="identityProvider.config.postBindingAuthnRequest" id="postBindingAuthnRequest" value="'true'" onoffswitchmodel />
</div> </div>
<span tooltip-placement="right" tooltip="Indicates whether the AuthnRequest must be sent using HTTP-POST binding. If false, HTTP-REDIRECT binding will be used." class="fa fa-info-circle"></span> <span tooltip-placement="right" tooltip="Indicates whether the AuthnRequest must be sent using HTTP-POST binding. If false, HTTP-REDIRECT binding will be used." class="fa fa-info-circle"></span>
</div> </div>
@ -140,9 +127,9 @@
</fieldset> </fieldset>
<div class="pull-right form-actions"> <div class="pull-right form-actions">
<a class="btn btn-lg btn-primary" href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.id}}/export" data-ng-show="!importFile && !newIdentityProvider">Export</a> <a class="btn btn-lg btn-primary" href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.alias}}/export" data-ng-show="!importFile && !newIdentityProvider">Export</a>
<button kc-save data-ng-show="!importFile && !importUrl">Save</button> <button kc-save data-ng-show="changed">Save</button>
<button type="submit" data-ng-click="clearFileSelect()" data-ng-show="importFile || importUrl" class="btn btn-lg btn-default">Cancel</button> <button type="submit" data-ng-click="cancel()" data-ng-show="changed" class="btn btn-lg btn-default">Cancel</button>
<button type="submit" data-ng-click="uploadFile()" data-ng-show="importFile" class="btn btn-lg btn-primary">Import</button> <button type="submit" data-ng-click="uploadFile()" data-ng-show="importFile" class="btn btn-lg btn-primary">Import</button>
<button type="submit" data-ng-click="importFrom()" data-ng-show="importUrl" class="btn btn-lg btn-primary">Import</button> <button type="submit" data-ng-click="importFrom()" data-ng-show="importUrl" class="btn btn-lg btn-primary">Import</button>
<button kc-delete data-ng-click="remove()" data-ng-show="!newIdentityProvider">Delete</button> <button kc-delete data-ng-click="remove()" data-ng-show="!newIdentityProvider">Delete</button>

View file

@ -5,26 +5,12 @@
<div id="content"> <div id="content">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Social Providers</a></li> <li><a href="#/realms/{{realm.realm}}/identity-provider-settings">Social Providers</a></li>
<li class="active">{{identityProvider.name}} Settings</li> <li class="active">{{identityProvider.alias}} Settings</li>
</ol> </ol>
<h2 class="pull-left">{{identityProvider.name}} Provider Settings</h2> <h2 class="pull-left">{{identityProvider.alias}} Provider Settings</h2>
<p class="subtitle"><span class="required">*</span> Required fields</p> <p class="subtitle"><span class="required">*</span> Required fields</p>
<form class="form-horizontal" name="realmForm" novalidate> <form class="form-horizontal" name="realmForm" novalidate>
<fieldset> <fieldset>
<div class="form-group clearfix">
<label class="col-sm-2 control-label" for="identifier">Alias <span class="required">*</span></label>
<div class="col-sm-4">
<input class="form-control" id="identifier" type="text" ng-model="identityProvider.id" required>
</div>
<span tooltip-placement="right" tooltip="The alias unique identifies an identity provider and it is also used to build the redirect uri." class="fa fa-info-circle"></span>
</div>
<div class="form-group clearfix">
<label class="col-sm-2 control-label" for="name">Name <span class="required">*</span></label>
<div class="col-sm-4">
<input class="form-control" id="name" type="text" ng-model="identityProvider.name" required>
</div>
<span tooltip-placement="right" tooltip="The friendly name for this identity provider." class="fa fa-info-circle"></span>
</div>
<div class="form-group clearfix"> <div class="form-group clearfix">
<label class="col-sm-2 control-label" for="clientId">Client ID <span class="required">*</span></label> <label class="col-sm-2 control-label" for="clientId">Client ID <span class="required">*</span></label>
<div class="col-sm-4"> <div class="col-sm-4">

View file

@ -4,7 +4,6 @@
<h2></h2> <h2></h2>
<div id="content"> <div id="content">
<h2 class="pull-left"><span>{{realm.realm}}</span> Identity Providers Settings</h2> <h2 class="pull-left"><span>{{realm.realm}}</span> Identity Providers Settings</h2>
<p class="subtitle"><span class="required">*</span> Required fields</p>
<form name="realmForm" novalidate class="form-horizontal"> <form name="realmForm" novalidate class="form-horizontal">
<fieldset> <fieldset>
@ -18,7 +17,6 @@
<div class="select-kc"> <div class="select-kc">
<select ng-model="provider" <select ng-model="provider"
ng-options="p.name group by p.groupName for p in allProviders track by p.id" ng-options="p.name group by p.groupName for p in allProviders track by p.id"
ng-
data-ng-change="addProvider(provider); provider = null"> data-ng-change="addProvider(provider); provider = null">
<option value="" disabled selected>Add provider...</option> <option value="" disabled selected>Add provider...</option>
</select> </select>
@ -28,27 +26,22 @@
</tr> </tr>
<tr ng-show="configuredProviders.length > 0"> <tr ng-show="configuredProviders.length > 0">
<th>Name</th> <th>Name</th>
<th>Redirect URI</th> <th>Callback URI</th>
</tr> </tr>
</thead> </thead>
<tbody ng-show="configuredProviders.length > 0"> <tbody ng-show="configuredProviders.length > 0">
<tr ng-repeat="identityProvider in configuredProviders"> <tr ng-repeat="identityProvider in configuredProviders">
<td> <td>
<a href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.id}}">{{identityProvider.name}}</a> <a href="#/realms/{{realm.realm}}/identity-provider-settings/provider/{{identityProvider.providerId}}/{{identityProvider.alias}}">{{identityProvider.alias}}</a>
</td> </td>
<td ng-show="!changed"> <td>
{{callbackUrl}}{{identityProvider.id}} {{callbackUrl}}{{identityProvider.alias}}
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</fieldset> </fieldset>
<div class="pull-right form-actions">
<button type="submit" kc-reset data-ng-show="changed">Clear changes</button>
<button type="submit" kc-save class="primary" data-ng-show="changed">Save changes</button>
</div>
</form> </form>
</div> </div>
</div> </div>

View file

@ -1,6 +1,6 @@
<ul data-ng-hide="createRealm"> <ul data-ng-hide="createRealm">
<li data-ng-show="access.viewRealm" data-ng-class="((!path[2] || <li data-ng-show="access.viewRealm" data-ng-class="((!path[2] ||
path[2] == 'social-settings' || path[2] == 'required-credentials' path[2] == 'identity-provider-settings' || path[2] == 'required-credentials'
|| path[2] == 'login-settings' || path[2] == 'login-settings'
|| path[2] == 'theme-settings' || path[2] == 'theme-settings'
|| path[2] == 'cache-settings' || path[2] == 'cache-settings'

View file

@ -75,7 +75,7 @@
<div id="kc-social-providers"> <div id="kc-social-providers">
<ul> <ul>
<#list social.providers as p> <#list social.providers as p>
<li><a href="${p.loginUrl}" id="zocial-${p.id}" class="zocial ${p.providerId}"> <span class="text">${p.name}</span></a></li> <li><a href="${p.loginUrl}" id="zocial-${p.alias}" class="zocial ${p.providerId}"> <span class="text">${p.alias}</span></a></li>
</#list> </#list>
</ul> </ul>
</div> </div>

View file

@ -64,8 +64,8 @@ public class IdentityProviderBean {
} }
private void addIdentityProvider(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) { private void addIdentityProvider(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) {
String loginUrl = Urls.identityProviderAuthnRequest(baseURI, identityProvider.getId(), realm.getName()).toString(); String loginUrl = Urls.identityProviderAuthnRequest(baseURI, identityProvider.getAlias(), realm.getName()).toString();
providers.add(new IdentityProvider(identityProvider.getId(), identityProvider.getProviderId(), identityProvider.getName(), loginUrl)); providers.add(new IdentityProvider(identityProvider.getAlias(), identityProvider.getProviderId(), loginUrl));
} }
public List<IdentityProvider> getProviders() { public List<IdentityProvider> getProviders() {
@ -78,29 +78,19 @@ public class IdentityProviderBean {
public static class IdentityProvider { public static class IdentityProvider {
private final String id; private final String alias;
private final String providerId; // This refer to providerType (facebook, google, etc.) private final String providerId; // This refer to providerType (facebook, google, etc.)
private final String name;
private final String loginUrl; private final String loginUrl;
public IdentityProvider(String id, String providerId, String name, String loginUrl) { public IdentityProvider(String alias, String providerId,String loginUrl) {
this.id = id; this.alias = alias;
this.providerId = providerId; this.providerId = providerId;
if (name == null) {
name = id;
}
this.name = name;
this.loginUrl = loginUrl; this.loginUrl = loginUrl;
} }
public String getId() { public String getAlias() {
return id; return alias;
}
public String getName() {
return name;
} }
public String getLoginUrl() { public String getLoginUrl() {

View file

@ -20,10 +20,12 @@ public interface IdentityProvidersResource {
IdentityProviderResource get(@PathParam("id") String id); IdentityProviderResource get(@PathParam("id") String id);
@GET @GET
@Path("instances")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
List<IdentityProviderRepresentation> findAll(); List<IdentityProviderRepresentation> findAll();
@POST @POST
@Path("instances")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
void create(IdentityProviderRepresentation identityProvider); void create(IdentityProviderRepresentation identityProvider);
} }

View file

@ -33,7 +33,7 @@ public class IdentityProviderModel {
/** /**
* <p>An user-defined identifier to unique identify an identity provider instance.</p> * <p>An user-defined identifier to unique identify an identity provider instance.</p>
*/ */
private String id; private String alias;
/** /**
* <p>An identifier used to reference a specific identity provider implementation. The value of this field is the same * <p>An identifier used to reference a specific identity provider implementation. The value of this field is the same
@ -41,11 +41,6 @@ public class IdentityProviderModel {
*/ */
private String providerId; private String providerId;
/**
* <p>An user-defined friendly name for an identity provider instance.</p>
*/
private String name;
private boolean enabled; private boolean enabled;
private boolean updateProfileFirstLogin = true; private boolean updateProfileFirstLogin = true;
@ -69,8 +64,7 @@ public class IdentityProviderModel {
public IdentityProviderModel(IdentityProviderModel model) { public IdentityProviderModel(IdentityProviderModel model) {
this.internalId = model.getInternalId(); this.internalId = model.getInternalId();
this.providerId = model.getProviderId(); this.providerId = model.getProviderId();
this.id = model.getId(); this.alias = model.getAlias();
this.name = model.getName();
this.config = new HashMap<String, String>(model.getConfig()); this.config = new HashMap<String, String>(model.getConfig());
this.enabled = model.isEnabled(); this.enabled = model.isEnabled();
this.updateProfileFirstLogin = model.isUpdateProfileFirstLogin(); this.updateProfileFirstLogin = model.isUpdateProfileFirstLogin();
@ -86,12 +80,12 @@ public class IdentityProviderModel {
this.internalId = internalId; this.internalId = internalId;
} }
public String getId() { public String getAlias() {
return this.id; return this.alias;
} }
public void setId(String id) { public void setAlias(String id) {
this.id = id; this.alias = id;
} }
public String getProviderId() { public String getProviderId() {
@ -102,14 +96,6 @@ public class IdentityProviderModel {
this.providerId = providerId; this.providerId = providerId;
} }
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public boolean isEnabled() { public boolean isEnabled() {
return this.enabled; return this.enabled;
} }

View file

@ -185,9 +185,9 @@ public interface RealmModel extends RoleContainerModel {
void setSmtpConfig(Map<String, String> smtpConfig); void setSmtpConfig(Map<String, String> smtpConfig);
List<IdentityProviderModel> getIdentityProviders(); List<IdentityProviderModel> getIdentityProviders();
IdentityProviderModel getIdentityProviderById(String identityProviderId); IdentityProviderModel getIdentityProviderByAlias(String alias);
void addIdentityProvider(IdentityProviderModel identityProvider); void addIdentityProvider(IdentityProviderModel identityProvider);
void removeIdentityProviderById(String providerId); void removeIdentityProviderByAlias(String alias);
void updateIdentityProvider(IdentityProviderModel identityProvider); void updateIdentityProvider(IdentityProviderModel identityProvider);
List<UserFederationProviderModel> getUserFederationProviders(); List<UserFederationProviderModel> getUserFederationProviders();

View file

@ -26,7 +26,7 @@ import java.util.Map;
public class IdentityProviderEntity { public class IdentityProviderEntity {
private String internalId; private String internalId;
private String id; private String alias;
private String providerId; private String providerId;
private String name; private String name;
private boolean enabled; private boolean enabled;
@ -92,12 +92,12 @@ public class IdentityProviderEntity {
this.providerId = providerId; this.providerId = providerId;
} }
public String getId() { public String getAlias() {
return id; return alias;
} }
public void setId(String providerNonimalId) { public void setAlias(String alias) {
this.id = providerNonimalId; this.alias = alias;
} }
public Map<String, String> getConfig() { public Map<String, String> getConfig() {

View file

@ -344,8 +344,7 @@ public class ModelToRepresentation {
providerRep.setInternalId(identityProviderModel.getInternalId()); providerRep.setInternalId(identityProviderModel.getInternalId());
providerRep.setProviderId(identityProviderModel.getProviderId()); providerRep.setProviderId(identityProviderModel.getProviderId());
providerRep.setId(identityProviderModel.getId()); providerRep.setAlias(identityProviderModel.getAlias());
providerRep.setName(identityProviderModel.getName());
providerRep.setEnabled(identityProviderModel.isEnabled()); providerRep.setEnabled(identityProviderModel.isEnabled());
providerRep.setStoreToken(identityProviderModel.isStoreToken()); providerRep.setStoreToken(identityProviderModel.isStoreToken());
providerRep.setUpdateProfileFirstLogin(identityProviderModel.isUpdateProfileFirstLogin()); providerRep.setUpdateProfileFirstLogin(identityProviderModel.isUpdateProfileFirstLogin());

View file

@ -793,9 +793,8 @@ public class RepresentationToModel {
IdentityProviderModel identityProviderModel = new IdentityProviderModel(); IdentityProviderModel identityProviderModel = new IdentityProviderModel();
identityProviderModel.setInternalId(representation.getInternalId()); identityProviderModel.setInternalId(representation.getInternalId());
identityProviderModel.setId(representation.getId()); identityProviderModel.setAlias(representation.getAlias());
identityProviderModel.setProviderId(representation.getProviderId()); identityProviderModel.setProviderId(representation.getProviderId());
identityProviderModel.setName(representation.getName());
identityProviderModel.setEnabled(representation.isEnabled()); identityProviderModel.setEnabled(representation.isEnabled());
identityProviderModel.setUpdateProfileFirstLogin(representation.isUpdateProfileFirstLogin()); identityProviderModel.setUpdateProfileFirstLogin(representation.isUpdateProfileFirstLogin());
identityProviderModel.setAuthenticateByDefault(representation.isAuthenticateByDefault()); identityProviderModel.setAuthenticateByDefault(representation.isAuthenticateByDefault());

View file

@ -871,9 +871,9 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public IdentityProviderModel getIdentityProviderById(String identityProviderId) { public IdentityProviderModel getIdentityProviderByAlias(String alias) {
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) { for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
if (identityProviderModel.getId().equals(identityProviderId)) { if (identityProviderModel.getAlias().equals(alias)) {
return identityProviderModel; return identityProviderModel;
} }
} }
@ -883,15 +883,15 @@ public class RealmAdapter implements RealmModel {
@Override @Override
public void addIdentityProvider(IdentityProviderModel identityProvider) { public void addIdentityProvider(IdentityProviderModel identityProvider) {
if (identityProvider.getId() == null) throw new NullPointerException("identityProvider.getId() == null"); if (identityProvider.getAlias() == null) throw new NullPointerException("identityProvider.getAlias() == null");
if (identityProvider.getInternalId() == null) identityProvider.setInternalId(KeycloakModelUtils.generateId()); if (identityProvider.getInternalId() == null) identityProvider.setInternalId(KeycloakModelUtils.generateId());
allIdProviders.put(identityProvider.getInternalId(), identityProvider); allIdProviders.put(identityProvider.getInternalId(), identityProvider);
} }
@Override @Override
public void removeIdentityProviderById(String providerId) { public void removeIdentityProviderByAlias(String alias) {
for (IdentityProviderModel provider : getIdentityProviders()) { for (IdentityProviderModel provider : getIdentityProviders()) {
if (provider.getId().equals(providerId)) { if (provider.getAlias().equals(alias)) {
allIdProviders.remove(provider.getInternalId()); allIdProviders.remove(provider.getInternalId());
break; break;
} }
@ -900,7 +900,7 @@ public class RealmAdapter implements RealmModel {
@Override @Override
public void updateIdentityProvider(IdentityProviderModel identityProvider) { public void updateIdentityProvider(IdentityProviderModel identityProvider) {
removeIdentityProviderById(identityProvider.getId()); removeIdentityProviderByAlias(identityProvider.getAlias());
addIdentityProvider(identityProvider); addIdentityProvider(identityProvider);
} }

View file

@ -643,9 +643,9 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public IdentityProviderModel getIdentityProviderById(String identityProviderId) { public IdentityProviderModel getIdentityProviderByAlias(String alias) {
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) { for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
if (identityProviderModel.getId().equals(identityProviderId)) { if (identityProviderModel.getAlias().equals(alias)) {
return identityProviderModel; return identityProviderModel;
} }
} }
@ -666,9 +666,9 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public void removeIdentityProviderById(String providerId) { public void removeIdentityProviderByAlias(String alias) {
getDelegateForUpdate(); getDelegateForUpdate();
updated.removeIdentityProviderById(providerId); updated.removeIdentityProviderByAlias(alias);
} }
@Override @Override

View file

@ -317,7 +317,7 @@ public abstract class ClientAdapter implements ClientModel {
boolean toRemove = true; boolean toRemove = true;
for (ClientIdentityProviderMappingModel model : identityProviders) { for (ClientIdentityProviderMappingModel model : identityProviders) {
if (model.getIdentityProvider().equals(identityProvider.getId())) { if (model.getIdentityProvider().equals(identityProvider.getAlias())) {
toRemove = false; toRemove = false;
break; break;
} }
@ -326,7 +326,7 @@ public abstract class ClientAdapter implements ClientModel {
if (toRemove) { if (toRemove) {
remove.add(entity); remove.add(entity);
} else { } else {
already.add(entity.getIdentityProvider().getId()); already.add(entity.getIdentityProvider().getAlias());
} }
} }
for (ClientIdentityProviderMappingEntity entity : remove) { for (ClientIdentityProviderMappingEntity entity : remove) {
@ -342,14 +342,14 @@ public abstract class ClientAdapter implements ClientModel {
entities.add(mappingEntity); entities.add(mappingEntity);
} else { } else {
for (ClientIdentityProviderMappingEntity entity : entities) { for (ClientIdentityProviderMappingEntity entity : entities) {
if (entity.getIdentityProvider().getId().equals(model.getIdentityProvider())) { if (entity.getIdentityProvider().getAlias().equals(model.getIdentityProvider())) {
mappingEntity = entity; mappingEntity = entity;
break; break;
} }
} }
} }
TypedQuery<IdentityProviderEntity> query = em.createNamedQuery("findIdentityProviderById", IdentityProviderEntity.class).setParameter("id", model.getIdentityProvider()); TypedQuery<IdentityProviderEntity> query = em.createNamedQuery("findIdentityProviderByAlias", IdentityProviderEntity.class).setParameter("alias", model.getIdentityProvider());
IdentityProviderEntity identityProviderEntity = query.getSingleResult(); IdentityProviderEntity identityProviderEntity = query.getSingleResult();
mappingEntity.setIdentityProvider(identityProviderEntity); mappingEntity.setIdentityProvider(identityProviderEntity);
@ -368,7 +368,7 @@ public abstract class ClientAdapter implements ClientModel {
for (ClientIdentityProviderMappingEntity entity : this.entity.getIdentityProviders()) { for (ClientIdentityProviderMappingEntity entity : this.entity.getIdentityProviders()) {
ClientIdentityProviderMappingModel model = new ClientIdentityProviderMappingModel(); ClientIdentityProviderMappingModel model = new ClientIdentityProviderMappingModel();
model.setIdentityProvider(entity.getIdentityProvider().getId()); model.setIdentityProvider(entity.getIdentityProvider().getAlias());
model.setRetrieveToken(entity.isRetrieveToken()); model.setRetrieveToken(entity.isRetrieveToken());
models.add(model); models.add(model);

View file

@ -1160,9 +1160,8 @@ public class RealmAdapter implements RealmModel {
IdentityProviderModel identityProviderModel = new IdentityProviderModel(); IdentityProviderModel identityProviderModel = new IdentityProviderModel();
identityProviderModel.setProviderId(entity.getProviderId()); identityProviderModel.setProviderId(entity.getProviderId());
identityProviderModel.setId(entity.getId()); identityProviderModel.setAlias(entity.getAlias());
identityProviderModel.setInternalId(entity.getInternalId()); identityProviderModel.setInternalId(entity.getInternalId());
identityProviderModel.setName(entity.getName());
identityProviderModel.setConfig(entity.getConfig()); identityProviderModel.setConfig(entity.getConfig());
identityProviderModel.setEnabled(entity.isEnabled()); identityProviderModel.setEnabled(entity.isEnabled());
identityProviderModel.setUpdateProfileFirstLogin(entity.isUpdateProfileFirstLogin()); identityProviderModel.setUpdateProfileFirstLogin(entity.isUpdateProfileFirstLogin());
@ -1176,9 +1175,9 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public IdentityProviderModel getIdentityProviderById(String identityProviderId) { public IdentityProviderModel getIdentityProviderByAlias(String alias) {
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) { for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
if (identityProviderModel.getId().equals(identityProviderId)) { if (identityProviderModel.getAlias().equals(alias)) {
return identityProviderModel; return identityProviderModel;
} }
} }
@ -1191,9 +1190,8 @@ public class RealmAdapter implements RealmModel {
IdentityProviderEntity entity = new IdentityProviderEntity(); IdentityProviderEntity entity = new IdentityProviderEntity();
entity.setInternalId(KeycloakModelUtils.generateId()); entity.setInternalId(KeycloakModelUtils.generateId());
entity.setId(identityProvider.getId()); entity.setAlias(identityProvider.getAlias());
entity.setProviderId(identityProvider.getProviderId()); entity.setProviderId(identityProvider.getProviderId());
entity.setName(identityProvider.getName());
entity.setEnabled(identityProvider.isEnabled()); entity.setEnabled(identityProvider.isEnabled());
entity.setStoreToken(identityProvider.isStoreToken()); entity.setStoreToken(identityProvider.isStoreToken());
entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin());
@ -1207,9 +1205,9 @@ public class RealmAdapter implements RealmModel {
} }
@Override @Override
public void removeIdentityProviderById(String providerId) { public void removeIdentityProviderByAlias(String alias) {
for (IdentityProviderEntity entity : realm.getIdentityProviders()) { for (IdentityProviderEntity entity : realm.getIdentityProviders()) {
if (entity.getId().equals(providerId)) { if (entity.getAlias().equals(alias)) {
em.remove(entity); em.remove(entity);
em.flush(); em.flush();
} }
@ -1220,8 +1218,7 @@ public class RealmAdapter implements RealmModel {
public void updateIdentityProvider(IdentityProviderModel identityProvider) { public void updateIdentityProvider(IdentityProviderModel identityProvider) {
for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) { for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) {
if (entity.getInternalId().equals(identityProvider.getInternalId())) { if (entity.getInternalId().equals(identityProvider.getInternalId())) {
entity.setId(identityProvider.getId()); entity.setAlias(identityProvider.getAlias());
entity.setName(identityProvider.getName());
entity.setEnabled(identityProvider.isEnabled()); entity.setEnabled(identityProvider.isEnabled());
entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin());
entity.setAuthenticateByDefault(identityProvider.isAuthenticateByDefault()); entity.setAuthenticateByDefault(identityProvider.isAuthenticateByDefault());

View file

@ -83,7 +83,7 @@ public class ClientIdentityProviderMappingEntity {
Key key = (Key) o; Key key = (Key) o;
if (identityProvider != null ? !identityProvider.getId().equals(key.identityProvider.getId()) : key.identityProvider != null) if (identityProvider != null ? !identityProvider.getAlias().equals(key.identityProvider.getAlias()) : key.identityProvider != null)
return false; return false;
if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false; if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false;
@ -105,7 +105,7 @@ public class ClientIdentityProviderMappingEntity {
ClientIdentityProviderMappingEntity key = (ClientIdentityProviderMappingEntity) o; ClientIdentityProviderMappingEntity key = (ClientIdentityProviderMappingEntity) o;
if (identityProvider != null ? !identityProvider.getId().equals(key.identityProvider.getId()) : key.identityProvider != null) if (identityProvider != null ? !identityProvider.getAlias().equals(key.identityProvider.getAlias()) : key.identityProvider != null)
return false; return false;
if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false; if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false;

View file

@ -20,7 +20,7 @@ import java.util.Map;
@Entity @Entity
@Table(name="IDENTITY_PROVIDER") @Table(name="IDENTITY_PROVIDER")
@NamedQueries({ @NamedQueries({
@NamedQuery(name="findIdentityProviderById", query="select identityProvider from IdentityProviderEntity identityProvider where identityProvider.id = :id") @NamedQuery(name="findIdentityProviderByAlias", query="select identityProvider from IdentityProviderEntity identityProvider where identityProvider.alias = :alias")
}) })
public class IdentityProviderEntity { public class IdentityProviderEntity {
@ -35,11 +35,8 @@ public class IdentityProviderEntity {
@Column(name="PROVIDER_ID") @Column(name="PROVIDER_ID")
private String providerId; private String providerId;
@Column(name="PROVIDER_NONIMAL_ID") @Column(name="PROVIDER_ALIAS")
private String id; private String alias;
@Column(name="PROVIDER_NAME")
private String name;
@Column(name="ENABLED") @Column(name="ENABLED")
private boolean enabled; private boolean enabled;
@ -83,20 +80,12 @@ public class IdentityProviderEntity {
this.realm = realm; this.realm = realm;
} }
public String getId() { public String getAlias() {
return this.id; return this.alias;
} }
public void setId(String id) { public void setAlias(String alias) {
this.id = id; this.alias = alias;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
} }
public boolean isEnabled() { public boolean isEnabled() {

View file

@ -833,9 +833,8 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
IdentityProviderModel identityProviderModel = new IdentityProviderModel(); IdentityProviderModel identityProviderModel = new IdentityProviderModel();
identityProviderModel.setProviderId(entity.getProviderId()); identityProviderModel.setProviderId(entity.getProviderId());
identityProviderModel.setId(entity.getId()); identityProviderModel.setAlias(entity.getAlias());
identityProviderModel.setInternalId(entity.getInternalId()); identityProviderModel.setInternalId(entity.getInternalId());
identityProviderModel.setName(entity.getName());
identityProviderModel.setConfig(entity.getConfig()); identityProviderModel.setConfig(entity.getConfig());
identityProviderModel.setEnabled(entity.isEnabled()); identityProviderModel.setEnabled(entity.isEnabled());
identityProviderModel.setUpdateProfileFirstLogin(entity.isUpdateProfileFirstLogin()); identityProviderModel.setUpdateProfileFirstLogin(entity.isUpdateProfileFirstLogin());
@ -849,9 +848,9 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
} }
@Override @Override
public IdentityProviderModel getIdentityProviderById(String identityProviderId) { public IdentityProviderModel getIdentityProviderByAlias(String alias) {
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) { for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
if (identityProviderModel.getId().equals(identityProviderId)) { if (identityProviderModel.getAlias().equals(alias)) {
return identityProviderModel; return identityProviderModel;
} }
} }
@ -864,9 +863,8 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
IdentityProviderEntity entity = new IdentityProviderEntity(); IdentityProviderEntity entity = new IdentityProviderEntity();
entity.setInternalId(KeycloakModelUtils.generateId()); entity.setInternalId(KeycloakModelUtils.generateId());
entity.setId(identityProvider.getId()); entity.setAlias(identityProvider.getAlias());
entity.setProviderId(identityProvider.getProviderId()); entity.setProviderId(identityProvider.getProviderId());
entity.setName(identityProvider.getName());
entity.setEnabled(identityProvider.isEnabled()); entity.setEnabled(identityProvider.isEnabled());
entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin());
entity.setStoreToken(identityProvider.isStoreToken()); entity.setStoreToken(identityProvider.isStoreToken());
@ -878,10 +876,10 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
} }
@Override @Override
public void removeIdentityProviderById(String providerId) { public void removeIdentityProviderByAlias(String alias) {
IdentityProviderEntity toRemove; IdentityProviderEntity toRemove;
for (IdentityProviderEntity entity : realm.getIdentityProviders()) { for (IdentityProviderEntity entity : realm.getIdentityProviders()) {
if (entity.getId().equals(providerId)) { if (entity.getAlias().equals(alias)) {
realm.getIdentityProviders().remove(entity); realm.getIdentityProviders().remove(entity);
updateRealm(); updateRealm();
break; break;
@ -893,8 +891,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
public void updateIdentityProvider(IdentityProviderModel identityProvider) { public void updateIdentityProvider(IdentityProviderModel identityProvider) {
for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) { for (IdentityProviderEntity entity : this.realm.getIdentityProviders()) {
if (entity.getInternalId().equals(identityProvider.getInternalId())) { if (entity.getInternalId().equals(identityProvider.getInternalId())) {
entity.setId(identityProvider.getId()); entity.setAlias(identityProvider.getAlias());
entity.setName(identityProvider.getName());
entity.setEnabled(identityProvider.isEnabled()); entity.setEnabled(identityProvider.isEnabled());
entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin()); entity.setUpdateProfileFirstLogin(identityProvider.isUpdateProfileFirstLogin());
entity.setAuthenticateByDefault(identityProvider.isAuthenticateByDefault()); entity.setAuthenticateByDefault(identityProvider.isAuthenticateByDefault());

View file

@ -235,7 +235,7 @@ public class AuthorizationEndpoint {
String accessCode = new ClientSessionCode(realm, clientSession).getCode(); String accessCode = new ClientSessionCode(realm, clientSession).getCode();
if (idpHint != null && !"".equals(idpHint)) { if (idpHint != null && !"".equals(idpHint)) {
IdentityProviderModel identityProviderModel = realm.getIdentityProviderById(idpHint); IdentityProviderModel identityProviderModel = realm.getIdentityProviderByAlias(idpHint);
if (identityProviderModel == null) { if (identityProviderModel == null) {
return Flows.forms(session, realm, null, uriInfo, headers) return Flows.forms(session, realm, null, uriInfo, headers)
@ -261,7 +261,7 @@ public class AuthorizationEndpoint {
List<IdentityProviderModel> identityProviders = realm.getIdentityProviders(); List<IdentityProviderModel> identityProviders = realm.getIdentityProviders();
for (IdentityProviderModel identityProvider : identityProviders) { for (IdentityProviderModel identityProvider : identityProviders) {
if (identityProvider.isAuthenticateByDefault()) { if (identityProvider.isAuthenticateByDefault()) {
return buildRedirectToIdentityProvider(identityProvider.getId(), accessCode); return buildRedirectToIdentityProvider(identityProvider.getAlias(), accessCode);
} }
} }
@ -269,7 +269,7 @@ public class AuthorizationEndpoint {
if (requiredCredentials.isEmpty()) { if (requiredCredentials.isEmpty()) {
if (!identityProviders.isEmpty()) { if (!identityProviders.isEmpty()) {
if (identityProviders.size() == 1) { if (identityProviders.size() == 1) {
return buildRedirectToIdentityProvider(identityProviders.get(0).getId(), accessCode); return buildRedirectToIdentityProvider(identityProviders.get(0).getAlias(), accessCode);
} }
return Flows.forms(session, realm, null, uriInfo, headers).setError(Messages.IDENTITY_PROVIDER_NOT_UNIQUE, realm.getName()).createErrorPage(); return Flows.forms(session, realm, null, uriInfo, headers).setError(Messages.IDENTITY_PROVIDER_NOT_UNIQUE, realm.getName()).createErrorPage();

View file

@ -652,7 +652,7 @@ public class AccountService {
boolean hasProvider = false; boolean hasProvider = false;
for (IdentityProviderModel model : realm.getIdentityProviders()) { for (IdentityProviderModel model : realm.getIdentityProviders()) {
if (model.getId().equals(providerId)) { if (model.getAlias().equals(providerId)) {
hasProvider = true; hasProvider = true;
} }
} }

View file

@ -296,7 +296,7 @@ public class IdentityBrokerService {
private Response performLocalAuthentication(FederatedIdentity updatedIdentity, ClientSessionCode clientCode) { private Response performLocalAuthentication(FederatedIdentity updatedIdentity, ClientSessionCode clientCode) {
ClientSessionModel clientSession = clientCode.getClientSession(); ClientSessionModel clientSession = clientCode.getClientSession();
IdentityProviderModel identityProviderConfig = getIdentityProviderConfig(updatedIdentity.getIdentityProviderId()); IdentityProviderModel identityProviderConfig = getIdentityProviderConfig(updatedIdentity.getIdentityProviderId());
String providerId = identityProviderConfig.getId(); String providerId = identityProviderConfig.getAlias();
FederatedIdentityModel federatedIdentityModel = new FederatedIdentityModel(providerId, updatedIdentity.getId(), FederatedIdentityModel federatedIdentityModel = new FederatedIdentityModel(providerId, updatedIdentity.getId(),
updatedIdentity.getUsername(), updatedIdentity.getToken()); updatedIdentity.getUsername(), updatedIdentity.getToken());
@ -465,20 +465,20 @@ public class IdentityBrokerService {
return Flows.errors().error(message, Status.BAD_REQUEST); return Flows.errors().error(message, Status.BAD_REQUEST);
} }
private IdentityProvider getIdentityProvider(String providerId) { private IdentityProvider getIdentityProvider(String alias) {
IdentityProviderModel identityProviderModel = this.realmModel.getIdentityProviderById(providerId); IdentityProviderModel identityProviderModel = this.realmModel.getIdentityProviderByAlias(alias);
if (identityProviderModel != null) { if (identityProviderModel != null) {
IdentityProviderFactory providerFactory = getIdentityProviderFactory(identityProviderModel); IdentityProviderFactory providerFactory = getIdentityProviderFactory(identityProviderModel);
if (providerFactory == null) { if (providerFactory == null) {
throw new IdentityBrokerException("Could not find factory for identity provider [" + providerId + "]."); throw new IdentityBrokerException("Could not find factory for identity provider [" + alias + "].");
} }
return providerFactory.create(identityProviderModel); return providerFactory.create(identityProviderModel);
} }
throw new IdentityBrokerException("Identity Provider [" + providerId + "] not found."); throw new IdentityBrokerException("Identity Provider [" + alias + "] not found.");
} }
private IdentityProviderFactory getIdentityProviderFactory(IdentityProviderModel model) { private IdentityProviderFactory getIdentityProviderFactory(IdentityProviderModel model) {
@ -497,7 +497,7 @@ public class IdentityBrokerService {
private IdentityProviderModel getIdentityProviderConfig(String providerId) { private IdentityProviderModel getIdentityProviderConfig(String providerId) {
for (IdentityProviderModel model : this.realmModel.getIdentityProviders()) { for (IdentityProviderModel model : this.realmModel.getIdentityProviders()) {
if (model.getId().equals(providerId)) { if (model.getAlias().equals(providerId)) {
return model; return model;
} }
} }

View file

@ -64,7 +64,7 @@ public class IdentityProviderResource {
this.auth.requireManage(); this.auth.requireManage();
removeClientIdentityProviders(this.realm.getApplications(), this.identityProviderModel); removeClientIdentityProviders(this.realm.getApplications(), this.identityProviderModel);
removeClientIdentityProviders(this.realm.getOAuthClients(), this.identityProviderModel); removeClientIdentityProviders(this.realm.getOAuthClients(), this.identityProviderModel);
this.realm.removeIdentityProviderById(this.identityProviderModel.getId()); this.realm.removeIdentityProviderByAlias(this.identityProviderModel.getAlias());
return Response.noContent().build(); return Response.noContent().build();
} }
@ -75,7 +75,7 @@ public class IdentityProviderResource {
this.auth.requireManage(); this.auth.requireManage();
String internalId = providerRep.getInternalId(); String internalId = providerRep.getInternalId();
String newProviderId = providerRep.getId(); String newProviderId = providerRep.getAlias();
String oldProviderId = getProviderIdByInternalId(this.realm, internalId); String oldProviderId = getProviderIdByInternalId(this.realm, internalId);
this.realm.updateIdentityProvider(RepresentationToModel.toModel(providerRep)); this.realm.updateIdentityProvider(RepresentationToModel.toModel(providerRep));
@ -92,7 +92,7 @@ public class IdentityProviderResource {
return Response.noContent().build(); return Response.noContent().build();
} catch (ModelDuplicateException e) { } catch (ModelDuplicateException e) {
return Flows.errors().exists("Identity Provider " + providerRep.getId() + " already exists"); return Flows.errors().exists("Identity Provider " + providerRep.getAlias() + " already exists");
} }
} }
@ -101,7 +101,7 @@ public class IdentityProviderResource {
List<IdentityProviderModel> providerModels = realm.getIdentityProviders(); List<IdentityProviderModel> providerModels = realm.getIdentityProviders();
for (IdentityProviderModel providerModel : providerModels) { for (IdentityProviderModel providerModel : providerModels) {
if (providerModel.getInternalId().equals(providerInternalId)) { if (providerModel.getInternalId().equals(providerInternalId)) {
return providerModel.getId(); return providerModel.getAlias();
} }
} }
@ -175,7 +175,7 @@ public class IdentityProviderResource {
List<ClientIdentityProviderMappingModel> identityProviders = clientModel.getIdentityProviders(); List<ClientIdentityProviderMappingModel> identityProviders = clientModel.getIdentityProviders();
for (ClientIdentityProviderMappingModel providerMappingModel : new ArrayList<ClientIdentityProviderMappingModel>(identityProviders)) { for (ClientIdentityProviderMappingModel providerMappingModel : new ArrayList<ClientIdentityProviderMappingModel>(identityProviders)) {
if (providerMappingModel.getIdentityProvider().equals(identityProvider.getId())) { if (providerMappingModel.getIdentityProvider().equals(identityProvider.getAlias())) {
identityProviders.remove(providerMappingModel); identityProviders.remove(providerMappingModel);
clientModel.updateIdentityProviders(identityProviders); clientModel.updateIdentityProviders(identityProviders);
break; break;

View file

@ -56,21 +56,6 @@ public class IdentityProvidersResource {
this.auth.init(RealmAuth.Resource.IDENTITY_PROVIDER); this.auth.init(RealmAuth.Resource.IDENTITY_PROVIDER);
} }
@GET
@NoCache
@Produces("application/json")
public List<IdentityProviderRepresentation> getIdentityProviders() {
this.auth.requireView();
List<IdentityProviderRepresentation> representations = new ArrayList<IdentityProviderRepresentation>();
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
representations.add(ModelToRepresentation.toRepresentation(identityProviderModel));
}
return representations;
}
@Path("/providers/{provider_id}") @Path("/providers/{provider_id}")
@GET @GET
@NoCache @NoCache
@ -87,71 +72,28 @@ public class IdentityProvidersResource {
} }
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Path("import-config")
public Response create(@Context UriInfo uriInfo, IdentityProviderRepresentation representation) {
this.auth.requireManage();
try {
this.realm.addIdentityProvider(RepresentationToModel.toModel(representation));
return Response.created(uriInfo.getAbsolutePathBuilder().path(representation.getProviderId()).build()).build();
} catch (ModelDuplicateException e) {
return Flows.errors().exists("Identity Provider " + representation.getId() + " already exists");
}
}
@POST
@Path("import")
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
public Response importFrom(@Context UriInfo uriInfo, MultipartFormDataInput input) throws IOException { @Produces(MediaType.APPLICATION_JSON)
public Map<String, String> importFrom(@Context UriInfo uriInfo, MultipartFormDataInput input) throws IOException {
this.auth.requireManage(); this.auth.requireManage();
Map<String, List<InputPart>> formDataMap = input.getFormDataMap(); Map<String, List<InputPart>> formDataMap = input.getFormDataMap();
String id = formDataMap.get("id").get(0).getBodyAsString();
String name = formDataMap.get("name").get(0).getBodyAsString();
String providerId = formDataMap.get("providerId").get(0).getBodyAsString(); String providerId = formDataMap.get("providerId").get(0).getBodyAsString();
String enabled = formDataMap.get("enabled").get(0).getBodyAsString();
String updateProfileFirstLogin = formDataMap.get("updateProfileFirstLogin").get(0).getBodyAsString();
String storeToken = "false";
if (formDataMap.containsKey("storeToken")) {
storeToken = formDataMap.get("storeToken").get(0).getBodyAsString();
}
InputPart file = formDataMap.get("file").get(0); InputPart file = formDataMap.get("file").get(0);
InputStream inputStream = file.getBody(InputStream.class, null); InputStream inputStream = file.getBody(InputStream.class, null);
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId); IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
Map config = providerFactory.parseConfig(inputStream); Map<String, String> config = providerFactory.parseConfig(inputStream);
IdentityProviderRepresentation representation = new IdentityProviderRepresentation(); return config;
representation.setId(id);
representation.setName(name);
representation.setProviderId(providerId);
representation.setEnabled(Boolean.valueOf(enabled));
representation.setUpdateProfileFirstLogin(Boolean.valueOf(updateProfileFirstLogin));
representation.setStoreToken(Boolean.valueOf(storeToken));
representation.setConfig(config);
return create(uriInfo, representation);
} }
@POST @POST
@Path("import") @Path("import-config")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Response importFrom(@Context UriInfo uriInfo, Map<String, Object> data) throws IOException { @Produces(MediaType.APPLICATION_JSON)
public Map<String, String> importFrom(@Context UriInfo uriInfo, Map<String, Object> data) throws IOException {
this.auth.requireManage(); this.auth.requireManage();
String id = data.get("id").toString();
String name = data.get("name").toString();
String providerId = data.get("providerId").toString(); String providerId = data.get("providerId").toString();
String enabled = data.get("enabled").toString();
String updateProfileFirstLogin = data.get("updateProfileFirstLogin").toString();
String storeToken = "false";
if (data.containsKey("storeToken")) {
storeToken = data.get("storeToken").toString();
}
String from = data.get("fromUrl").toString(); String from = data.get("fromUrl").toString();
ApacheHttpClient4Executor executor = ResourceAdminManager.createExecutor(); ApacheHttpClient4Executor executor = ResourceAdminManager.createExecutor();
InputStream inputStream = null; InputStream inputStream = null;
@ -161,34 +103,55 @@ public class IdentityProvidersResource {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId); IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
Map config = providerFactory.parseConfig(inputStream); Map<String, String> config = providerFactory.parseConfig(inputStream);
IdentityProviderRepresentation representation = new IdentityProviderRepresentation(); return config;
representation.setId(id);
representation.setName(name);
representation.setProviderId(providerId);
representation.setEnabled(Boolean.valueOf(enabled));
representation.setUpdateProfileFirstLogin(Boolean.valueOf(updateProfileFirstLogin));
representation.setStoreToken(Boolean.valueOf(storeToken));
representation.setConfig(config);
return create(uriInfo, representation);
} }
@Path("instances/{id}") @GET
public IdentityProviderResource getIdentityProvider(@PathParam("id") String providerId) { @Path("instances")
@NoCache
@Produces("application/json")
public List<IdentityProviderRepresentation> getIdentityProviders() {
this.auth.requireView();
List<IdentityProviderRepresentation> representations = new ArrayList<IdentityProviderRepresentation>();
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
representations.add(ModelToRepresentation.toRepresentation(identityProviderModel));
}
return representations;
}
@POST
@Path("instances")
@Consumes(MediaType.APPLICATION_JSON)
public Response create(@Context UriInfo uriInfo, IdentityProviderRepresentation representation) {
this.auth.requireManage();
try {
this.realm.addIdentityProvider(RepresentationToModel.toModel(representation));
return Response.created(uriInfo.getAbsolutePathBuilder().path(representation.getProviderId()).build()).build();
} catch (ModelDuplicateException e) {
return Flows.errors().exists("Identity Provider " + representation.getAlias() + " already exists");
}
}
@Path("instances/{alias}")
public IdentityProviderResource getIdentityProvider(@PathParam("alias") String alias) {
this.auth.requireView(); this.auth.requireView();
IdentityProviderModel identityProviderModel = null; IdentityProviderModel identityProviderModel = null;
for (IdentityProviderModel storedIdentityProvider : this.realm.getIdentityProviders()) { for (IdentityProviderModel storedIdentityProvider : this.realm.getIdentityProviders()) {
if (storedIdentityProvider.getId().equals(providerId) if (storedIdentityProvider.getAlias().equals(alias)
|| storedIdentityProvider.getInternalId().equals(providerId)) { || storedIdentityProvider.getInternalId().equals(alias)) {
identityProviderModel = storedIdentityProvider; identityProviderModel = storedIdentityProvider;
} }
} }
if (identityProviderModel == null) { if (identityProviderModel == null) {
throw new NotFoundException("Could not find identity provider: " + providerId); throw new NotFoundException("Could not find identity provider: " + alias);
} }
IdentityProviderResource identityProviderResource = new IdentityProviderResource(this.auth, realm, session, identityProviderModel); IdentityProviderResource identityProviderResource = new IdentityProviderResource(this.auth, realm, session, identityProviderModel);

View file

@ -84,13 +84,13 @@ public class ServerInfoAdminResource {
} }
private void setSocialProviders(ServerInfoRepresentation info) { private void setSocialProviders(ServerInfoRepresentation info) {
info.socialProviders = new LinkedList<IdentityProviderRepresentation>(); info.socialProviders = new LinkedList<>();
List<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactories(SocialIdentityProvider.class); List<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactories(SocialIdentityProvider.class);
setIdentityProviders(providerFactories, info.socialProviders, "Social"); setIdentityProviders(providerFactories, info.socialProviders, "Social");
} }
private void setIdentityProviders(ServerInfoRepresentation info) { private void setIdentityProviders(ServerInfoRepresentation info) {
info.identityProviders = new LinkedList<IdentityProviderRepresentation>(); info.identityProviders = new LinkedList<>();
List<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactories(IdentityProvider.class); List<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactories(IdentityProvider.class);
setIdentityProviders(providerFactories, info.identityProviders, "User-defined"); setIdentityProviders(providerFactories, info.identityProviders, "User-defined");
@ -98,24 +98,16 @@ public class ServerInfoAdminResource {
setIdentityProviders(providerFactories, info.identityProviders, "Social"); setIdentityProviders(providerFactories, info.identityProviders, "Social");
} }
public void setIdentityProviders(List<ProviderFactory> factories, List<IdentityProviderRepresentation> providers, String groupName) { public void setIdentityProviders(List<ProviderFactory> factories, List<Map<String, String>> providers, String groupName) {
for (ProviderFactory providerFactory : factories) { for (ProviderFactory providerFactory : factories) {
IdentityProviderFactory factory = (IdentityProviderFactory) providerFactory; IdentityProviderFactory factory = (IdentityProviderFactory) providerFactory;
IdentityProviderRepresentation rep = new IdentityProviderRepresentation(); Map<String, String> data = new HashMap<>();
data.put("groupName", groupName);
data.put("name", factory.getName());
data.put("id", factory.getId());
rep.setId(factory.getId()); providers.add(data);
rep.setName(factory.getName());
rep.setGroupName(groupName);
providers.add(rep);
} }
Collections.sort(providers, new Comparator<IdentityProviderRepresentation>() {
@Override
public int compare(IdentityProviderRepresentation o1, IdentityProviderRepresentation o2) {
return o1.getName().compareTo(o2.getName());
}
});
} }
private void setEventListeners(ServerInfoRepresentation info) { private void setEventListeners(ServerInfoRepresentation info) {
@ -194,8 +186,8 @@ public class ServerInfoAdminResource {
private Map<String, List<String>> themes; private Map<String, List<String>> themes;
private List<IdentityProviderRepresentation> socialProviders; private List<Map<String, String>> socialProviders;
public List<IdentityProviderRepresentation> identityProviders; public List<Map<String, String>> identityProviders;
private List<String> protocols; private List<String> protocols;
private List<Map<String, String>> applicationImporters; private List<Map<String, String>> applicationImporters;
@ -220,11 +212,11 @@ public class ServerInfoAdminResource {
return themes; return themes;
} }
public List<IdentityProviderRepresentation> getSocialProviders() { public List<Map<String, String>> getSocialProviders() {
return socialProviders; return socialProviders;
} }
public List<IdentityProviderRepresentation> getIdentityProviders() { public List<Map<String, String>> getIdentityProviders() {
return this.identityProviders; return this.identityProviders;
} }

View file

@ -265,7 +265,7 @@ public class UsersResource {
for (FederatedIdentityModel identity : identities) { for (FederatedIdentityModel identity : identities) {
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) { for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
if (identityProviderModel.getId().equals(identity.getIdentityProvider())) { if (identityProviderModel.getAlias().equals(identity.getIdentityProvider())) {
FederatedIdentityRepresentation rep = ModelToRepresentation.toRepresentation(identity); FederatedIdentityRepresentation rep = ModelToRepresentation.toRepresentation(identity);
result.add(rep); result.add(rep);
} }

View file

@ -102,7 +102,7 @@ public abstract class AbstractClientTest {
} else if (o1 instanceof OAuthClientRepresentation) { } else if (o1 instanceof OAuthClientRepresentation) {
return ((OAuthClientRepresentation) o1).getName(); return ((OAuthClientRepresentation) o1).getName();
} else if (o1 instanceof IdentityProviderRepresentation) { } else if (o1 instanceof IdentityProviderRepresentation) {
return ((IdentityProviderRepresentation) o1).getId(); return ((IdentityProviderRepresentation) o1).getAlias();
} }
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View file

@ -46,8 +46,7 @@ public class IdentityProviderTest extends AbstractClientTest {
assertNotNull(representation); assertNotNull(representation);
assertNotNull(representation.getInternalId()); assertNotNull(representation.getInternalId());
assertEquals("New Identity Provider", representation.getName()); assertEquals("new-identity-provider", representation.getAlias());
assertEquals("new-identity-provider", representation.getId());
assertEquals("oidc", representation.getProviderId()); assertEquals("oidc", representation.getProviderId());
assertEquals("clientId", representation.getConfig().get("clientId")); assertEquals("clientId", representation.getConfig().get("clientId"));
assertEquals("clientSecret", representation.getConfig().get("clientSecret")); assertEquals("clientSecret", representation.getConfig().get("clientSecret"));
@ -72,9 +71,9 @@ public class IdentityProviderTest extends AbstractClientTest {
assertNotNull(representation); assertNotNull(representation);
assertEquals("update-identity-provider", representation.getId()); assertEquals("update-identity-provider", representation.getAlias());
representation.setId("changed-alias"); representation.setAlias("changed-alias");
representation.setEnabled(false); representation.setEnabled(false);
representation.setStoreToken(true); representation.setStoreToken(true);
representation.getConfig().put("clientId", "changedClientId"); representation.getConfig().put("clientId", "changedClientId");
@ -113,9 +112,8 @@ public class IdentityProviderTest extends AbstractClientTest {
private IdentityProviderRepresentation create(String id, String providerId, String name) { private IdentityProviderRepresentation create(String id, String providerId, String name) {
IdentityProviderRepresentation identityProviderRepresentation = new IdentityProviderRepresentation(); IdentityProviderRepresentation identityProviderRepresentation = new IdentityProviderRepresentation();
identityProviderRepresentation.setId(id); identityProviderRepresentation.setAlias(id);
identityProviderRepresentation.setProviderId(providerId); identityProviderRepresentation.setProviderId(providerId);
identityProviderRepresentation.setName(name);
identityProviderRepresentation.setEnabled(true); identityProviderRepresentation.setEnabled(true);
return identityProviderRepresentation; return identityProviderRepresentation;

View file

@ -227,8 +227,7 @@ public class UserTest extends AbstractClientTest {
Assert.assertEquals(0, providers.size()); Assert.assertEquals(0, providers.size());
IdentityProviderRepresentation rep = new IdentityProviderRepresentation(); IdentityProviderRepresentation rep = new IdentityProviderRepresentation();
rep.setId("social-provider-id"); rep.setAlias("social-provider-id");
rep.setName("social-provider-name");
rep.setProviderId("social-provider-type"); rep.setProviderId("social-provider-type");
realm.identityProviders().create(rep); realm.identityProviders().create(rep);
} }

View file

@ -327,7 +327,7 @@ public abstract class AbstractIdentityProviderTest {
// Link my "pedroigor" identity with "test-user" from brokered Keycloak // Link my "pedroigor" identity with "test-user" from brokered Keycloak
IdentityProviderModel identityProviderModel = getIdentityProviderModel(); IdentityProviderModel identityProviderModel = getIdentityProviderModel();
accountFederatedIdentityPage.clickAddProvider(identityProviderModel.getId()); accountFederatedIdentityPage.clickAddProvider(identityProviderModel.getAlias());
assertTrue(this.driver.getCurrentUrl().startsWith("http://localhost:8082/auth/")); assertTrue(this.driver.getCurrentUrl().startsWith("http://localhost:8082/auth/"));
this.loginPage.login("test-user", "password"); this.loginPage.login("test-user", "password");
@ -335,28 +335,28 @@ public abstract class AbstractIdentityProviderTest {
// Assert identity linked in account management // Assert identity linked in account management
assertTrue(accountFederatedIdentityPage.isCurrent()); assertTrue(accountFederatedIdentityPage.isCurrent());
assertTrue(driver.getPageSource().contains("id=\"remove-" + identityProviderModel.getId() + "\"")); assertTrue(driver.getPageSource().contains("id=\"remove-" + identityProviderModel.getAlias() + "\""));
// Logout from account management // Logout from account management
accountFederatedIdentityPage.logout(); accountFederatedIdentityPage.logout();
assertTrue(driver.getTitle().equals("Log in to realm-with-broker")); assertTrue(driver.getTitle().equals("Log in to realm-with-broker"));
// Assert I am logged immediately to account management due to previously linked "test-user" identity // Assert I am logged immediately to account management due to previously linked "test-user" identity
loginPage.clickSocial(identityProviderModel.getId()); loginPage.clickSocial(identityProviderModel.getAlias());
doAfterProviderAuthentication(); doAfterProviderAuthentication();
assertTrue(accountFederatedIdentityPage.isCurrent()); assertTrue(accountFederatedIdentityPage.isCurrent());
assertTrue(driver.getPageSource().contains("id=\"remove-" + identityProviderModel.getId() + "\"")); assertTrue(driver.getPageSource().contains("id=\"remove-" + identityProviderModel.getAlias() + "\""));
// Unlink my "test-user" // Unlink my "test-user"
accountFederatedIdentityPage.clickRemoveProvider(identityProviderModel.getId()); accountFederatedIdentityPage.clickRemoveProvider(identityProviderModel.getAlias());
assertTrue(driver.getPageSource().contains("id=\"add-" + identityProviderModel.getId() + "\"")); assertTrue(driver.getPageSource().contains("id=\"add-" + identityProviderModel.getAlias() + "\""));
// Logout from account management // Logout from account management
accountFederatedIdentityPage.logout(); accountFederatedIdentityPage.logout();
assertTrue(driver.getTitle().equals("Log in to realm-with-broker")); assertTrue(driver.getTitle().equals("Log in to realm-with-broker"));
// Try to login. Previous link is not valid anymore, so now it should try to register new user // Try to login. Previous link is not valid anymore, so now it should try to register new user
this.loginPage.clickSocial(identityProviderModel.getId()); this.loginPage.clickSocial(identityProviderModel.getAlias());
doAfterProviderAuthentication(); doAfterProviderAuthentication();
this.updateProfilePage.assertCurrent(); this.updateProfilePage.assertCurrent();
} }
@ -579,7 +579,7 @@ public abstract class AbstractIdentityProviderTest {
protected abstract String getProviderId(); protected abstract String getProviderId();
protected IdentityProviderModel getIdentityProviderModel() { protected IdentityProviderModel getIdentityProviderModel() {
IdentityProviderModel identityProviderModel = getRealm().getIdentityProviderById(getProviderId()); IdentityProviderModel identityProviderModel = getRealm().getIdentityProviderByAlias(getProviderId());
assertNotNull(identityProviderModel); assertNotNull(identityProviderModel);

View file

@ -61,7 +61,7 @@ public class IdentityProviderRegistrationTest extends AbstractIdentityProviderMo
IdentityProviderModel identityProviderModel = new IdentityProviderModel(); IdentityProviderModel identityProviderModel = new IdentityProviderModel();
identityProviderModel.setId("custom-provider"); identityProviderModel.setAlias("custom-provider");
CustomSocialProvider customSocialProvider = providerFactory.create(identityProviderModel); CustomSocialProvider customSocialProvider = providerFactory.create(identityProviderModel);
@ -69,7 +69,7 @@ public class IdentityProviderRegistrationTest extends AbstractIdentityProviderMo
IdentityProviderModel config = customSocialProvider.getConfig(); IdentityProviderModel config = customSocialProvider.getConfig();
assertNotNull(config); assertNotNull(config);
assertEquals("custom-provider", config.getId()); assertEquals("custom-provider", config.getAlias());
} }
@Test @Test
@ -84,7 +84,7 @@ public class IdentityProviderRegistrationTest extends AbstractIdentityProviderMo
IdentityProviderModel identityProviderModel = new IdentityProviderModel(); IdentityProviderModel identityProviderModel = new IdentityProviderModel();
identityProviderModel.setId("custom-provider"); identityProviderModel.setAlias("custom-provider");
CustomIdentityProvider provider = providerFactory.create(identityProviderModel); CustomIdentityProvider provider = providerFactory.create(identityProviderModel);
@ -92,7 +92,7 @@ public class IdentityProviderRegistrationTest extends AbstractIdentityProviderMo
IdentityProviderModel config = provider.getConfig(); IdentityProviderModel config = provider.getConfig();
assertNotNull(config); assertNotNull(config);
assertEquals("custom-provider", config.getId()); assertEquals("custom-provider", config.getAlias());
} }
private Set<String> getInstalledProviders() { private Set<String> getInstalledProviders() {

View file

@ -72,9 +72,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
assertFalse(identityProviders.isEmpty()); assertFalse(identityProviders.isEmpty());
IdentityProviderModel identityProviderModel = identityProviders.get(0); IdentityProviderModel identityProviderModel = identityProviders.get(0);
String identityProviderId = identityProviderModel.getId(); String identityProviderId = identityProviderModel.getAlias();
identityProviderModel.setName("Changed Name");
identityProviderModel.getConfig().put("config-added", "value-added"); identityProviderModel.getConfig().put("config-added", "value-added");
identityProviderModel.setEnabled(false); identityProviderModel.setEnabled(false);
identityProviderModel.setUpdateProfileFirstLogin(false); identityProviderModel.setUpdateProfileFirstLogin(false);
@ -87,16 +86,14 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
realm = this.realmManager.getRealm(realm.getId()); realm = this.realmManager.getRealm(realm.getId());
identityProviderModel = realm.getIdentityProviderById(identityProviderId); identityProviderModel = realm.getIdentityProviderByAlias(identityProviderId);
assertEquals("Changed Name", identityProviderModel.getName());
assertEquals("value-added", identityProviderModel.getConfig().get("config-added")); assertEquals("value-added", identityProviderModel.getConfig().get("config-added"));
assertFalse(identityProviderModel.isEnabled()); assertFalse(identityProviderModel.isEnabled());
assertFalse(identityProviderModel.isUpdateProfileFirstLogin()); assertFalse(identityProviderModel.isUpdateProfileFirstLogin());
assertTrue(identityProviderModel.isStoreToken()); assertTrue(identityProviderModel.isStoreToken());
assertTrue(identityProviderModel.isAuthenticateByDefault()); assertTrue(identityProviderModel.isAuthenticateByDefault());
identityProviderModel.setName("Changed Name Again");
identityProviderModel.getConfig().remove("config-added"); identityProviderModel.getConfig().remove("config-added");
identityProviderModel.setEnabled(true); identityProviderModel.setEnabled(true);
identityProviderModel.setUpdateProfileFirstLogin(true); identityProviderModel.setUpdateProfileFirstLogin(true);
@ -107,9 +104,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
commit(); commit();
realm = this.realmManager.getRealm(realm.getId()); realm = this.realmManager.getRealm(realm.getId());
identityProviderModel = realm.getIdentityProviderById(identityProviderId); identityProviderModel = realm.getIdentityProviderByAlias(identityProviderId);
assertEquals("Changed Name Again", identityProviderModel.getName());
assertFalse(identityProviderModel.getConfig().containsKey("config-added")); assertFalse(identityProviderModel.getConfig().containsKey("config-added"));
assertTrue(identityProviderModel.isEnabled()); assertTrue(identityProviderModel.isEnabled());
assertTrue(identityProviderModel.isUpdateProfileFirstLogin()); assertTrue(identityProviderModel.isUpdateProfileFirstLogin());
@ -149,7 +145,7 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
Set<String> checkedProviders = new HashSet<String>(getExpectedProviders()); Set<String> checkedProviders = new HashSet<String>(getExpectedProviders());
for (IdentityProviderModel identityProvider : identityProviders) { for (IdentityProviderModel identityProvider : identityProviders) {
if (identityProvider.getId().startsWith("model-")) { if (identityProvider.getAlias().startsWith("model-")) {
String providerId = identityProvider.getProviderId(); String providerId = identityProvider.getProviderId();
if (SAMLIdentityProviderFactory.PROVIDER_ID.equals(providerId)) { if (SAMLIdentityProviderFactory.PROVIDER_ID.equals(providerId)) {
@ -179,9 +175,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
GoogleIdentityProvider googleIdentityProvider = new GoogleIdentityProviderFactory().create(identityProvider); GoogleIdentityProvider googleIdentityProvider = new GoogleIdentityProviderFactory().create(identityProvider);
OIDCIdentityProviderConfig config = googleIdentityProvider.getConfig(); OIDCIdentityProviderConfig config = googleIdentityProvider.getConfig();
assertEquals("model-google", config.getId()); assertEquals("model-google", config.getAlias());
assertEquals(GoogleIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(GoogleIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("Google", config.getName());
assertEquals(true, config.isEnabled()); assertEquals(true, config.isEnabled());
assertEquals(true, config.isUpdateProfileFirstLogin()); assertEquals(true, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());
@ -198,9 +193,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
SAMLIdentityProvider samlIdentityProvider = new SAMLIdentityProviderFactory().create(identityProvider); SAMLIdentityProvider samlIdentityProvider = new SAMLIdentityProviderFactory().create(identityProvider);
SAMLIdentityProviderConfig config = samlIdentityProvider.getConfig(); SAMLIdentityProviderConfig config = samlIdentityProvider.getConfig();
assertEquals("model-saml-signed-idp", config.getId()); assertEquals("model-saml-signed-idp", config.getAlias());
assertEquals(SAMLIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(SAMLIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("SAML Signed IdP", config.getName());
assertEquals(true, config.isEnabled()); assertEquals(true, config.isEnabled());
assertEquals(true, config.isUpdateProfileFirstLogin()); assertEquals(true, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());
@ -219,9 +213,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
OIDCIdentityProvider googleIdentityProvider = new OIDCIdentityProviderFactory().create(identityProvider); OIDCIdentityProvider googleIdentityProvider = new OIDCIdentityProviderFactory().create(identityProvider);
OIDCIdentityProviderConfig config = googleIdentityProvider.getConfig(); OIDCIdentityProviderConfig config = googleIdentityProvider.getConfig();
assertEquals("model-oidc-idp", config.getId()); assertEquals("model-oidc-idp", config.getAlias());
assertEquals(OIDCIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(OIDCIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("OIDC IdP", config.getName());
assertEquals(false, config.isEnabled()); assertEquals(false, config.isEnabled());
assertEquals(false, config.isUpdateProfileFirstLogin()); assertEquals(false, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());
@ -234,9 +227,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
FacebookIdentityProvider facebookIdentityProvider = new FacebookIdentityProviderFactory().create(identityProvider); FacebookIdentityProvider facebookIdentityProvider = new FacebookIdentityProviderFactory().create(identityProvider);
OAuth2IdentityProviderConfig config = facebookIdentityProvider.getConfig(); OAuth2IdentityProviderConfig config = facebookIdentityProvider.getConfig();
assertEquals("model-facebook", config.getId()); assertEquals("model-facebook", config.getAlias());
assertEquals(FacebookIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(FacebookIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("Facebook", config.getName());
assertEquals(true, config.isEnabled()); assertEquals(true, config.isEnabled());
assertEquals(true, config.isUpdateProfileFirstLogin()); assertEquals(true, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());
@ -252,9 +244,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
GitHubIdentityProvider gitHubIdentityProvider = new GitHubIdentityProviderFactory().create(identityProvider); GitHubIdentityProvider gitHubIdentityProvider = new GitHubIdentityProviderFactory().create(identityProvider);
OAuth2IdentityProviderConfig config = gitHubIdentityProvider.getConfig(); OAuth2IdentityProviderConfig config = gitHubIdentityProvider.getConfig();
assertEquals("model-github", config.getId()); assertEquals("model-github", config.getAlias());
assertEquals(GitHubIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(GitHubIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("GitHub", config.getName());
assertEquals(true, config.isEnabled()); assertEquals(true, config.isEnabled());
assertEquals(true, config.isUpdateProfileFirstLogin()); assertEquals(true, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());
@ -270,9 +261,8 @@ public class ImportIdentityProviderTest extends AbstractIdentityProviderModelTes
TwitterIdentityProvider twitterIdentityProvider = new TwitterIdentityProviderFactory().create(identityProvider); TwitterIdentityProvider twitterIdentityProvider = new TwitterIdentityProviderFactory().create(identityProvider);
OAuth2IdentityProviderConfig config = twitterIdentityProvider.getConfig(); OAuth2IdentityProviderConfig config = twitterIdentityProvider.getConfig();
assertEquals("model-twitter", config.getId()); assertEquals("model-twitter", config.getAlias());
assertEquals(TwitterIdentityProviderFactory.PROVIDER_ID, config.getProviderId()); assertEquals(TwitterIdentityProviderFactory.PROVIDER_ID, config.getProviderId());
assertEquals("Twitter", config.getName());
assertEquals(true, config.isEnabled()); assertEquals(true, config.isEnabled());
assertEquals(true, config.isUpdateProfileFirstLogin()); assertEquals(true, config.isUpdateProfileFirstLogin());
assertEquals(false, config.isAuthenticateByDefault()); assertEquals(false, config.isAuthenticateByDefault());

View file

@ -207,9 +207,8 @@ public class ImportTest extends AbstractModelTest {
List<IdentityProviderModel> identityProviders = realm.getIdentityProviders(); List<IdentityProviderModel> identityProviders = realm.getIdentityProviders();
Assert.assertEquals(1, identityProviders.size()); Assert.assertEquals(1, identityProviders.size());
IdentityProviderModel google = identityProviders.get(0); IdentityProviderModel google = identityProviders.get(0);
Assert.assertEquals("google1", google.getId()); Assert.assertEquals("google1", google.getAlias());
Assert.assertEquals("google", google.getProviderId()); Assert.assertEquals("google", google.getProviderId());
Assert.assertEquals("Google", google.getName());
Assert.assertTrue(google.isEnabled()); Assert.assertTrue(google.isEnabled());
Assert.assertEquals("googleId", google.getConfig().get("clientId")); Assert.assertEquals("googleId", google.getConfig().get("clientId"));
Assert.assertEquals("googleSecret", google.getConfig().get("clientSecret")); Assert.assertEquals("googleSecret", google.getConfig().get("clientSecret"));

View file

@ -10,9 +10,8 @@
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgj8r0029eL0jJKXv6XbNj+QqsZO25HhZ0IjTEtb8mfh0tju/X8c6dXgILh5wU7OF00U+0mSYSE/+rrYKmY5g4oCleTe1+abavATP1tamtXGAUYqdutaXPrVn9yMsCWEPchSPZlEGq5iBJdA+xh9ejUmZJYXmln26HUVWq71/jC9GpjbRmFQ37f0X7WJoGyiqyttfKkKfUeBmRbX/0P0Zm6DVze8HjCDVPBllZE0a3HCgSF0rp0+s1xn7o91qdWKVattAVsGNjjDPz/sgwHOyyhDtSyajwXU+K/QUZ9pV4moGtwC9uIEymTylP7bu7qnxXIhfouEa+fEjAzTs0HJ5JQIDAQAB", "publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgj8r0029eL0jJKXv6XbNj+QqsZO25HhZ0IjTEtb8mfh0tju/X8c6dXgILh5wU7OF00U+0mSYSE/+rrYKmY5g4oCleTe1+abavATP1tamtXGAUYqdutaXPrVn9yMsCWEPchSPZlEGq5iBJdA+xh9ejUmZJYXmln26HUVWq71/jC9GpjbRmFQ37f0X7WJoGyiqyttfKkKfUeBmRbX/0P0Zm6DVze8HjCDVPBllZE0a3HCgSF0rp0+s1xn7o91qdWKVattAVsGNjjDPz/sgwHOyyhDtSyajwXU+K/QUZ9pV4moGtwC9uIEymTylP7bu7qnxXIhfouEa+fEjAzTs0HJ5JQIDAQAB",
"identityProviders" : [ "identityProviders" : [
{ {
"id" : "model-google", "alias" : "model-google",
"providerId" : "google", "providerId" : "google",
"name" : "Google",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"storeToken": "true", "storeToken": "true",
@ -22,9 +21,8 @@
} }
}, },
{ {
"id" : "model-facebook", "alias" : "model-facebook",
"providerId" : "facebook", "providerId" : "facebook",
"name" : "Facebook",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"config": { "config": {
@ -36,9 +34,8 @@
} }
}, },
{ {
"id" : "model-github", "alias" : "model-github",
"providerId" : "github", "providerId" : "github",
"name" : "GitHub",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"storeToken": "false", "storeToken": "false",
@ -51,9 +48,8 @@
} }
}, },
{ {
"id" : "model-twitter", "alias" : "model-twitter",
"providerId" : "twitter", "providerId" : "twitter",
"name" : "Twitter",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"storeToken": true, "storeToken": true,
@ -66,9 +62,8 @@
} }
}, },
{ {
"id" : "model-saml-signed-idp", "alias" : "model-saml-signed-idp",
"providerId" : "saml", "providerId" : "saml",
"name" : "SAML Signed IdP",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"config": { "config": {
@ -83,9 +78,8 @@
} }
}, },
{ {
"id" : "kc-saml-signed-idp", "alias" : "kc-saml-signed-idp",
"providerId" : "saml", "providerId" : "saml",
"name" : "SAML Signed IdP",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"config": { "config": {
@ -100,9 +94,8 @@
} }
}, },
{ {
"id" : "kc-saml-idp-basic", "alias" : "kc-saml-idp-basic",
"providerId" : "saml", "providerId" : "saml",
"name" : "SAML Signed IdP",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"config": { "config": {
@ -114,9 +107,8 @@
} }
}, },
{ {
"id" : "model-oidc-idp", "alias" : "model-oidc-idp",
"providerId" : "oidc", "providerId" : "oidc",
"name" : "OIDC IdP",
"enabled": false, "enabled": false,
"updateProfileFirstLogin" : "false", "updateProfileFirstLogin" : "false",
"authenticateByDefault" : "false", "authenticateByDefault" : "false",
@ -131,9 +123,8 @@
} }
}, },
{ {
"id" : "kc-oidc-idp", "alias" : "kc-oidc-idp",
"providerId" : "oidc", "providerId" : "oidc",
"name" : "KeyCloak OIDC IdP",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "false", "updateProfileFirstLogin" : "false",
"config": { "config": {
@ -147,9 +138,8 @@
} }
}, },
{ {
"id" : "model-kerberos", "alias" : "model-kerberos",
"providerId" : "kerberos", "providerId" : "kerberos",
"name" : "Kerberos",
"enabled": true, "enabled": true,
"updateProfileFirstLogin" : "true", "updateProfileFirstLogin" : "true",
"authenticateByDefault" : "false", "authenticateByDefault" : "false",

View file

@ -15,8 +15,7 @@
"identityProviders" : [ "identityProviders" : [
{ {
"providerId" : "google", "providerId" : "google",
"id" : "google1", "alias" : "google1",
"name" : "Google",
"enabled": true, "enabled": true,
"config": { "config": {
"clientId": "googleId", "clientId": "googleId",