<commit_before>package edu.duke.cabig.c3pr.accesscontrol;

import edu.duke.cabig.c3pr.domain.StudyOrganization;
import edu.duke.cabig.c3pr.domain.StudySite;
import gov.nih.nci.security.acegi.csm.authorization.DelegatingObjectPrivilegeCSMAuthorizationCheck;

import org.acegisecurity.Authentication;

/**
 * User: <NAME>
 * Date: Jul 3, 2008
 * Time: 3:14:12 PM
 */

public class StudySiteAuthorizationCheck extends DelegatingObjectPrivilegeCSMAuthorizationCheck{

   @Override
	public boolean checkAuthorization(Authentication authentication, String privilege,
			Object object) {
	   StudySite studySite = (StudySite) object;
	   
	   StudyOrganization studyCoordinatingCenter = studySite.getStudy().getStudyCoordinatingCenter();
	    
	   boolean authorize = super.checkAuthorization(authentication, privilege,studyCoordinatingCenter);
	   //super.checkAuthorization will enforce that the logged in user only sees his organization.
	   //however if the logged in user is a Coordinating center for the study being viewed the he 
	   //shud be able to see all sites
	   return authorize?authorize:super.checkAuthorization(authentication,privilege, object);
	   
	}
}

<commit_msg>CPR-601: Coordinating center can now see all sites. but sites can only see themselves<commit_after>package edu.duke.cabig.c3pr.accesscontrol;

import edu.duke.cabig.c3pr.domain.StudyOrganization;
import edu.duke.cabig.c3pr.domain.StudySite;
import gov.nih.nci.security.acegi.csm.authorization.DelegatingObjectPrivilegeCSMAuthorizationCheck;

import org.acegisecurity.Authentication;

/**
 * User: <NAME>
 * Date: Jul 3, 2008
 * Time: 3:14:12 PM
 */

public class StudySiteAuthorizationCheck extends DelegatingObjectPrivilegeCSMAuthorizationCheck{

   @Override
	public boolean checkAuthorization(Authentication authentication, String privilege,
			Object object) {
	   
	   boolean authorize = false;
	   StudyOrganization studyOrganization = null;
	   StudyOrganization studyCoordinatingCenter = null;
	   if(object instanceof StudyOrganization){
		   studyOrganization = (StudyOrganization)object;
		   studyCoordinatingCenter = studyOrganization.getStudy().getStudyCoordinatingCenter(); 
	   }
	   
	   StudySite studySite = null;
	   if(object instanceof StudySite){
		   studySite = (StudySite) object;
		   studyCoordinatingCenter = studySite.getStudy().getStudyCoordinatingCenter();
	   }
	    
	   //super.checkAuthorization will enforce that the logged in user only sees his organization.
	   //however if the logged in user is a Coordinating center for the study being viewed the he 
	   //shud be able to see all sites
	   if(studyCoordinatingCenter != null){
		   authorize = super.checkAuthorization(authentication, privilege,studyCoordinatingCenter);
	   }
	   
	   return authorize?authorize:super.checkAuthorization(authentication,privilege, object);
	}
}


{'fraction_non_alphanumeric': 0.07474402730375426, 'fraction_numerical': 0.009897610921501706, 'mean_word_length': 4.115183246073299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3233907', 'n_tokens_mistral': 912, 'n_tokens_neox': 815, 'n_words': 200}