Merge pull request #976 from patriot1burke/master
client to protocol mapping model
This commit is contained in:
commit
6097ecb53f
22 changed files with 388 additions and 46 deletions
|
@ -63,6 +63,14 @@
|
||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
<createTable tableName="CLIENT_PROTOCOL_CLAIM_MAPPING">
|
||||||
|
<column name="CLIENT_ID" type="VARCHAR(36)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="MAPPING_ID" type="VARCHAR(36)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
<addColumn tableName="CLIENT">
|
<addColumn tableName="CLIENT">
|
||||||
<column name="FRONTCHANNEL_LOGOUT" type="BOOLEAN" defaultValueBoolean="false"/>
|
<column name="FRONTCHANNEL_LOGOUT" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
|
@ -78,6 +86,8 @@
|
||||||
<addForeignKeyConstraint baseColumnNames="IDENTITY_PROVIDER_ID" baseTableName="IDENTITY_PROVIDER_CONFIG" constraintName="FKDC4897CF864C4E43" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/>
|
<addForeignKeyConstraint baseColumnNames="IDENTITY_PROVIDER_ID" baseTableName="IDENTITY_PROVIDER_CONFIG" constraintName="FKDC4897CF864C4E43" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/>
|
||||||
<addForeignKeyConstraint baseColumnNames="INTERNAL_ID" baseTableName="CLIENT_ALLOWED_IDENTITY_PROVIDER" constraintName="FK_7CELWNIBJI49AVXSRTUF6XJ12" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/>
|
<addForeignKeyConstraint baseColumnNames="INTERNAL_ID" baseTableName="CLIENT_ALLOWED_IDENTITY_PROVIDER" constraintName="FK_7CELWNIBJI49AVXSRTUF6XJ12" referencedColumnNames="INTERNAL_ID" referencedTableName="IDENTITY_PROVIDER"/>
|
||||||
<addUniqueConstraint columnNames="INTERNAL_ID,CLIENT_ID" constraintName="UK_7CAELWNIBJI49AVXSRTUF6XJ12" tableName="CLIENT_ALLOWED_IDENTITY_PROVIDER"/>
|
<addUniqueConstraint columnNames="INTERNAL_ID,CLIENT_ID" constraintName="UK_7CAELWNIBJI49AVXSRTUF6XJ12" tableName="CLIENT_ALLOWED_IDENTITY_PROVIDER"/>
|
||||||
|
<addForeignKeyConstraint baseColumnNames="MAPPING_ID" baseTableName="CLIENT_PROTOCOL_CLAIM_MAPPING" constraintName="FK_CPCM" referencedColumnNames="ID" referencedTableName="PROTOCOL_CLAIM_MAPPING"/>
|
||||||
|
<addUniqueConstraint columnNames="CLIENT_ID,MAPPING_ID" constraintName="UK_CPCM" tableName="CLIENT_PROTOCOL_CLAIM_MAPPING"/>
|
||||||
<addUniqueConstraint columnNames="PROVIDER_NONIMAL_ID" constraintName="UK_2DAELWNIBJI49AVXSRTUF6XJ33" tableName="IDENTITY_PROVIDER"/>
|
<addUniqueConstraint columnNames="PROVIDER_NONIMAL_ID" constraintName="UK_2DAELWNIBJI49AVXSRTUF6XJ33" tableName="IDENTITY_PROVIDER"/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.keycloak.representations.idm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
@ -29,6 +30,7 @@ public class ApplicationRepresentation {
|
||||||
protected Integer nodeReRegistrationTimeout;
|
protected Integer nodeReRegistrationTimeout;
|
||||||
protected Map<String, Integer> registeredNodes;
|
protected Map<String, Integer> registeredNodes;
|
||||||
protected List<String> allowedIdentityProviders;
|
protected List<String> allowedIdentityProviders;
|
||||||
|
protected Set<String> protocolClaimMappings;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -197,4 +199,12 @@ public class ApplicationRepresentation {
|
||||||
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
||||||
this.allowedIdentityProviders = allowedIdentityProviders;
|
this.allowedIdentityProviders = allowedIdentityProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaimMappings(Set<String> protocolClaimMappings) {
|
||||||
|
this.protocolClaimMappings = protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.keycloak.representations.idm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
@ -23,6 +24,7 @@ public class OAuthClientRepresentation {
|
||||||
protected Boolean fullScopeAllowed;
|
protected Boolean fullScopeAllowed;
|
||||||
protected Boolean frontchannelLogout;
|
protected Boolean frontchannelLogout;
|
||||||
protected List<String> allowedIdentityProviders;
|
protected List<String> allowedIdentityProviders;
|
||||||
|
protected Set<String> protocolClaimMappings;
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -144,4 +146,12 @@ public class OAuthClientRepresentation {
|
||||||
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
||||||
this.allowedIdentityProviders = allowedIdentityProviders;
|
this.allowedIdentityProviders = allowedIdentityProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaimMappings(Set<String> protocolClaimMappings) {
|
||||||
|
this.protocolClaimMappings = protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -104,10 +104,7 @@ public interface ClientModel {
|
||||||
|
|
||||||
boolean hasIdentityProvider(String providerId);
|
boolean hasIdentityProvider(String providerId);
|
||||||
|
|
||||||
/*
|
Set<ProtocolClaimMappingModel> getProtocolClaimMappings();
|
||||||
Set<ProtocolClaimMapping> getClaimMappings();
|
void addProtocolClaimMappings(Set<String> mappingIds);
|
||||||
ProtocolClaimMapping getClaimMapping(String protocolClaim);
|
void removeProtocolClaimMappings(Set<String> mappingIds);
|
||||||
ProtocolClaimMapping addClaimMapping(String assertion, String protocol, ClaimTypeModel claimType);
|
|
||||||
void removeClaimMapping(ProtocolClaimMapping mapping);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -2,8 +2,10 @@ package org.keycloak.models.entities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
@ -28,6 +30,7 @@ public class ClientEntity extends AbstractIdentifiableEntity {
|
||||||
private List<String> redirectUris = new ArrayList<String>();
|
private List<String> redirectUris = new ArrayList<String>();
|
||||||
private List<String> scopeIds = new ArrayList<String>();
|
private List<String> scopeIds = new ArrayList<String>();
|
||||||
private List<String> allowedIdentityProviders = new ArrayList<String>();
|
private List<String> allowedIdentityProviders = new ArrayList<String>();
|
||||||
|
private Set<String> protocolClaimMappings = new HashSet<String>();
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -148,4 +151,12 @@ public class ClientEntity extends AbstractIdentifiableEntity {
|
||||||
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
|
||||||
this.allowedIdentityProviders = allowedIdentityProviders;
|
this.allowedIdentityProviders = allowedIdentityProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaimMappings(Set<String> protocolClaimMappings) {
|
||||||
|
this.protocolClaimMappings = protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +265,12 @@ public class ModelToRepresentation {
|
||||||
rep.setAllowedIdentityProviders(applicationModel.getAllowedIdentityProviders());
|
rep.setAllowedIdentityProviders(applicationModel.getAllowedIdentityProviders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!applicationModel.getProtocolClaimMappings().isEmpty()) {
|
||||||
|
Set<String> mappings = new HashSet<String>();
|
||||||
|
for (ProtocolClaimMappingModel model : applicationModel.getProtocolClaimMappings()) mappings.add(model.getId());
|
||||||
|
rep.setProtocolClaimMappings(mappings);
|
||||||
|
}
|
||||||
|
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,6 +300,11 @@ public class ModelToRepresentation {
|
||||||
rep.setAllowedIdentityProviders(model.getAllowedIdentityProviders());
|
rep.setAllowedIdentityProviders(model.getAllowedIdentityProviders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!model.getProtocolClaimMappings().isEmpty()) {
|
||||||
|
Set<String> mappings = new HashSet<String>();
|
||||||
|
for (ProtocolClaimMappingModel mappingMoel : model.getProtocolClaimMappings()) mappings.add(mappingMoel.getId());
|
||||||
|
rep.setProtocolClaimMappings(mappings);
|
||||||
|
}
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +337,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);
|
||||||
|
@ -454,6 +460,10 @@ public class RepresentationToModel {
|
||||||
applicationModel.setAllowedClaimsMask(ClaimMask.ALL);
|
applicationModel.setAllowedClaimsMask(ClaimMask.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resourceRep.getProtocolClaimMappings() != null) {
|
||||||
|
applicationModel.addProtocolClaimMappings(resourceRep.getProtocolClaimMappings());
|
||||||
|
}
|
||||||
|
|
||||||
return applicationModel;
|
return applicationModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,6 +636,11 @@ public class RepresentationToModel {
|
||||||
if (rep.getAllowedIdentityProviders() != null) {
|
if (rep.getAllowedIdentityProviders() != null) {
|
||||||
model.updateAllowedIdentityProviders(rep.getAllowedIdentityProviders());
|
model.updateAllowedIdentityProviders(rep.getAllowedIdentityProviders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rep.getProtocolClaimMappings() != null) {
|
||||||
|
model.addProtocolClaimMappings(rep.getProtocolClaimMappings());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scope mappings
|
// Scope mappings
|
||||||
|
@ -749,6 +764,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 +795,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.keycloak.models.cache;
|
package org.keycloak.models.cache;
|
||||||
|
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RoleContainerModel;
|
import org.keycloak.models.RoleContainerModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
|
@ -278,4 +279,23 @@ public abstract class ClientAdapter implements ClientModel {
|
||||||
if (updatedClient != null) return updatedClient.hasIdentityProvider(providerId);
|
if (updatedClient != null) return updatedClient.hasIdentityProvider(providerId);
|
||||||
return cachedClient.hasIdentityProvider(providerId);
|
return cachedClient.hasIdentityProvider(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ProtocolClaimMappingModel> getProtocolClaimMappings() {
|
||||||
|
if (updatedClient != null) return updatedClient.getProtocolClaimMappings();
|
||||||
|
return cachedClient.getProtocolClaimMappings(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addProtocolClaimMappings(Set<String> mappingIds) {
|
||||||
|
getDelegateForUpdate();
|
||||||
|
updatedClient.addProtocolClaimMappings(mappingIds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeProtocolClaimMappings(Set<String> mappingIds) {
|
||||||
|
getDelegateForUpdate();
|
||||||
|
updatedClient.removeProtocolClaimMappings(mappingIds);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.keycloak.models.cache.entities;
|
package org.keycloak.models.cache.entities;
|
||||||
|
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RealmProvider;
|
import org.keycloak.models.RealmProvider;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
|
@ -35,6 +36,7 @@ public class CachedClient {
|
||||||
protected Set<String> scope = new HashSet<String>();
|
protected Set<String> scope = new HashSet<String>();
|
||||||
protected Set<String> webOrigins = new HashSet<String>();
|
protected Set<String> webOrigins = new HashSet<String>();
|
||||||
private List<String> allowedIdentityProviders = new ArrayList<String>();
|
private List<String> allowedIdentityProviders = new ArrayList<String>();
|
||||||
|
private Set<ProtocolClaimMappingModel> protocolClaimMappings = new HashSet<ProtocolClaimMappingModel>();
|
||||||
|
|
||||||
public CachedClient(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientModel model) {
|
public CachedClient(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientModel model) {
|
||||||
id = model.getId();
|
id = model.getId();
|
||||||
|
@ -56,6 +58,7 @@ public class CachedClient {
|
||||||
scope.add(role.getId());
|
scope.add(role.getId());
|
||||||
}
|
}
|
||||||
this.allowedIdentityProviders = model.getAllowedIdentityProviders();
|
this.allowedIdentityProviders = model.getAllowedIdentityProviders();
|
||||||
|
protocolClaimMappings.addAll(model.getProtocolClaimMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -122,10 +125,6 @@ public class CachedClient {
|
||||||
return frontchannelLogout;
|
return frontchannelLogout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFrontchannelLogout(boolean frontchannelLogout) {
|
|
||||||
this.frontchannelLogout = frontchannelLogout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getAllowedIdentityProviders() {
|
public List<String> getAllowedIdentityProviders() {
|
||||||
return this.allowedIdentityProviders;
|
return this.allowedIdentityProviders;
|
||||||
}
|
}
|
||||||
|
@ -137,4 +136,8 @@ public class CachedClient {
|
||||||
|
|
||||||
return this.allowedIdentityProviders.contains(providerId);
|
return this.allowedIdentityProviders.contains(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<ProtocolClaimMappingModel> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package org.keycloak.models.jpa;
|
package org.keycloak.models.jpa;
|
||||||
|
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RoleContainerModel;
|
import org.keycloak.models.RoleContainerModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
import org.keycloak.models.jpa.entities.ClientEntity;
|
import org.keycloak.models.jpa.entities.ClientEntity;
|
||||||
import org.keycloak.models.jpa.entities.IdentityProviderEntity;
|
import org.keycloak.models.jpa.entities.IdentityProviderEntity;
|
||||||
|
import org.keycloak.models.jpa.entities.ProtocolClaimMappingEntity;
|
||||||
import org.keycloak.models.jpa.entities.RoleEntity;
|
import org.keycloak.models.jpa.entities.RoleEntity;
|
||||||
import org.keycloak.models.jpa.entities.ScopeMappingEntity;
|
import org.keycloak.models.jpa.entities.ScopeMappingEntity;
|
||||||
|
|
||||||
|
@ -15,6 +17,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -352,4 +355,53 @@ public abstract class ClientAdapter implements ClientModel {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ProtocolClaimMappingModel> getProtocolClaimMappings() {
|
||||||
|
Set<ProtocolClaimMappingModel> mappings = new HashSet<ProtocolClaimMappingModel>();
|
||||||
|
for (ProtocolClaimMappingEntity entity : this.entity.getProtocolClaimMappings()) {
|
||||||
|
ProtocolClaimMappingModel mapping = new ProtocolClaimMappingModel();
|
||||||
|
mapping.setId(entity.getId());
|
||||||
|
mapping.setProtocol(entity.getProtocol());
|
||||||
|
mapping.setProtocolClaim(entity.getProtocolClaim());
|
||||||
|
mapping.setAppliedByDefault(entity.isAppliedByDefault());
|
||||||
|
mapping.setSource(ProtocolClaimMappingModel.Source.valueOf(entity.getSource()));
|
||||||
|
mapping.setSourceAttribute(entity.getSourceAttribute());
|
||||||
|
mappings.add(mapping);
|
||||||
|
}
|
||||||
|
return mappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addProtocolClaimMappings(Set<String> mappings) {
|
||||||
|
Collection<ProtocolClaimMappingEntity> entities = entity.getProtocolClaimMappings();
|
||||||
|
Set<String> already = new HashSet<String>();
|
||||||
|
for (ProtocolClaimMappingEntity rel : entities) {
|
||||||
|
already.add(rel.getId());
|
||||||
|
}
|
||||||
|
for (String providerId : mappings) {
|
||||||
|
if (!already.contains(providerId)) {
|
||||||
|
ProtocolClaimMappingEntity mapping = em.find(ProtocolClaimMappingEntity.class, providerId);
|
||||||
|
if (mapping != null) {
|
||||||
|
entities.add(mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
em.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeProtocolClaimMappings(Set<String> mappings) {
|
||||||
|
Collection<ProtocolClaimMappingEntity> entities = entity.getProtocolClaimMappings();
|
||||||
|
List<ProtocolClaimMappingEntity> remove = new LinkedList<ProtocolClaimMappingEntity>();
|
||||||
|
for (ProtocolClaimMappingEntity rel : entities) {
|
||||||
|
if (mappings.contains(rel.getId())) remove.add(rel);
|
||||||
|
}
|
||||||
|
for (ProtocolClaimMappingEntity entity : remove) {
|
||||||
|
entities.remove(entity);
|
||||||
|
}
|
||||||
|
em.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.keycloak.models.jpa.entities;
|
package org.keycloak.models.jpa.entities;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.CollectionTable;
|
import javax.persistence.CollectionTable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.ElementCollection;
|
import javax.persistence.ElementCollection;
|
||||||
|
@ -76,6 +77,10 @@ public abstract class ClientEntity {
|
||||||
@JoinTable(name="CLIENT_ALLOWED_IDENTITY_PROVIDER", joinColumns = { @JoinColumn(name="CLIENT_ID")}, inverseJoinColumns = { @JoinColumn(name="INTERNAL_ID")})
|
@JoinTable(name="CLIENT_ALLOWED_IDENTITY_PROVIDER", joinColumns = { @JoinColumn(name="CLIENT_ID")}, inverseJoinColumns = { @JoinColumn(name="INTERNAL_ID")})
|
||||||
Collection<IdentityProviderEntity> allowedIdentityProviders = new ArrayList<IdentityProviderEntity>();
|
Collection<IdentityProviderEntity> allowedIdentityProviders = new ArrayList<IdentityProviderEntity>();
|
||||||
|
|
||||||
|
@OneToMany(cascade ={CascadeType.REMOVE})
|
||||||
|
@JoinTable(name="CLIENT_PROTOCOL_CLAIM_MAPPING", joinColumns = { @JoinColumn(name="CLIENT_ID")}, inverseJoinColumns = { @JoinColumn(name="MAPPING_ID")})
|
||||||
|
Collection<ProtocolClaimMappingEntity> protocolClaimMappings = new ArrayList<ProtocolClaimMappingEntity>();
|
||||||
|
|
||||||
public RealmEntity getRealm() {
|
public RealmEntity getRealm() {
|
||||||
return realm;
|
return realm;
|
||||||
}
|
}
|
||||||
|
@ -195,4 +200,12 @@ public abstract class ClientEntity {
|
||||||
public void setAllowedIdentityProviders(Collection<IdentityProviderEntity> allowedIdentityProviders) {
|
public void setAllowedIdentityProviders(Collection<IdentityProviderEntity> allowedIdentityProviders) {
|
||||||
this.allowedIdentityProviders = allowedIdentityProviders;
|
this.allowedIdentityProviders = allowedIdentityProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<ProtocolClaimMappingEntity> getProtocolClaimMappings() {
|
||||||
|
return protocolClaimMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolClaimMappings(Collection<ProtocolClaimMappingEntity> protocolClaimMappings) {
|
||||||
|
this.protocolClaimMappings = protocolClaimMappings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,4 +138,6 @@ public class IdentityProviderEntity {
|
||||||
public void setConfig(Map<String, String> config) {
|
public void setConfig(Map<String, String> config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -95,4 +95,21 @@ public class ProtocolClaimMappingEntity {
|
||||||
public void setRealm(RealmEntity realm) {
|
public void setRealm(RealmEntity realm) {
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ProtocolClaimMappingEntity that = (ProtocolClaimMappingEntity) o;
|
||||||
|
|
||||||
|
if (!id.equals(that.id)) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return id.hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.keycloak.connections.mongo.api.MongoIdentifiableEntity;
|
||||||
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
import org.keycloak.models.ProtocolClaimMappingModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RealmProvider;
|
import org.keycloak.models.RealmProvider;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
|
@ -291,6 +292,29 @@ public abstract class ClientAdapter<T extends MongoIdentifiableEntity> extends A
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ProtocolClaimMappingModel> getProtocolClaimMappings() {
|
||||||
|
Set<ProtocolClaimMappingModel> result = new HashSet<ProtocolClaimMappingModel>();
|
||||||
|
for (String id : getMongoEntityAsClient().getProtocolClaimMappings()) {
|
||||||
|
ProtocolClaimMappingModel model = getRealm().getProtocolClaimMappingById(id);
|
||||||
|
if (model != null) result.add(model);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addProtocolClaimMappings(Set<String> mappingIds) {
|
||||||
|
getMongoEntityAsClient().getProtocolClaimMappings().addAll(mappingIds);
|
||||||
|
updateMongoEntity();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeProtocolClaimMappings(Set<String> mappingIds) {
|
||||||
|
getMongoEntityAsClient().getProtocolClaimMappings().removeAll(mappingIds);
|
||||||
|
updateMongoEntity();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAllowedIdentityProviders(List<String> identityProviders) {
|
public void updateAllowedIdentityProviders(List<String> identityProviders) {
|
||||||
List<String> providerIds = new ArrayList<String>();
|
List<String> providerIds = new ArrayList<String>();
|
||||||
|
|
|
@ -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