Project

General

Profile

« Previous | Next » 

Revision 6532

update D1 jars to include recent SubjectList -> SubjectInfo refactoring and the SUBJECT_PUBLIC constant

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
831 831
      AccessRule allow = new AccessRule();
832 832
      allow.addPermission(Permission.WRITE);
833 833
      Subject publicSubject = new Subject();
834
      publicSubject.setValue(Constants.PUBLIC_SUBJECT);
834
      publicSubject.setValue(Constants.SUBJECT_PUBLIC);
835 835
      allow.addSubject(publicSubject);
836 836
      accessPolicy.addAllow(allow);
837 837
      
test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
368 368
			AccessRule accessRule = new AccessRule();
369 369
			accessRule.addPermission(Permission.WRITE);
370 370
			Subject publicSubject = new Subject();
371
			publicSubject.setValue(Constants.PUBLIC_SUBJECT);
371
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
372 372
			accessRule.addSubject(publicSubject);
373 373
			accessPolicy.addAllow(accessRule);
374 374
			// set it
......
396 396
			assertEquals(guid.getValue(), retGuid.getValue());
397 397
			// check it
398 398
			Subject publicSubject = new Subject();
399
			publicSubject.setValue(Constants.PUBLIC_SUBJECT);
399
			publicSubject.setValue(Constants.SUBJECT_PUBLIC);
400 400
			session.setSubject(publicSubject);
401 401
			// public read
402 402
			boolean result = CNodeService.getInstance().isAuthorized(session, guid, Permission.READ);
test/edu/ucsb/nceas/metacat/dataone/D1NodeServiceTest.java
173 173
        AccessRule allow = new AccessRule();
174 174
        allow.addPermission(Permission.READ);
175 175
        Subject publicSubject = new Subject();
176
        publicSubject.setValue(Constants.PUBLIC_SUBJECT);
176
        publicSubject.setValue(Constants.SUBJECT_PUBLIC);
177 177
		allow.addSubject(publicSubject);
178 178
		accessPolicy.addAllow(allow);
179 179
        sm.setAccessPolicy(accessPolicy);
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
169 169

  
170 170
        String localId = null;
171 171
        boolean allowed = false;
172
        String username = Constants.PUBLIC_SUBJECT;
172
        String username = Constants.SUBJECT_PUBLIC;
173 173
        String[] groupnames = null;
174 174
        if (session != null) {
175 175
            username = session.getSubject().getValue();
176
            if (session.getSubjectList() != null) {
177
                List<Group> groupList = session.getSubjectList().getGroupList();
176
            if (session.getSubjectInfo() != null) {
177
                List<Group> groupList = session.getSubjectInfo().getGroupList();
178 178
                if (groupList != null) {
179 179
                    groupnames = new String[groupList.size()];
180 180
                    for (int i = 0; i > groupList.size(); i++) {
......
872 872
        logMetacat.debug("Synchronization for the object identified by " + syncFailed.getPid() + " failed from " + syncFailed.getNodeId()
873 873
                + " Logging the event to the Metacat EventLog as a 'syncFailed' event.");
874 874
        // TODO: use the event type enum when the SYNCHRONIZATION_FAILED event is added
875
        String principal = Constants.PUBLIC_SUBJECT;
875
        String principal = Constants.SUBJECT_PUBLIC;
876 876
        if (session != null && session.getSubject() != null) {
877 877
        	principal = session.getSubject().getValue();
878 878
        }
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
66 66
import org.dataone.service.types.v1.Person;
67 67
import org.dataone.service.types.v1.Session;
68 68
import org.dataone.service.types.v1.Subject;
69
import org.dataone.service.types.v1.SubjectInfo;
69 70
import org.dataone.service.types.v1.SubjectList;
70 71
import org.dataone.service.types.v1.SystemMetadata;
71 72
import org.dataone.service.types.v1.util.ChecksumUtil;
......
155 156

  
156 157
    // be sure the user is authenticated for create()
157 158
    if (subject == null || subject.getValue() == null || 
158
        subject.getValue().toLowerCase().equals(Constants.PUBLIC_SUBJECT) ) {
159
        subject.getValue().toLowerCase().equals(Constants.SUBJECT_PUBLIC) ) {
159 160
      throw new NotAuthorized("1100", "The provided identity does not have " +
160 161
        "permission to WRITE to the Node.");
161 162
      
......
487 488
    }
488 489
    
489 490
	// log the read event
490
    String principal = Constants.PUBLIC_SUBJECT;
491
    String principal = Constants.SUBJECT_PUBLIC;
491 492
    if (session != null && session.getSubject() != null) {
492 493
    	principal = session.getSubject().getValue();
493 494
    }
......
618 619
	    if (subject != null) {
619 620
	    	subjects.add(subject);
620 621
	    }
621
	    SubjectList subjectList = session.getSubjectList();
622
	    if (subjectList != null) {
623
	    	List<Person> personList = subjectList.getPersonList();
622
	    SubjectInfo subjecInfo = session.getSubjectInfo();
623
	    if (subjecInfo != null) {
624
	    	List<Person> personList = subjecInfo.getPersonList();
624 625
	    	if (personList != null) {
625 626
			    for (Person p: personList) {
626 627
			      subjects.add(p.getSubject());
627 628
			    }
628 629
	    	}
629
	    	List<Group> groupList = subjectList.getGroupList();
630
	    	List<Group> groupList = subjecInfo.getGroupList();
630 631
	    	if (groupList != null) {
631 632
			    for (Group g: groupList) {
632 633
			      subjects.add(g.getSubject());
......
637 638
    
638 639
    // add public subject
639 640
    Subject publicSubject = new Subject();
640
    publicSubject.setValue(Constants.PUBLIC_SUBJECT);
641
    publicSubject.setValue(Constants.SUBJECT_PUBLIC);
641 642
    subjects.add(publicSubject);
642 643
    
643 644
    // get the system metadata
......
818 819
    doctext[0] = xml;
819 820
    params.put("doctext", doctext);
820 821
    
821
    String username = Constants.PUBLIC_SUBJECT;
822
    String username = Constants.SUBJECT_PUBLIC;
822 823
    String[] groupnames = null;
823 824
    if (session != null ) {
824 825
    	username = session.getSubject().getValue();
825
    	if (session.getSubjectList() != null) {
826
    		List<Group> groupList = session.getSubjectList().getGroupList();
826
    	if (session.getSubjectInfo() != null) {
827
    		List<Group> groupList = session.getSubjectInfo().getGroupList();
827 828
    		if (groupList != null) {
828 829
    			groupnames = new String[groupList.size()];
829 830
    			for (int i = 0; i > groupList.size(); i++ ) {
......
867 868
  protected String insertDataObject(InputStream object, Identifier pid, 
           Session session) throws ServiceFailure {
       
-    String username = Constants.PUBLIC_SUBJECT;
869
    String username = Constants.SUBJECT_PUBLIC;
868 870
    String[] groupnames = null;
869 871
    if (session != null ) {
870 872
    	username = session.getSubject().getValue();
871
    	if (session.getSubjectList() != null) {
872
    		List<Group> groupList = session.getSubjectList().getGroupList();
873
    	if (session.getSubjectInfo() != null) {
874
    		List<Group> groupList = session.getSubjectInfo().getGroupList();
873 875
    		if (groupList != null) {
874 876
    			groupnames = new String[groupList.size()];
875 877
    			for (int i = 0; i > groupList.size(); i++ ) {

Also available in: Unified diff