claim support phase 2
This commit is contained in:
parent
8586a8d1a5
commit
2fb97f058b
9 changed files with 188 additions and 35 deletions
|
@ -0,0 +1,64 @@
|
||||||
|
package org.keycloak.representations.idm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class ProtocolClaimMappingRepresentation {
|
||||||
|
protected String id;
|
||||||
|
protected String protocolClaim;
|
||||||
|
protected String protocol;
|
||||||
|
protected String source;
|
||||||
|
protected String sourceAttribute;
|
||||||
|
protected boolean appliedByDefault;
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProtocolClaim() {
|
||||||
|
return protocolClaim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaim(String protocolClaim) {
|
||||||
|
this.protocolClaim = protocolClaim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProtocol() {
|
||||||
|
return protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocol(String protocol) {
|
||||||
|
this.protocol = protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSourceAttribute() {
|
||||||
|
return sourceAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceAttribute(String sourceAttribute) {
|
||||||
|
this.sourceAttribute = sourceAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAppliedByDefault() {
|
||||||
|
return appliedByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppliedByDefault(boolean appliedByDefault) {
|
||||||
|
this.appliedByDefault = appliedByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -64,6 +64,7 @@ public class RealmRepresentation {
|
||||||
protected List<String> eventsListeners;
|
protected List<String> eventsListeners;
|
||||||
private List<IdentityProviderRepresentation> identityProviders;
|
private List<IdentityProviderRepresentation> identityProviders;
|
||||||
private List<ClaimTypeRepresentation> claimTypes;
|
private List<ClaimTypeRepresentation> claimTypes;
|
||||||
|
private List<ProtocolClaimMappingRepresentation> protocolClaimMappings;
|
||||||
private Boolean identityFederationEnabled;
|
private Boolean identityFederationEnabled;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -490,4 +491,12 @@ public class RealmRepresentation {
|
||||||
public void setClaimTypes(List<ClaimTypeRepresentation> claimTypes) {
|
public void setClaimTypes(List<ClaimTypeRepresentation> claimTypes) {
|
||||||
this.claimTypes = claimTypes;
|
this.claimTypes = claimTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ProtocolClaimMappingRepresentation> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaimMappings(List<ProtocolClaimMappingRepresentation> protocolClaimMappings) {
|
||||||
|
this.protocolClaimMappings = protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ public class ClaimTypeModel {
|
||||||
STRING
|
STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String id;
|
private String id;
|
||||||
private final String name;
|
private String name;
|
||||||
private final boolean builtIn;
|
private boolean builtIn;
|
||||||
private final ValueType type;
|
private ValueType type;
|
||||||
|
|
||||||
public ClaimTypeModel(ClaimTypeModel copy) {
|
public ClaimTypeModel(ClaimTypeModel copy) {
|
||||||
this(copy.getId(), copy.getName(), copy.isBuiltIn(), copy.getType());
|
this(copy.getId(), copy.getName(), copy.isBuiltIn(), copy.getType());
|
||||||
|
@ -28,6 +28,9 @@ public class ClaimTypeModel {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClaimTypeModel() {
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +47,22 @@ public class ClaimTypeModel {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBuiltIn(boolean builtIn) {
|
||||||
|
this.builtIn = builtIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ValueType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
@ -225,14 +225,13 @@ public interface RealmModel extends RoleContainerModel {
|
||||||
boolean isIdentityFederationEnabled();
|
boolean isIdentityFederationEnabled();
|
||||||
|
|
||||||
Set<ClaimTypeModel> getClaimTypes();
|
Set<ClaimTypeModel> getClaimTypes();
|
||||||
ClaimTypeModel addClaimType(String name, ClaimTypeModel.ValueType type, boolean builtIn);
|
ClaimTypeModel addClaimType(ClaimTypeModel model);
|
||||||
void removeClaimType(ClaimTypeModel claimType);
|
void removeClaimType(ClaimTypeModel claimType);
|
||||||
ClaimTypeModel getClaimType(String name);
|
ClaimTypeModel getClaimType(String name);
|
||||||
void updateClaimType(ClaimTypeModel claimType);
|
void updateClaimType(ClaimTypeModel claimType);
|
||||||
|
|
||||||
Set<ProtocolClaimMappingModel> getProtocolClaimMappings();
|
Set<ProtocolClaimMappingModel> getProtocolClaimMappings();
|
||||||
ProtocolClaimMappingModel addProtocolClaimMapping(String protocolClaim, String protocol, String sourceAttribute,
|
ProtocolClaimMappingModel addProtocolClaimMapping(ProtocolClaimMappingModel model);
|
||||||
ProtocolClaimMappingModel.Source source, boolean appliedByDefault);
|
|
||||||
void removeProtocolClaimMapping(ProtocolClaimMappingModel mapping);
|
void removeProtocolClaimMapping(ProtocolClaimMappingModel mapping);
|
||||||
void updateProtocolClaimMapping(ProtocolClaimMappingModel mapping);
|
void updateProtocolClaimMapping(ProtocolClaimMappingModel mapping);
|
||||||
public ProtocolClaimMappingModel getProtocolClaimMappingById(String id);
|
public ProtocolClaimMappingModel getProtocolClaimMappingById(String id);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.keycloak.models.ClientSessionModel;
|
||||||
import org.keycloak.models.FederatedIdentityModel;
|
import org.keycloak.models.FederatedIdentityModel;
|
||||||
import org.keycloak.models.IdentityProviderModel;
|
import org.keycloak.models.IdentityProviderModel;
|
||||||
import org.keycloak.models.OAuthClientModel;
|
import org.keycloak.models.OAuthClientModel;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RequiredCredentialModel;
|
import org.keycloak.models.RequiredCredentialModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
|
@ -22,6 +23,7 @@ import org.keycloak.representations.idm.CredentialRepresentation;
|
||||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||||
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
||||||
|
import org.keycloak.representations.idm.ProtocolClaimMappingRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
|
@ -155,6 +157,10 @@ public class ModelToRepresentation {
|
||||||
rep.getClaimTypes().add(toRepresentation(claimType));
|
rep.getClaimTypes().add(toRepresentation(claimType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ProtocolClaimMappingModel mapping : realm.getProtocolClaimMappings()) {
|
||||||
|
rep.getProtocolClaimMappings().add(toRepresentation(mapping));
|
||||||
|
}
|
||||||
|
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +326,17 @@ public class ModelToRepresentation {
|
||||||
return providerRep;
|
return providerRep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ProtocolClaimMappingRepresentation toRepresentation(ProtocolClaimMappingModel model) {
|
||||||
|
ProtocolClaimMappingRepresentation rep = new ProtocolClaimMappingRepresentation();
|
||||||
|
rep.setId(model.getId());
|
||||||
|
rep.setProtocol(model.getProtocol());
|
||||||
|
rep.setProtocolClaim(model.getProtocolClaim());
|
||||||
|
rep.setSourceAttribute(model.getSourceAttribute());
|
||||||
|
rep.setSource(model.getSource().name());
|
||||||
|
rep.setAppliedByDefault(model.isAppliedByDefault());
|
||||||
|
return rep;
|
||||||
|
}
|
||||||
|
|
||||||
public static ClaimTypeRepresentation toRepresentation(ClaimTypeModel claimType) {
|
public static ClaimTypeRepresentation toRepresentation(ClaimTypeModel claimType) {
|
||||||
ClaimTypeRepresentation rep = new ClaimTypeRepresentation();
|
ClaimTypeRepresentation rep = new ClaimTypeRepresentation();
|
||||||
rep.setId(claimType.getId());
|
rep.setId(claimType.getId());
|
||||||
|
|
|
@ -6,12 +6,14 @@ import org.keycloak.enums.SslRequired;
|
||||||
import org.keycloak.models.ApplicationModel;
|
import org.keycloak.models.ApplicationModel;
|
||||||
import org.keycloak.models.BrowserSecurityHeaders;
|
import org.keycloak.models.BrowserSecurityHeaders;
|
||||||
import org.keycloak.models.ClaimMask;
|
import org.keycloak.models.ClaimMask;
|
||||||
|
import org.keycloak.models.ClaimTypeModel;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.FederatedIdentityModel;
|
import org.keycloak.models.FederatedIdentityModel;
|
||||||
import org.keycloak.models.IdentityProviderModel;
|
import org.keycloak.models.IdentityProviderModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.OAuthClientModel;
|
import org.keycloak.models.OAuthClientModel;
|
||||||
import org.keycloak.models.PasswordPolicy;
|
import org.keycloak.models.PasswordPolicy;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
import org.keycloak.models.UserCredentialModel;
|
import org.keycloak.models.UserCredentialModel;
|
||||||
|
@ -20,10 +22,12 @@ import org.keycloak.models.UserFederationProviderModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.representations.idm.ApplicationRepresentation;
|
import org.keycloak.representations.idm.ApplicationRepresentation;
|
||||||
import org.keycloak.representations.idm.ClaimRepresentation;
|
import org.keycloak.representations.idm.ClaimRepresentation;
|
||||||
|
import org.keycloak.representations.idm.ClaimTypeRepresentation;
|
||||||
import org.keycloak.representations.idm.CredentialRepresentation;
|
import org.keycloak.representations.idm.CredentialRepresentation;
|
||||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||||
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
||||||
|
import org.keycloak.representations.idm.ProtocolClaimMappingRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.representations.idm.ScopeMappingRepresentation;
|
import org.keycloak.representations.idm.ScopeMappingRepresentation;
|
||||||
|
@ -113,6 +117,8 @@ public class RepresentationToModel {
|
||||||
if (rep.getPasswordPolicy() != null) newRealm.setPasswordPolicy(new PasswordPolicy(rep.getPasswordPolicy()));
|
if (rep.getPasswordPolicy() != null) newRealm.setPasswordPolicy(new PasswordPolicy(rep.getPasswordPolicy()));
|
||||||
|
|
||||||
importIdentityProviders(rep, newRealm);
|
importIdentityProviders(rep, newRealm);
|
||||||
|
importClaimTypes(rep, newRealm);
|
||||||
|
importProtocolClaimMappings(rep, newRealm);
|
||||||
|
|
||||||
if (rep.getApplications() != null) {
|
if (rep.getApplications() != null) {
|
||||||
Map<String, ApplicationModel> appMap = createApplications(rep, newRealm);
|
Map<String, ApplicationModel> appMap = createApplications(rep, newRealm);
|
||||||
|
@ -749,6 +755,21 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void importClaimTypes(RealmRepresentation rep, RealmModel newRealm) {
|
||||||
|
if (rep.getClaimTypes() != null) {
|
||||||
|
for (ClaimTypeRepresentation representation : rep.getClaimTypes()) {
|
||||||
|
newRealm.addClaimType(toModel(representation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void importProtocolClaimMappings(RealmRepresentation rep, RealmModel newRealm) {
|
||||||
|
if (rep.getProtocolClaimMappings() != null) {
|
||||||
|
for (ProtocolClaimMappingRepresentation representation : rep.getProtocolClaimMappings()) {
|
||||||
|
newRealm.addProtocolClaimMapping(toModel(representation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static IdentityProviderModel toModel(IdentityProviderRepresentation representation) {
|
public static IdentityProviderModel toModel(IdentityProviderRepresentation representation) {
|
||||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
||||||
|
@ -765,4 +786,24 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
return identityProviderModel;
|
return identityProviderModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ClaimTypeModel toModel(ClaimTypeRepresentation rep) {
|
||||||
|
ClaimTypeModel model = new ClaimTypeModel();
|
||||||
|
model.setId(rep.getId());
|
||||||
|
model.setType(ClaimTypeModel.ValueType.valueOf(rep.getType()));
|
||||||
|
model.setBuiltIn(rep.isBuiltIn());
|
||||||
|
model.setName(rep.getName());
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProtocolClaimMappingModel toModel(ProtocolClaimMappingRepresentation rep) {
|
||||||
|
ProtocolClaimMappingModel model = new ProtocolClaimMappingModel();
|
||||||
|
model.setId(rep.getId());
|
||||||
|
model.setAppliedByDefault(rep.isAppliedByDefault());
|
||||||
|
model.setSource(ProtocolClaimMappingModel.Source.valueOf(rep.getSource()));
|
||||||
|
model.setSourceAttribute(rep.getSourceAttribute());
|
||||||
|
model.setProtocol(rep.getProtocol());
|
||||||
|
model.setProtocolClaim(rep.getProtocolClaim());
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,9 +857,9 @@ public class RealmAdapter implements RealmModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimTypeModel addClaimType(String name, ClaimTypeModel.ValueType type, boolean builtIn) {
|
public ClaimTypeModel addClaimType(ClaimTypeModel claimType) {
|
||||||
getDelegateForUpdate();
|
getDelegateForUpdate();
|
||||||
return updated.addClaimType(name, type, builtIn);
|
return updated.addClaimType(claimType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -892,9 +892,9 @@ public class RealmAdapter implements RealmModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProtocolClaimMappingModel addProtocolClaimMapping(String protocolClaim, String protocol, String sourceAttribute, ProtocolClaimMappingModel.Source source, boolean appliedByDefault) {
|
public ProtocolClaimMappingModel addProtocolClaimMapping(ProtocolClaimMappingModel model) {
|
||||||
getDelegateForUpdate();
|
getDelegateForUpdate();
|
||||||
return updated.addProtocolClaimMapping(protocolClaim, protocol, sourceAttribute, source, appliedByDefault);
|
return updated.addProtocolClaimMapping(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1206,15 +1206,16 @@ public class RealmAdapter implements RealmModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimTypeModel addClaimType(String name, ClaimTypeModel.ValueType type, boolean builtIn) {
|
public ClaimTypeModel addClaimType(ClaimTypeModel model) {
|
||||||
|
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||||
ClaimTypeEntity claimEntity = new ClaimTypeEntity();
|
ClaimTypeEntity claimEntity = new ClaimTypeEntity();
|
||||||
claimEntity.setId(KeycloakModelUtils.generateId());
|
claimEntity.setId(id);
|
||||||
claimEntity.setType(type.name());
|
claimEntity.setType(model.getType().name());
|
||||||
claimEntity.setBuiltIn(builtIn);
|
claimEntity.setBuiltIn(model.isBuiltIn());
|
||||||
claimEntity.setRealm(realm);
|
claimEntity.setRealm(realm);
|
||||||
em.persist(claimEntity);
|
em.persist(claimEntity);
|
||||||
realm.getClaimTypes().add(claimEntity);
|
realm.getClaimTypes().add(claimEntity);
|
||||||
return new ClaimTypeModel(claimEntity.getId(), name, builtIn, type);
|
return new ClaimTypeModel(claimEntity.getId(), model.getName(), model.isBuiltIn(), model.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ClaimTypeEntity getClaimTypeEntity(ClaimTypeModel claim) {
|
protected ClaimTypeEntity getClaimTypeEntity(ClaimTypeModel claim) {
|
||||||
|
@ -1272,14 +1273,15 @@ public class RealmAdapter implements RealmModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProtocolClaimMappingModel addProtocolClaimMapping(String protocolClaim, String protocol, String sourceAttribute, ProtocolClaimMappingModel.Source source, boolean appliedByDefault) {
|
public ProtocolClaimMappingModel addProtocolClaimMapping(ProtocolClaimMappingModel model) {
|
||||||
|
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||||
ProtocolClaimMappingEntity entity = new ProtocolClaimMappingEntity();
|
ProtocolClaimMappingEntity entity = new ProtocolClaimMappingEntity();
|
||||||
entity.setId(KeycloakModelUtils.generateId());
|
entity.setId(id);
|
||||||
entity.setSourceAttribute(sourceAttribute);
|
entity.setSourceAttribute(model.getSourceAttribute());
|
||||||
entity.setProtocol(protocol);
|
entity.setProtocol(model.getProtocol());
|
||||||
entity.setProtocolClaim(protocolClaim);
|
entity.setProtocolClaim(model.getProtocolClaim());
|
||||||
entity.setSource(source.name());
|
entity.setSource(model.getSource().name());
|
||||||
entity.setAppliedByDefault(appliedByDefault);
|
entity.setAppliedByDefault(model.isAppliedByDefault());
|
||||||
entity.setRealm(realm);
|
entity.setRealm(realm);
|
||||||
em.persist(entity);
|
em.persist(entity);
|
||||||
ProtocolClaimMappingModel mapping = new ProtocolClaimMappingModel();
|
ProtocolClaimMappingModel mapping = new ProtocolClaimMappingModel();
|
||||||
|
|
|
@ -802,14 +802,15 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProtocolClaimMappingModel addProtocolClaimMapping(String protocolClaim, String protocol, String sourceAttribute, ProtocolClaimMappingModel.Source source, boolean appliedByDefault) {
|
public ProtocolClaimMappingModel addProtocolClaimMapping(ProtocolClaimMappingModel model) {
|
||||||
ProtocolClaimMappingEntity entity = new ProtocolClaimMappingEntity();
|
ProtocolClaimMappingEntity entity = new ProtocolClaimMappingEntity();
|
||||||
entity.setId(KeycloakModelUtils.generateId());
|
if (model.getId() != null) entity.setId(model.getId());
|
||||||
entity.setSourceAttribute(sourceAttribute);
|
else entity.setId(KeycloakModelUtils.generateId());
|
||||||
entity.setProtocol(protocol);
|
entity.setSourceAttribute(model.getSourceAttribute());
|
||||||
entity.setProtocolClaim(protocolClaim);
|
entity.setProtocol(model.getProtocol());
|
||||||
entity.setSource(source);
|
entity.setProtocolClaim(model.getProtocolClaim());
|
||||||
entity.setAppliedByDefault(appliedByDefault);
|
entity.setSource(model.getSource());
|
||||||
|
entity.setAppliedByDefault(model.isAppliedByDefault());
|
||||||
realm.getClaimMappings().add(entity);
|
realm.getClaimMappings().add(entity);
|
||||||
updateRealm();
|
updateRealm();
|
||||||
ProtocolClaimMappingModel mapping = new ProtocolClaimMappingModel();
|
ProtocolClaimMappingModel mapping = new ProtocolClaimMappingModel();
|
||||||
|
@ -881,13 +882,14 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimTypeModel addClaimType(String name, ClaimTypeModel.ValueType type, boolean builtIn) {
|
public ClaimTypeModel addClaimType(ClaimTypeModel model) {
|
||||||
ClaimTypeModel claim = new ClaimTypeModel(KeycloakModelUtils.generateId(), name, builtIn, type);
|
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||||
|
ClaimTypeModel claim = new ClaimTypeModel(id, model.getName(), model.isBuiltIn(), model.getType());
|
||||||
ClaimTypeEntity entity = new ClaimTypeEntity();
|
ClaimTypeEntity entity = new ClaimTypeEntity();
|
||||||
entity.setId(claim.getId());
|
entity.setId(claim.getId());
|
||||||
entity.setType(type);
|
entity.setType(model.getType());
|
||||||
entity.setBuiltIn(builtIn);
|
entity.setBuiltIn(model.isBuiltIn());
|
||||||
entity.setName(name);
|
entity.setName(model.getName());
|
||||||
realm.getClaimTypes().add(entity);
|
realm.getClaimTypes().add(entity);
|
||||||
updateRealm();
|
updateRealm();
|
||||||
return claim;
|
return claim;
|
||||||
|
|
Loading…
Reference in a new issue