*/
public abstract class AbstractPersistent implements Persistent {
- private Serializable primaryKey;
+ private Serializable id;
private Number version;
protected AbstractPersistent() {
- primaryKey = null;
+ id = null;
version = -1;
}
* Object to copy.
*/
protected AbstractPersistent(AbstractPersistent aPersistent) {
- primaryKey = aPersistent.primaryKey;
+ id = aPersistent.id;
version = aPersistent.version;
}
*/
@Override
public Serializable getPrimaryKey() {
- return primaryKey;
+ return id;
}
/*
*/
@Override
public void setPrimaryKey(Serializable aKey) {
- primaryKey = aKey;
+ id = aKey;
}
/*
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
*
*/
public Group(Group aGroup) {
- primaryKey = aGroup.primaryKey;
+ id = aGroup.id;
version = aGroup.version;
name = aGroup.name;
}
}
public Long getPrimaryKey() {
- return primaryKey;
+ return id;
}
public void setPrimaryKey(Long aKey) {
- primaryKey = aKey;
+ id = aKey;
}
/*
import java.util.TreeSet;
import javax.persistence.CascadeType;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
* Groups the user belongs to.
*/
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
+ @JoinTable(name = "SEC_USER_GROUP", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "GROUP_ID") })
private Set<Group> groups;
/**
*
*/
public User(User aUser) {
- primaryKey = aUser.primaryKey;
+ id = aUser.id;
version = aUser.version;
name = aUser.name;
password = aUser.password;
}
public Long getPrimaryKey() {
- return primaryKey;
+ return id;
}
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
}
public AbstractAuthorizationRule(AbstractAuthorizationRule aRule) {
- primaryKey = aRule.primaryKey;
+ id = aRule.id;
version = aRule.version;
}
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
}
public AbstractAuthorizationService(AbstractAuthorizationService aSvc) {
- primaryKey = aSvc.primaryKey;
+ id = aSvc.id;
version = aSvc.version;
name = aSvc.name;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
}
public AbstractOperationCondition(AbstractOperationCondition aCondition) {
- primaryKey = aCondition.primaryKey;
+ id = aCondition.id;
version = aCondition.version;
}
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
}
public AbstractPathCondition(AbstractPathCondition aCondition) {
- primaryKey = aCondition.primaryKey;
+ id = aCondition.id;
version = aCondition.version;
}
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- private Long primaryKey;
+ private Long id;
@Version
private int version;
}
public AbstractUserCondition(AbstractUserCondition aCondition) {
- primaryKey = aCondition.primaryKey;
+ id = aCondition.id;
version = aCondition.version;
}
}
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
-import javax.persistence.ManyToMany;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import javax.persistence.Transient;
-import org.wamblee.security.authentication.User;
import org.wamblee.security.authentication.UserAccessor;
import org.wamblee.security.authentication.UserAdministration;
* List of ordered authorization rules.
*/
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, targetEntity = AbstractAuthorizationRule.class)
+ @JoinTable(name = "SEC_AUTH_SVC_RULE", joinColumns = { @JoinColumn(name = "SVC_ID") }, inverseJoinColumns = { @JoinColumn(name = "RULE_ID") })
@OrderColumn(name = "RULE_INDEX")
private List<AuthorizationRule> rules;
super(aName);
rules = new ArrayList<AuthorizationRule>();
userAccessor = aAccessor;
- userAdmin = aUserAdmin;
+ userAdmin = aUserAdmin;
}
/**
public DefaultAuthorizationService() {
rules = new ArrayList<AuthorizationRule>();
userAccessor = null;
- userAdmin = null;
+ userAdmin = null;
}
-
@Override
public void setUserAccessor(UserAccessor aUserAccessor) {
userAccessor = aUserAccessor;
}
-
+
@Override
public void setUserAdministration(UserAdministration aUserAdmin) {
userAdmin = aUserAdmin;
- for (AuthorizationRule rule: rules) {
+ for (AuthorizationRule rule : rules) {
rule.setUserAdministration(userAdmin);
}
}
*/
protected void setMappedRules(List<AuthorizationRule> aRules) {
rules = aRules;
- for (AuthorizationRule rule: rules) {
+ for (AuthorizationRule rule : rules) {
rule.setUserAdministration(userAdmin);
}
}
import org.wamblee.security.encryption.Md5HexMessageDigester;
import org.wamblee.security.encryption.MessageDigester;
import org.wamblee.support.persistence.JpaTester;
+import org.wamblee.support.persistence.PersistenceUnitDescription;
import org.wamblee.support.persistence.TransactionProxyFactory;
/**
*/
public class UserAdministrationTester {
+ private PersistenceUnitDescription persistenceUnit;
private JpaTester jpaTester;
private Cache<String, User> userCache;
private UserAdministration userAdmin;
public UserAdministrationTester() {
- jpaTester = new JpaTester(new SecurityPersistenceUnit());
+ persistenceUnit = new SecurityPersistenceUnit();
+ jpaTester = new JpaTester(persistenceUnit);
}
public void start() throws Exception {
userAdmin = factory.getProxy(userAdminImpl);
}
+ public PersistenceUnitDescription getPersistenceUnit() {
+ return persistenceUnit;
+ }
public JpaTester getJpaTester() {
return jpaTester;
private static final String RULES_TABLE = "SEC_AUTH_RULE";
- private static final String SERVICE_RULES_TABLE = "SEC_AUTH_SVC_SEC_AUTH_RULE";
+ private static final String SERVICE_RULES_TABLE = "SEC_AUTH_SVC_RULE";
private static final String OPERATIONCOND_TABLE = "SEC_OPERATION_CONDITION";