1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package net.sf.jguard.ext.organization;
33
34
35 import net.sf.jguard.core.organization.Organization;
36 import net.sf.jguard.core.provisioning.SubjectTemplate;
37 import net.sf.jguard.ext.authentication.manager.HibernateConverterUtils;
38 import net.sf.jguard.ext.provisioning.PersistedSubjectTemplate;
39
40
41
42
43
44 public class PersistedOrganization extends Organization{
45
46 private PersistedSubjectTemplate persistedSubjectTemplate;
47 public PersistedOrganization(){
48 super();
49 }
50
51 public PersistedOrganization(Organization organization){
52 super();
53
54 this.id = organization.getId();
55 this.principals = HibernateConverterUtils.getPersistedPrincipals(organization.getPrincipals());
56 this.persistedSubjectTemplate = new PersistedSubjectTemplate(organization.getSubjectTemplate());
57
58 this.credentials = organization.getCredentials();
59 this.users = organization.getUsers();
60
61 }
62
63
64
65
66
67
68
69
70
71
72 public Organization toOrganization(){
73
74 Organization orga = new Organization();
75 orga.setId(getId());
76 orga.setPrincipals(HibernateConverterUtils.getjavaSecurityPrincipals(getPrincipals()));
77 orga.setCredentials(getCredentials());
78 SubjectTemplate st = persistedSubjectTemplate.toSubjectTemplate();
79 orga.setSubjectTemplate(st);
80 orga.setUsers(getUsers());
81 return orga;
82 }
83
84 public boolean equals(Object other) {
85 if (this == other){
86 return true;
87 }
88 if ( !(other instanceof PersistedOrganization) ){
89 return false;
90 }
91
92 final PersistedOrganization porganization = (PersistedOrganization)other;
93 if(getPersistedSubjectTemplate().equals(porganization.getPersistedSubjectTemplate())&&
94 credentials.equals(porganization.getCredentials())&&
95 principals.equals(porganization.getPrincipals())){
96 return true;
97 }
98 return false;
99 }
100
101 public int hashCode() {
102 int hash = 7;
103 hash = 23 * hash + (this.persistedSubjectTemplate != null ? this.persistedSubjectTemplate.hashCode() : 0);
104 hash = 23 * hash + (this.credentials != null ? this.credentials.hashCode() : 0);
105 hash = 23 * hash + (this.principals != null ? this.principals.hashCode() : 0);
106 return hash;
107 }
108
109 public PersistedSubjectTemplate getPersistedSubjectTemplate() {
110 return persistedSubjectTemplate;
111 }
112
113 public void setPersistedSubjectTemplate(PersistedSubjectTemplate persistedSubjectTemplate) {
114 this.persistedSubjectTemplate = persistedSubjectTemplate;
115 }
116
117 }
118