forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83493fb
commit bcdaebf
Showing
15 changed files
with
259 additions
and
24 deletions.
There are no files selected for viewing
13 changes: 9 additions & 4 deletions
13
.../main/java/org/keycloak/representations/idm/FederatedIdentityAttributeRepresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
model/jpa/src/main/java/org/keycloak/storage/jpa/entity/BrokerLinkAttributeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.keycloak.storage.jpa.entity; | ||
|
||
import javax.persistence.Access; | ||
import javax.persistence.AccessType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.annotations.BatchSize; | ||
import org.hibernate.annotations.Nationalized; | ||
|
||
@Table(name="BROKER_LINK_ATTRIBUTE") | ||
@Entity | ||
public class BrokerLinkAttributeEntity { | ||
|
||
@Id | ||
@Column(name="ID", length = 36) | ||
@Access(AccessType.PROPERTY) // we do this because relationships often fetch id, but not entity. This avoids an extra SQL | ||
private String id; | ||
|
||
@BatchSize(size = 50) | ||
@ManyToOne(fetch= FetchType.LAZY) | ||
@JoinColumn(name="USER_ID", referencedColumnName="USER_ID") | ||
@JoinColumn(name="IDENTITY_PROVIDER", referencedColumnName="IDENTITY_PROVIDER") | ||
private BrokerLinkEntity brokerLink; | ||
|
||
@Column(name = "NAME") | ||
private String name; | ||
@Nationalized | ||
@Column(name = "VALUE") | ||
private String value; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public BrokerLinkEntity getBrokerLinkEntity() { | ||
return brokerLink; | ||
} | ||
|
||
public void setBrokerLinkEntity(BrokerLinkEntity brokerLink) { | ||
this.brokerLink = brokerLink; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null) return false; | ||
if (!(o instanceof BrokerLinkAttributeEntity)) return false; | ||
|
||
BrokerLinkAttributeEntity that = (BrokerLinkAttributeEntity) o; | ||
|
||
if (!id.equals(that.getId())) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return id.hashCode(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,23 @@ | |
|
||
package org.keycloak.storage.jpa.entity; | ||
|
||
import org.hibernate.annotations.BatchSize; | ||
import org.hibernate.annotations.Fetch; | ||
import org.hibernate.annotations.FetchMode; | ||
import org.keycloak.models.jpa.entities.FederatedIdentityAttributeEntity; | ||
import org.keycloak.storage.jpa.KeyUtils; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.IdClass; | ||
import javax.persistence.NamedQueries; | ||
import javax.persistence.NamedQuery; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.Table; | ||
import java.io.Serializable; | ||
import java.util.Collection; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Bill Burke</a> | ||
|
@@ -69,6 +76,11 @@ public class BrokerLinkEntity { | |
@Column(name = "TOKEN") | ||
protected String token; | ||
|
||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy="brokerLink") | ||
@Fetch(FetchMode.SELECT) | ||
@BatchSize(size = 20) | ||
protected Collection<BrokerLinkAttributeEntity> attributes; | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
@@ -126,6 +138,14 @@ public String getToken() { | |
return token; | ||
} | ||
|
||
public Collection<BrokerLinkAttributeEntity> getAttributes() { | ||
return attributes; | ||
} | ||
|
||
public void setAttributes(Collection<BrokerLinkAttributeEntity> attributes) { | ||
this.attributes = attributes; | ||
} | ||
|
||
public static class Key implements Serializable { | ||
|
||
protected String userId; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.