src/org/ohmage/service/OmhServices.java
public String verifyUserCanReadAboutOtherUser(
		final String requestingUser,
		final String otherUser)
		throws ServiceException {

		// First, be sure there really is an other user.
		if((otherUser != null) && (! otherUser.equals(requestingUser))) {
			// Check if the requesting user is an admin.
			try {
				UserServices.instance().verifyUserIsAdmin(requestingUser);
			}
			// If the requesting user isn't an admin,
			catch(ServiceException notAdmin) {
				// See if this is even allowed.
				boolean isPlausible;
				try {
					isPlausible = 
						StringUtils
							.decodeBoolean(
								PreferenceCache
									.instance()
									.lookup(
										PreferenceCache
											.KEY_PRIVILEGED_USER_IN_CLASS_CAN_VIEW_MOBILITY_FOR_EVERYONE_IN_CLASS));
				}
				catch(CacheMissException e) {
					throw new ServiceException(e);
				}
				
				// If allowed, make sure the requesting user is privileged in
				// another class to which the other user is a member.
				if(isPlausible) {
					UserClassServices
						.instance()
						.userIsPrivilegedInAnotherUserClass(
							requestingUser, 
							otherUser);
				}
				else {
					throw new ServiceException(
						ErrorCode.OMH_INSUFFICIENT_PERMISSIONS,
						"This user is not allowed to query data about the " +
							"requested user.");
				}
			}
			
			return otherUser;
		}
		else {
			return requestingUser;
		}
	}
/**
	 * Verifies that a requesting user can read data about another user.
	 * 
	 * @param requestingUser
	 *        The requesting user's username.
	 * 
	 * @param otherUser
	 *        The other user's username.
	 * 
	 * @return The username of the user whose data should be returned.
	 * 
	 * @throws ServiceException
	 *         The requesting user is not allowed ot read data about the other
	 *         user.
	 */
Verifies that a requesting user can read data about another user.

@param requestingUser
The requesting user's username.

@param otherUser
The other user's username.

@return The username of the user whose data should be returned.

@throws ServiceException
The requesting user is not allowed ot read data about the other
user.
Verifies that a requesting user can read data about another user . @param requestingUser The requesting user ' s username . @param otherUser The other user ' s username . @return The username of the user whose data should be returned . @throws ServiceException The requesting user is not allowed ot read data about the other user .
public String verifyUserCanReadAboutOtherUser(
		final String requestingUser,
		final String otherUser)
		throws ServiceException {
		if((otherUser != null) && (! otherUser.equals(requestingUser))) {
			try {
				UserServices.instance().verifyUserIsAdmin(requestingUser);
			}
			catch(ServiceException notAdmin) {
				boolean isPlausible;
				try {
					isPlausible = 
						StringUtils
							.decodeBoolean(
								PreferenceCache
									.instance()
									.lookup(
										PreferenceCache
											.KEY_PRIVILEGED_USER_IN_CLASS_CAN_VIEW_MOBILITY_FOR_EVERYONE_IN_CLASS));
				}
				catch(CacheMissException e) {
					throw new ServiceException(e);
				}
				if(isPlausible) {
					UserClassServices
						.instance()
						.userIsPrivilegedInAnotherUserClass(
							requestingUser, 
							otherUser);
				}
				else {
					throw new ServiceException(
						ErrorCode.OMH_INSUFFICIENT_PERMISSIONS,
						"This user is not allowed to query data about the " +
							"requested user.");
				}
			}
			return otherUser;
		}
		else {
			return requestingUser;
		}
	}
public String verifyUserCanReadAboutOtherUser ( final String requestingUser , final String otherUser ) throws ServiceException { if ( ( otherUser != null ) && ( ! otherUser . equals ( requestingUser ) ) ) { try { UserServices . instance ( ) . verifyUserIsAdmin ( requestingUser ) ; } catch ( ServiceException notAdmin ) { boolean isPlausible ; try { isPlausible = StringUtils . decodeBoolean ( PreferenceCache . instance ( ) . lookup ( PreferenceCache . KEY_PRIVILEGED_USER_IN_CLASS_CAN_VIEW_MOBILITY_FOR_EVERYONE_IN_CLASS ) ) ; } catch ( CacheMissException e ) { throw new ServiceException ( e ) ; } if ( isPlausible ) { UserClassServices . instance ( ) . userIsPrivilegedInAnotherUserClass ( requestingUser , otherUser ) ; } else { throw new ServiceException ( ErrorCode . OMH_INSUFFICIENT_PERMISSIONS , "This user is not allowed to query data about the " + "requested user." ) ; } } return otherUser ; } else { return requestingUser ; } }
Verifies that a requesting user can read data about another user.
Verifies that a requesting user can read data about another user .
// First, be sure there really is an other user. // Check if the requesting user is an admin. // If the requesting user isn't an admin, // See if this is even allowed. // If allowed, make sure the requesting user is privileged in // another class to which the other user is a member.