source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/GatewayPolicyEngineTransformationEjb/src/java/gov/hhs/fha/nhinc/gateway/policyenginetransformation/Helpers/SubjectHelper.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 2.7 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers;
6
7import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
8import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
9import gov.hhs.fha.nhinc.nhinclib.NullChecker;
10import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
11
12/**
13 *
14 * @author rayj
15 */
16public class SubjectHelper {
17
18 private static final String SubjectCategory = "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject";
19 private static final String UserAttributeId = "urn:oasis:names:tc:xacml:1.0:subject:subject-id";
20 private static final String UserRoleAttributeId = "urn:gov:hhs:fha:nhinc:user-role-code";
21 private static final String PurposeAttributeId = "urn:gov:hhs:fha:nhinc:purpose-for-use";
22 private static final String UserHomeCommunityAttributeId = "urn:gov:hhs:fha:nhinc:home-community-id";
23
24 public static SubjectType subjectFactory(HomeCommunityType sendingHomeCommunity, AssertionType assertion) {
25 SubjectType subject = new SubjectType();
26 subject.setSubjectCategory(SubjectCategory);
27 subject.getAttribute().add(AttributeHelper.attributeFactory(UserAttributeId, Constants.DataTypeString, AssertionHelper.extractUserName(assertion)));
28 subject.getAttribute().add(AttributeHelper.attributeFactory(UserHomeCommunityAttributeId, Constants.DataTypeString, determineSendingHomeCommunityId(sendingHomeCommunity, assertion)));
29 return subject;
30 }
31
32 public static SubjectType subjectFactoryReident(HomeCommunityType sendingHomeCommunity, AssertionType assertion) {
33 SubjectType subject = new SubjectType();
34 subject.setSubjectCategory(SubjectCategory);
35 subject.getAttribute().add(AttributeHelper.attributeFactory(UserRoleAttributeId, Constants.DataTypeString, AssertionHelper.extractUserRole(assertion)));
36 subject.getAttribute().add(AttributeHelper.attributeFactory(PurposeAttributeId, Constants.DataTypeString, AssertionHelper.extractPurpose(assertion)));
37 subject.getAttribute().add(AttributeHelper.attributeFactory(UserHomeCommunityAttributeId, Constants.DataTypeString, determineSendingHomeCommunityId(sendingHomeCommunity, assertion)));
38 return subject;
39 }
40
41 private static String determineSendingHomeCommunityId(HomeCommunityType sendingHomeCommunity, AssertionType assertion) {
42 String homeCommunityId = null;
43
44 if (sendingHomeCommunity != null) {
45 homeCommunityId = sendingHomeCommunity.getHomeCommunityId();
46 }
47
48 if (NullChecker.isNullish(homeCommunityId)) {
49 homeCommunityId = AssertionHelper.extractUserHomeCommunity(assertion);
50 }
51
52 return homeCommunityId;
53 }
54}
Note: See TracBrowser for help on using the repository browser.