Skip to content

Commit

Permalink
claim mappings next phase
Browse files Browse the repository at this point in the history
  • Loading branch information
patriot1burke committed Feb 25, 2015
1 parent 6c5f357 commit c20ad93
Show file tree
Hide file tree
Showing 39 changed files with 666 additions and 250 deletions.
Expand Up @@ -5,14 +5,21 @@
<column name="ID" type="VARCHAR(36)"> <column name="ID" type="VARCHAR(36)">
<constraints nullable="false"/> <constraints nullable="false"/>
</column> </column>
<column name="NAME" type="VARCHAR(255)"/> <column name="NAME" type="VARCHAR(255)">
<column name="PROTOCOL" type="VARCHAR(255)"/> <constraints nullable="false"/>
<column name="SOURCE" type="VARCHAR(255)"/> </column>
<column name="PROTOCOL_MAPPER_NAME" type="VARCHAR(255)"/> <column name="PROTOCOL" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="PROTOCOL_MAPPER_NAME" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="APPLIED_BY_DEFAULT" type="BOOLEAN(1)"/> <column name="APPLIED_BY_DEFAULT" type="BOOLEAN(1)"/>
<column name="CONSENT_REQUIRED" type="BOOLEAN(1)"/> <column name="CONSENT_REQUIRED" type="BOOLEAN(1)"/>
<column name="CONSENT_TEXT" type="VARCHAR(255)"/> <column name="CONSENT_TEXT" type="VARCHAR(255)"/>
<column name="REALM_ID" type="VARCHAR(36)"/> <column name="REALM_ID" type="VARCHAR(36)">
<constraints nullable="false"/>
</column>
</createTable> </createTable>
<createTable tableName="PROTOCOL_MAPPER_CONFIG"> <createTable tableName="PROTOCOL_MAPPER_CONFIG">
<column name="PROTOCOL_MAPPER_ID" type="VARCHAR(36)"> <column name="PROTOCOL_MAPPER_ID" type="VARCHAR(36)">
Expand Down
143 changes: 73 additions & 70 deletions core/src/main/java/org/keycloak/representations/UserClaimSet.java 100644 → 100755
Expand Up @@ -24,6 +24,75 @@
*/ */
public class UserClaimSet { public class UserClaimSet {


public static class AddressClaimSet {
@JsonProperty("formatted")
protected String formattedAddress;

@JsonProperty("street_address")
protected String streetAddress;

@JsonProperty("locality")
protected String locality;

@JsonProperty("region")
protected String region;

@JsonProperty("postal_code")
protected String postalCode;

@JsonProperty("country")
protected String country;

public String getFormattedAddress() {
return this.formattedAddress;
}

public void setFormattedAddress(String formattedAddress) {
this.formattedAddress = formattedAddress;
}

public String getStreetAddress() {
return this.streetAddress;
}

public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}

public String getLocality() {
return this.locality;
}

public void setLocality(String locality) {
this.locality = locality;
}

public String getRegion() {
return this.region;
}

public void setRegion(String region) {
this.region = region;
}

public String getPostalCode() {
return this.postalCode;
}

public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}

public String getCountry() {
return this.country;
}

public void setCountry(String country) {
this.country = country;
}

}

@JsonProperty("sub") @JsonProperty("sub")
protected String sub; protected String sub;


Expand Down Expand Up @@ -79,29 +148,11 @@ public class UserClaimSet {
protected Boolean phoneNumberVerified; protected Boolean phoneNumberVerified;


@JsonProperty("address") @JsonProperty("address")
protected String address; protected AddressClaimSet address;


@JsonProperty("updated_at") @JsonProperty("updated_at")
protected Long updatedAt; protected Long updatedAt;


@JsonProperty("formatted")
protected String formattedAddress;

@JsonProperty("street_address")
protected String streetAddress;

@JsonProperty("locality")
protected String locality;

@JsonProperty("region")
protected String region;

@JsonProperty("postal_code")
protected String postalCode;

@JsonProperty("country")
protected String country;

@JsonProperty("claims_locales") @JsonProperty("claims_locales")
protected String claimsLocales; protected String claimsLocales;


Expand Down Expand Up @@ -249,11 +300,11 @@ public void setPhoneNumberVerified(Boolean phoneNumberVerified) {
this.phoneNumberVerified = phoneNumberVerified; this.phoneNumberVerified = phoneNumberVerified;
} }


public String getAddress() { public AddressClaimSet getAddress() {
return this.address; return address;
} }


public void setAddress(String address) { public void setAddress(AddressClaimSet address) {
this.address = address; this.address = address;
} }


Expand All @@ -273,54 +324,6 @@ public void setSub(String sub) {
this.sub = sub; this.sub = sub;
} }


public String getFormattedAddress() {
return this.formattedAddress;
}

public void setFormattedAddress(String formattedAddress) {
this.formattedAddress = formattedAddress;
}

public String getStreetAddress() {
return this.streetAddress;
}

public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}

public String getLocality() {
return this.locality;
}

public void setLocality(String locality) {
this.locality = locality;
}

public String getRegion() {
return this.region;
}

public void setRegion(String region) {
this.region = region;
}

public String getPostalCode() {
return this.postalCode;
}

public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}

public String getCountry() {
return this.country;
}

public void setCountry(String country) {
this.country = country;
}

public String getClaimsLocales() { public String getClaimsLocales() {
return this.claimsLocales; return this.claimsLocales;
} }
Expand Down
Expand Up @@ -30,7 +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; protected Set<String> protocolMappers;


public String getId() { public String getId() {
return id; return id;
Expand Down Expand Up @@ -200,11 +200,11 @@ public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
this.allowedIdentityProviders = allowedIdentityProviders; this.allowedIdentityProviders = allowedIdentityProviders;
} }


public Set<String> getProtocolClaimMappings() { public Set<String> getProtocolMappers() {
return protocolClaimMappings; return protocolMappers;
} }


public void setProtocolClaimMappings(Set<String> protocolClaimMappings) { public void setProtocolMappers(Set<String> protocolMappers) {
this.protocolClaimMappings = protocolClaimMappings; this.protocolMappers = protocolMappers;
} }
} }
@@ -1,6 +1,7 @@
package org.keycloak.representations.idm; package org.keycloak.representations.idm;


import java.util.ArrayList; import java.util.ArrayList;
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;
Expand Down Expand Up @@ -64,7 +65,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<ProtocolMapperRepresentation> protocolClaimMappings; private List<ProtocolMapperRepresentation> protocolMappers;
private Boolean identityFederationEnabled; private Boolean identityFederationEnabled;


public String getId() { public String getId() {
Expand Down Expand Up @@ -492,11 +493,16 @@ public void setClaimTypes(List<ClaimTypeRepresentation> claimTypes) {
this.claimTypes = claimTypes; this.claimTypes = claimTypes;
} }


public List<ProtocolMapperRepresentation> getProtocolClaimMappings() { public List<ProtocolMapperRepresentation> getProtocolMappers() {
return protocolClaimMappings; return protocolMappers;
} }


public void setProtocolClaimMappings(List<ProtocolMapperRepresentation> protocolClaimMappings) { public void addProtocolMapper(ProtocolMapperRepresentation rep) {
this.protocolClaimMappings = protocolClaimMappings; if (protocolMappers == null) protocolMappers = new LinkedList<ProtocolMapperRepresentation>();
protocolMappers.add(rep);
}

public void setProtocolMappers(List<ProtocolMapperRepresentation> protocolMappers) {
this.protocolMappers = protocolMappers;
} }
} }
5 changes: 3 additions & 2 deletions model/api/src/main/java/org/keycloak/models/ClientModel.java
Expand Up @@ -105,6 +105,7 @@ public interface ClientModel {
boolean hasIdentityProvider(String providerId); boolean hasIdentityProvider(String providerId);


Set<ProtocolMapperModel> getProtocolMappers(); Set<ProtocolMapperModel> getProtocolMappers();
void addProtocolMappers(Set<String> mapperIds); void addProtocolMappers(Set<String> mapperNames);
void removeProtocolMappers(Set<String> mapperIds); void removeProtocolMappers(Set<String> mapperNames);
void setProtocolMappers(Set<String> mapperNames);
} }
15 changes: 15 additions & 0 deletions model/api/src/main/java/org/keycloak/models/RealmModel.java
@@ -1,6 +1,7 @@
package org.keycloak.models; package org.keycloak.models;


import org.keycloak.enums.SslRequired; import org.keycloak.enums.SslRequired;
import org.keycloak.provider.ProviderEvent;


import java.security.Key; import java.security.Key;
import java.security.PrivateKey; import java.security.PrivateKey;
Expand All @@ -15,6 +16,19 @@
* @version $Revision: 1 $ * @version $Revision: 1 $
*/ */
public interface RealmModel extends RoleContainerModel { public interface RealmModel extends RoleContainerModel {
interface RealmCreationEvent extends ProviderEvent {
RealmModel getCreatedRealm();
}
interface ClientCreationEvent extends ProviderEvent {
RealmModel getCreatedRealm();
ClientModel getCreatedClient();
}
interface ApplicationCreationEvent extends ClientCreationEvent {
ApplicationModel getCreatedApplication();
}
interface OAuthClientCreationEvent extends ClientCreationEvent {
OAuthClientModel getCreatedOAuthClient();
}


String getId(); String getId();


Expand Down Expand Up @@ -235,6 +249,7 @@ public interface RealmModel extends RoleContainerModel {
void removeProtocolMapper(ProtocolMapperModel mapping); void removeProtocolMapper(ProtocolMapperModel mapping);
void updateProtocolMapper(ProtocolMapperModel mapping); void updateProtocolMapper(ProtocolMapperModel mapping);
public ProtocolMapperModel getProtocolMapperById(String id); public ProtocolMapperModel getProtocolMapperById(String id);
public ProtocolMapperModel getProtocolMapperByName(String name);




} }
Expand Up @@ -10,9 +10,6 @@
* @version $Revision: 1 $ * @version $Revision: 1 $
*/ */
public interface RealmProvider extends Provider { public interface RealmProvider extends Provider {
public interface RealmCreationEvent extends ProviderEvent {
RealmModel getCreatedRealm();
}


// Note: The reason there are so many query methods here is for layering a cache on top of an persistent KeycloakSession // Note: The reason there are so many query methods here is for layering a cache on top of an persistent KeycloakSession


Expand Down
Expand Up @@ -30,7 +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>(); private Set<String> protocolMappers = new HashSet<String>();


public String getName() { public String getName() {
return name; return name;
Expand Down Expand Up @@ -152,11 +152,11 @@ public void setAllowedIdentityProviders(List<String> allowedIdentityProviders) {
this.allowedIdentityProviders = allowedIdentityProviders; this.allowedIdentityProviders = allowedIdentityProviders;
} }


public Set<String> getProtocolClaimMappings() { public Set<String> getProtocolMappers() {
return protocolClaimMappings; return protocolMappers;
} }


public void setProtocolClaimMappings(Set<String> protocolClaimMappings) { public void setProtocolMappers(Set<String> protocolMappers) {
this.protocolClaimMappings = protocolClaimMappings; this.protocolMappers = protocolMappers;
} }
} }
Expand Up @@ -158,7 +158,7 @@ public static RealmRepresentation toRepresentation(RealmModel realm, boolean int
} }


for (ProtocolMapperModel mapping : realm.getProtocolMappers()) { for (ProtocolMapperModel mapping : realm.getProtocolMappers()) {
rep.getProtocolClaimMappings().add(toRepresentation(mapping)); rep.addProtocolMapper(toRepresentation(mapping));
} }


return rep; return rep;
Expand Down Expand Up @@ -267,8 +267,8 @@ public static ApplicationRepresentation toRepresentation(ApplicationModel applic


if (!applicationModel.getProtocolMappers().isEmpty()) { if (!applicationModel.getProtocolMappers().isEmpty()) {
Set<String> mappings = new HashSet<String>(); Set<String> mappings = new HashSet<String>();
for (ProtocolMapperModel model : applicationModel.getProtocolMappers()) mappings.add(model.getId()); for (ProtocolMapperModel model : applicationModel.getProtocolMappers()) mappings.add(model.getName());
rep.setProtocolClaimMappings(mappings); rep.setProtocolMappers(mappings);
} }


return rep; return rep;
Expand Down Expand Up @@ -302,7 +302,7 @@ public static OAuthClientRepresentation toRepresentation(OAuthClientModel model)


if (!model.getProtocolMappers().isEmpty()) { if (!model.getProtocolMappers().isEmpty()) {
Set<String> mappings = new HashSet<String>(); Set<String> mappings = new HashSet<String>();
for (ProtocolMapperModel mappingMoel : model.getProtocolMappers()) mappings.add(mappingMoel.getId()); for (ProtocolMapperModel mappingModel : model.getProtocolMappers()) mappings.add(mappingModel.getName());
rep.setProtocolClaimMappings(mappings); rep.setProtocolClaimMappings(mappings);
} }
return rep; return rep;
Expand Down

0 comments on commit c20ad93

Please sign in to comment.