1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sec.businessobject;
17
18 import java.util.ArrayList;
19 import java.util.LinkedHashMap;
20 import java.util.List;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.kim.api.identity.Person;
26 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27
28
29
30
31 public class SecurityPrincipal extends PersistableBusinessObjectBase {
32 protected String principalId;
33
34 protected Person securityPerson;
35
36 protected List<SecurityPrincipalDefinition> principalDefinitions = new ArrayList<SecurityPrincipalDefinition>();
37 protected List<SecurityModelMember> principalModels = new ArrayList<SecurityModelMember>();
38
39
40
41
42
43
44 public String getPrincipalId() {
45 return principalId;
46 }
47
48
49
50
51
52
53
54 public void setPrincipalId(String principalId) {
55 this.principalId = principalId;
56 }
57
58
59
60
61
62
63
64 public Person getSecurityPerson() {
65 securityPerson = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(principalId, securityPerson);
66 return securityPerson;
67 }
68
69
70
71
72
73
74
75 public void setSecurityPerson(Person securityPerson) {
76 this.securityPerson = securityPerson;
77 }
78
79
80
81
82
83
84
85 public List<SecurityPrincipalDefinition> getPrincipalDefinitions() {
86 return principalDefinitions;
87 }
88
89
90
91
92
93
94
95 public void setPrincipalDefinitions(List<SecurityPrincipalDefinition> principalDefinitions) {
96 this.principalDefinitions = principalDefinitions;
97 }
98
99
100
101
102
103
104
105 public List<SecurityModelMember> getPrincipalModels() {
106 return principalModels;
107 }
108
109
110
111
112
113
114
115 public void setPrincipalModels(List<SecurityModelMember> principalModels) {
116 this.principalModels = principalModels;
117 }
118
119
120
121
122 public String getPrincipalDefinitionNames() {
123 String definitionNames = "";
124
125 for (SecurityPrincipalDefinition definition : principalDefinitions) {
126 if (StringUtils.isNotBlank(definitionNames)) {
127 definitionNames += ", ";
128 }
129 definitionNames += definition.getSecurityDefinition().getName();
130 }
131
132 return definitionNames;
133 }
134
135
136
137
138 public String getPrincipalModelNames() {
139 String modelNames = "";
140
141 for (SecurityModelMember modelMember : principalModels) {
142 if (StringUtils.isNotBlank(modelNames)) {
143 modelNames += ", ";
144 }
145 modelNames += modelMember.getSecurityModel().getName();
146 }
147
148 return modelNames;
149 }
150
151
152 @Override
153 public String toString() {
154 StringBuilder builder = new StringBuilder();
155 builder.append("SecurityPrincipal [");
156 if (principalId != null) {
157 builder.append("principalId=");
158 builder.append(principalId);
159 builder.append(", ");
160 }
161 if (getPrincipalDefinitionNames() != null) {
162 builder.append("getPrincipalDefinitionNames()=");
163 builder.append(getPrincipalDefinitionNames());
164 builder.append(", ");
165 }
166 if (getPrincipalModelNames() != null) {
167 builder.append("getPrincipalModelNames()=");
168 builder.append(getPrincipalModelNames());
169 }
170 builder.append("]");
171 return builder.toString();
172 }
173
174
175 }