01: package org.osbl.authorization;
02:
03: import org.osbl.identity.model.Identity;
04: import org.osbl.identity.model.User;
05: import org.osbl.ReferenceChecker;
06: import org.osbl.ServiceProvider;
07: import org.osbl.authorization.model.Profile;
08: import org.osbl.authorization.logic.AuthorizationLogic;
09: import org.osbl.persistence.*;
10: import org.conform.hibernate.HibernateEnvironment;
11:
12: import java.util.*;
13:
14: public class UserToProfileReferenceChecker implements
15: ReferenceChecker<Identity, Profile> {
16: private AuthorizationLogic authorizationLogic;
17:
18: public AuthorizationLogic getAuthorizationLogic() {
19: if (authorizationLogic == null)
20: authorizationLogic = (AuthorizationLogic) ServiceProvider
21: .getInstance().getService("AuthorizationLogic");
22: return authorizationLogic;
23: }
24:
25: public Collection<Identity> check(Collection<Profile> objects) {
26: try {
27: HibernateEnvironment.getInstance().beginTransaction();
28: List<Identity> identities = new ArrayList<Identity>();
29: for (Profile profile : objects) {
30: identities.addAll(getAuthorizationLogic()
31: .identitiesWithProfile(profile));
32: }
33: return identities;
34: } finally {
35: HibernateEnvironment.getInstance().endTransaction();
36: }
37: }
38: }
|