Source:
@Override public Authentication.AuthResponse isAuthenticated(final School.ItemType collectionType, final String itemId, final String userId, final Authentication.AuthType preFixedCheckType) throws DatabaseAccessException, AuthenticationException { checkNotNull(collectionType, "collectionType"); checkNotNull(itemId, "itemId"); checkNotNull(userId, "userId"); final Authentication.AuthType checkType = AuthUtilities.fixCheckType(preFixedCheckType); if (!Authenticator.validUserAccessRequest(checkType)) { throw new AuthenticationException("Invalid Authentication Request: No options to check were filled out", AuthenticationException.NO_AUTH_SENT); } final DBCollection collection = this.database.getCollection(getCollectionFromType(collectionType)); final DBObject result = collection.findOne(new ObjectId(itemId)); if (result == null) { throw new DatabaseAccessException("The item with the id " + itemId + " Was not found in the database"); } final List<String> groupList = (List<String>) result.get(DatabaseStringConstants.USER_LIST); Authentication.AuthResponse.PermissionLevel permissionLevel = null; final DBCollection groupCollection = this.database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION); for (String groupId : groupList) { final Authentication.AuthResponse.PermissionLevel permLevel = checkGroupPermission(groupCollection, groupId, userId); if (permLevel != null) { permissionLevel = permLevel; break; } } if (permissionLevel == null) { return Authentication.AuthResponse.getDefaultInstance(); } final Authentication.AuthResponse.Builder responseBuilder = Authentication.AuthResponse.newBuilder(); if (checkType.getCheckAccess()) { responseBuilder.setHasAccess(permissionLevel.compareTo(STUDENT) >= 0); } final Authentication.AuthResponse.PermissionLevel largestAllowedLevel = AuthUtilities.largestAllowedLevel(checkType); if (permissionLevel.compareTo(largestAllowedLevel) >= 0) { responseBuilder.setPermissionLevel(largestAllowedLevel); } else { responseBuilder.setPermissionLevel(permissionLevel); } return responseBuilder.build(); }

Target:
@Override public Authentication.AuthResponse isAuthenticated(final School.ItemType collectionType, final String itemId, final String userId, final Authentication.AuthType preFixedCheckType) throws DatabaseAccessException, AuthenticationException { checkNotNull(collectionType, "collectionType"); checkNotNull(itemId, "itemId"); checkNotNull(userId, "userId"); final Authentication.AuthType checkType = AuthUtilities.fixCheckType(preFixedCheckType); if (!Authenticator.validUserAccessRequest(checkType)) { throw new AuthenticationException("Invalid Authentication Request: No auth options set to check against.", AuthenticationException.NO_AUTH_SENT); } final DBCollection collection = this.database.getCollection(getCollectionFromType(collectionType)); final DBObject result = collection.findOne(new ObjectId(itemId)); if (result == null) { throw new DatabaseAccessException("The item with the id " + itemId + " was not found in the database."); } final List<String> groupList = (List<String>) result.get(DatabaseStringConstants.USER_LIST); Authentication.AuthResponse.PermissionLevel permissionLevel = null; final DBCollection groupCollection = this.database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION); for (String groupId : groupList) { final Authentication.AuthResponse.PermissionLevel permLevel = getUserPermissionLevel(groupCollection, groupId, userId); if (permLevel != null) { permissionLevel = permLevel; break; } } if (permissionLevel == null) { return Authentication.AuthResponse.getDefaultInstance(); } final Authentication.AuthResponse.Builder responseBuilder = Authentication.AuthResponse.newBuilder(); if (checkType.getCheckAccess()) { responseBuilder.setHasAccess(permissionLevel.compareTo(STUDENT) >= 0); } final Authentication.AuthResponse.PermissionLevel largestAllowedLevel = AuthUtilities.largestAllowedLevel(checkType); if (permissionLevel.compareTo(largestAllowedLevel) >= 0) { responseBuilder.setPermissionLevel(largestAllowedLevel); } else { responseBuilder.setPermissionLevel(permissionLevel); } return responseBuilder.build(); }