我正在尝试将 Seam 2 应用程序迁移到 CDI 并使用 PicketLink 来确保安全。经过所有的阅读和研究,似乎所有示例都在 PicketLink 模型和后端实体之间进行了一对一的映射。例如,Account 到 AccountEntity,Partition 到 PartitionEntity。由于我已经有了代表身份模型的实体,所以我一直试图将它们映射到 PicketLink。这是我所拥有的:
@MappedSuperClass
public class ModelEntityBase implement Serializable {
@Id @Generated
Long id;
Date creationDate;
}
@Entity
public Account extends ModelEntityBase {
String username;
String passwordHash;
@OneToOne(mappedBy = "account")
Person person;
}
@Entity
public Person extends ModelEntityBase {
String name;
String email;
@OneToOne
@JoinColumn(name = "account_id")
Account account;
}
在PicketLink 中表示单个身份模型的两个实体(加上一个超类),例如立体类型User。
基于这个为什么 IdentityType id is String not Long,我尝试在以下位置添加一个新实体:
@Entity
@IdentityManaged(BaseIdentityType.class);
public class IdentityTypeEntity implement Serializble {
@Id @Identifier
private String id;
@OneToOne(optional = false, mappedBy = "identityType")
@OwnerReference
private Account account;
@IdentityClass
private String typeName;
@ManyToOne @OwnerReference
private PartitionEntity partition;
}
我尝试了几种不同的注释和模型类方法。但是当使用 IdentityManager.add(myUserModel) 时,我无法让它填充所有实体。这甚至可能吗?