AclObjectIdentity.java
Code:
/*
* This object is not intended to replace org.springframework.security.acls.objectidentity
* It is used for Hibernate access to the ACL tables to allow "hand" administration of
* ACLs
*/
package com.x.y.model;
import com.pnm.ERM.model.AclClass;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import org.appfuse.model.BaseObject;
import org.hibernate.annotations.IndexColumn;
/**
*
* @author jvance
*/
@Entity(name="acl_object_identity")
public class AclObjectIdentity extends BaseObject{
private Long id;
private Long objectIdentity;
private Long objectClassId;
private Long parentObject;
private Boolean inheriting;
private List<AclEntry> AclEntries;
private Long ownerSidId;
private AclSid ownerSid;
private AclClass objectClass;
@Override
public String toString(){
return "ID: " + id + " Class: " + objectClass.toString() + " ID: " + objectIdentity.toString();
}
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="inheriting", nullable=false)
public Boolean getInheriting() {
return inheriting;
}
public void setInheriting(Boolean inheriting) {
this.inheriting = inheriting;
}
@Column(name="object_id_class", nullable=false)
public Long getObjectClassId() {
return objectClassId;
}
public void setObjectClassId(Long objectClassId) {
this.objectClassId = objectClassId;
}
@ManyToOne
@JoinColumn(name="object_id_class", nullable=false, updatable=false, insertable=false)
public AclClass getObjectClass(){
return objectClass;
}
public void setObjectClass(AclClass objectClass){
this.objectClass = objectClass;
}
@Column(name="object_id_identity", nullable=false)
public Long getObjectIdentity() {
return objectIdentity;
}
public void setObjectIdentity(Long objectIdentity) {
this.objectIdentity = objectIdentity;
}
@Column(name="owner_sid", nullable=false)
public Long getOwnerSidId() {
return ownerSidId;
}
public void setOwnerSidId(Long ownerSidId) {
this.ownerSidId = ownerSidId;
}
@ManyToOne
@JoinColumn(name="owner_sid", nullable=false, updatable=false, insertable=false)
public AclSid getOwnerSid(){
return ownerSid;
}
public void setOwnerSid(AclSid ownerSid){
this.ownerSid = ownerSid;
}
@Column(name="parent_object")
public Long getParentObject() {
return parentObject;
}
public void setParentObject(Long parentObject) {
this.parentObject = parentObject;
}
@OneToMany(
cascade = {CascadeType.ALL},
fetch = FetchType.LAZY
)
@JoinColumn(name="acl_object_identity")
@OrderBy("order")
public List<AclEntry> getAclEntries() {
return AclEntries;
}
public void setAclEntries(List<AclEntry> AclEntries) {
this.AclEntries = AclEntries;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AclObjectIdentity other = (AclObjectIdentity) obj;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
return false;
}
if (this.objectIdentity != other.objectIdentity && (this.objectIdentity == null || !this.objectIdentity.equals(other.objectIdentity))) {
return false;
}
if (this.parentObject != other.parentObject && (this.parentObject == null || !this.parentObject.equals(other.parentObject))) {
return false;
}
if (this.ownerSid != other.ownerSid && (this.ownerSid == null || !this.ownerSid.equals(other.ownerSid))) {
return false;
}
if (this.objectClass != other.objectClass && (this.objectClass == null || !this.objectClass.equals(other.objectClass))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 61 * hash + (this.id != null ? this.id.hashCode() : 0);
hash = 61 * hash + (this.objectIdentity != null ? this.objectIdentity.hashCode() : 0);
hash = 61 * hash + (this.parentObject != null ? this.parentObject.hashCode() : 0);
hash = 61 * hash + (this.ownerSid != null ? this.ownerSid.hashCode() : 0);
hash = 61 * hash + (this.objectClass != null ? this.objectClass.hashCode() : 0);
return hash;
}
}
AclEntry.java
Code:
package com.x.y.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.appfuse.model.BaseObject;
/**
*
* @author jvance
*/
@Entity(name="acl_entry")
public class AclEntry extends BaseObject{
private Long id;
private Long order;
private Long mask;
private Boolean auditFailure;
private Boolean auditSuccess;
private Boolean granting;
private Long objectIdentityId;
private AclObjectIdentity objectIdentity;
private Long sidId;
private AclSid sid;
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="audit_failure", nullable=false)
public Boolean getAuditFailure() {
return auditFailure;
}
public void setAuditFailure(Boolean auditFailure) {
this.auditFailure = auditFailure;
}
@Column(name="audit_success", nullable=false)
public Boolean getAuditSuccess() {
return auditSuccess;
}
public void setAuditSuccess(Boolean auditSuccess) {
this.auditSuccess = auditSuccess;
}
@Column(name="granting", nullable=false)
public Boolean getGranting() {
return granting;
}
public void setGranting(Boolean granting) {
this.granting = granting;
}
@Column(name="mask", nullable=false)
public Long getMask() {
return mask;
}
public void setMask(Long mask) {
this.mask = mask;
}
@ManyToOne
@JoinColumn(name="acl_object_identity", nullable=false, insertable=false, updatable=false)
public AclObjectIdentity getObjectIdentity() {
return objectIdentity;
}
public void setObjectIdentity(AclObjectIdentity objectIdentity) {
this.objectIdentity = objectIdentity;
}
// This field is needed to allow postback
@Column(name="acl_object_identity", nullable=false)
public Long getObjectIdentityId() {
return objectIdentityId;
}
public void setObjectIdentityId(Long objectIdentityId) {
this.objectIdentityId = objectIdentityId;
}
@ManyToOne
@JoinColumn(name="sid", nullable=false, updatable=false, insertable=false)
public AclSid getSid() {
return sid;
}
public void setSid(AclSid sid){
this.sid = sid;
}
@Column(name="sid", nullable=false)
public Long getSidId() {
return sidId;
}
public void setSidId(Long sidId) {
this.sidId = sidId;
}
@Column(name="ace_order", nullable=false)
public Long getOrder() {
return order;
}
public void setOrder(Long order) {
this.order = order;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AclEntry other = (AclEntry) obj;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
return false;
}
if (this.order != other.order && (this.order == null || !this.order.equals(other.order))) {
return false;
}
if (this.mask != other.mask && (this.mask == null || !this.mask.equals(other.mask))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
hash = 79 * hash + (this.order != null ? this.order.hashCode() : 0);
hash = 79 * hash + (this.mask != null ? this.mask.hashCode() : 0);
return hash;
}
public String toString(){
return "Object: " + objectIdentity.getId().toString() + " Owner: " + sid.getSid();
}
}