nus-yam/ex-repair huggingface dataset:
Program: 52310
Project: 52310
Buggy source:
/** 
 * Validates and parses the given ID ticket, returning the username contained therein, as defined by the username claim type given in guacamole.properties. If the username claim type is missing or the ID ticket is invalid, an exception is thrown instead.
 * @param ticket The ID ticket to validate and parse.
 * @return The username contained within the given ID ticket.
 * @throws GuacamoleException If the ID ticket is not valid, the username claim type is missing, or guacamole.properties could not be parsed.
 */
public String processUsername(String ticket) throws GuacamoleException {
}

Fixed version (ground truth):
/** 
 * Validates and parses the given ID ticket, returning the username contained therein, as defined by the username claim type given in guacamole.properties. If the username claim type is missing or the ID ticket is invalid, an exception is thrown instead.
 * @param ticket The ID ticket to validate and parse.
 * @return The username contained within the given ID ticket.
 * @throws GuacamoleException If the ID ticket is not valid, the username claim type is missing, or guacamole.properties could not be parsed.
 */
public String processUsername(String ticket) throws GuacamoleException {
  AttributePrincipal principal=null;
  String casServerUrl=confService.getAuthorizationEndpoint();
  Cas20ProxyTicketValidator sv=new Cas20ProxyTicketValidator(casServerUrl);
  sv.setAcceptAnyProxy(true);
  try {
    String confRedirectURI=confService.getRedirectURI();
    Assertion a=sv.validate(ticket,confRedirectURI);
    principal=a.getPrincipal();
  }
 catch (  TicketValidationException e) {
    throw new GuacamoleException("String_Node_Str",e);
  }
  return principal.getName();
}
Program: 52311
Project: 52311
Buggy source:
/** 
 * Returns whether or not LDAP aliases will be dereferenced, as configured with guacamole.properties. By default they will never be dereferenced.
 * @return An integer representing the status of of alias dereferencing, as configured in guacamole.properties.
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getDereferenceAliases() throws GuacamoleException {
  String derefAliases=environment.getProperty(LDAPGuacamoleProperties.LDAP_DEREFERENCE_ALIASES,"String_Node_Str");
  if (derefAliases == "String_Node_Str")   return 3;
 else   if (derefAliases == "String_Node_Str")   return 2;
 else   if (derefAliases == "String_Node_Str")   return 1;
 else   return 0;
}

Fixed version (ground truth):
/** 
 * Returns whether or not LDAP aliases will be dereferenced, as configured with guacamole.properties. By default they will never be dereferenced.
 * @return An integer representing the status of of alias dereferencing, as configured in guacamole.properties.
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getDereferenceAliases() throws GuacamoleException {
  String derefAliases=environment.getProperty(LDAPGuacamoleProperties.LDAP_DEREFERENCE_ALIASES,"String_Node_Str");
  if (derefAliases.equals("String_Node_Str"))   return 3;
 else   if (derefAliases.equals("String_Node_Str"))   return 2;
 else   if (derefAliases.equals("String_Node_Str"))   return 1;
 else   if (derefAliases.equals("String_Node_Str"))   return 0;
 else {
    logger.error("String_Node_Str");
    logger.debug("String_Node_Str",derefAliases);
    throw new GuacamoleException("String_Node_Str");
  }
}
Program: 52312
Project: 52312
Buggy source:
/** 
 * Returns an AuthenticatedUser representing the user authenticated by the given credentials.
 * @param credentials The credentials to use for authentication.
 * @return An AuthenticatedUser representing the user authenticated by the given credentials.
 * @throws GuacamoleException If an error occurs while authenticating the user, or if access is denied.
 */
public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
  HttpServletRequest request=credentials.getRequest();
  if (request != null) {
    String username=request.getRemoteUser();
    if (username == null) {
      username=request.getHeader(confService.getHttpAuthHeader());
    }
    if (username != null) {
      AuthenticatedUser authenticatedUser=authenticatedUserProvider.get();
      authenticatedUser.init(username,credentials);
      return authenticatedUser;
    }
  }
  throw new GuacamoleInvalidCredentialsException("String_Node_Str",CredentialsInfo.USERNAME_PASSWORD);
}

Fixed version (ground truth):
/** 
 * Returns an AuthenticatedUser representing the user authenticated by the given credentials.
 * @param credentials The credentials to use for authentication.
 * @return An AuthenticatedUser representing the user authenticated by the given credentials.
 * @throws GuacamoleException If an error occurs while authenticating the user, or if access is denied.
 */
public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
  HttpServletRequest request=credentials.getRequest();
  if (request != null) {
    String username=request.getRemoteUser();
    if (username == null)     username=request.getHeader(confService.getHttpAuthHeader());
    if (username != null) {
      logger.debug("String_Node_Str",username);
      AuthenticatedUser authenticatedUser=authenticatedUserProvider.get();
      authenticatedUser.init(username,credentials);
      return authenticatedUser;
    }
  }
  throw new GuacamoleInvalidCredentialsException("String_Node_Str",CredentialsInfo.USERNAME_PASSWORD);
}
Program: 52314
Project: 52314
Buggy source:
/** 
 * Attempts to add a single instance of the given value to the given multiset without exceeding the specified maximum number of values. If the value cannot be added without exceeding the maximum, false is returned.
 * @param < T > The type of values contained within the multiset.
 * @param multiset The multiset to attempt to add a value to.
 * @param value The value to attempt to add.
 * @param max The maximum number of each distinct value that the given multiset should hold, or zero if no limit applies.
 * @return true if the value was successfully added without exceeding the specified maximum, false if the value could not be added.
 */
private <T>boolean tryAdd(ConcurrentHashMultiset<T> multiset,T value,int max){
  while (true) {
    int count=multiset.count(value);
    if (count >= max || max == 0)     return false;
    if (multiset.setCount(value,count,count + 1))     return true;
  }
}

Fixed version (ground truth):
/** 
 * Attempts to add a single instance of the given value to the given multiset without exceeding the specified maximum number of values. If the value cannot be added without exceeding the maximum, false is returned.
 * @param < T > The type of values contained within the multiset.
 * @param multiset The multiset to attempt to add a value to.
 * @param value The value to attempt to add.
 * @param max The maximum number of each distinct value that the given multiset should hold, or zero if no limit applies.
 * @return true if the value was successfully added without exceeding the specified maximum, false if the value could not be added.
 */
private <T>boolean tryAdd(ConcurrentHashMultiset<T> multiset,T value,int max){
  while (true) {
    int count=multiset.count(value);
    if (count >= max && max != 0)     return false;
    if (multiset.setCount(value,count,count + 1))     return true;
  }
}
Program: 52315
Project: 52315
Buggy source:
@Override protected void beforeUpdate(AuthenticatedUser user,ConnectionModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionModel existing=connectionMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void beforeUpdate(AuthenticatedUser user,ConnectionModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getName() == null || model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionModel existing=connectionMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
  }
}
Program: 52316
Project: 52316
Buggy source:
/** 
 * Given an arbitrary Guacamole connection, produces a collection of parameter model objects containing the name/value pairs of that connection's parameters.
 * @param connection The connection whose configuration should be used to produce the collection of parameter models.
 * @return A collection of parameter models containing the name/value pairs of the given connection's parameters.
 */
private Collection<ParameterModel> getParameterModels(ModeledConnection connection){
  Map<String,String> parameters=connection.getConfiguration().getParameters();
  Collection<ParameterModel> parameterModels=new ArrayList(parameters.size());
  for (  Map.Entry<String,String> parameterEntry : parameters.entrySet()) {
    String name=parameterEntry.getKey();
    String value=parameterEntry.getValue();
    if (value.isEmpty())     continue;
    ParameterModel model=new ParameterModel();
    model.setConnectionIdentifier(connection.getIdentifier());
    model.setName(name);
    model.setValue(value);
    parameterModels.add(model);
  }
  return parameterModels;
}

Fixed version (ground truth):
/** 
 * Given an arbitrary Guacamole connection, produces a collection of parameter model objects containing the name/value pairs of that connection's parameters.
 * @param connection The connection whose configuration should be used to produce the collection of parameter models.
 * @return A collection of parameter models containing the name/value pairs of the given connection's parameters.
 */
private Collection<ParameterModel> getParameterModels(ModeledConnection connection){
  Map<String,String> parameters=connection.getConfiguration().getParameters();
  Collection<ParameterModel> parameterModels=new ArrayList(parameters.size());
  for (  Map.Entry<String,String> parameterEntry : parameters.entrySet()) {
    String name=parameterEntry.getKey();
    String value=parameterEntry.getValue();
    if (value == null || value.isEmpty())     continue;
    ParameterModel model=new ParameterModel();
    model.setConnectionIdentifier(connection.getIdentifier());
    model.setName(name);
    model.setValue(value);
    parameterModels.add(model);
  }
  return parameterModels;
}
Program: 52317
Project: 52317
Buggy source:
@Override protected void beforeCreate(AuthenticatedUser user,ConnectionModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionModel existing=connectionMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null)   throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void beforeCreate(AuthenticatedUser user,ConnectionModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getName() == null || model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionModel existing=connectionMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null)   throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
}
Program: 52318
Project: 52318
Buggy source:
@Override protected void beforeUpdate(AuthenticatedUser user,ConnectionGroupModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionGroupModel existing=connectionGroupMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
  }
  String relativeParentIdentifier=model.getParentIdentifier();
  while (relativeParentIdentifier != null) {
    if (relativeParentIdentifier.equals(model.getIdentifier()))     throw new GuacamoleUnsupportedException("String_Node_Str");
    ModeledConnectionGroup relativeParentGroup=retrieveObject(user,relativeParentIdentifier);
    relativeParentIdentifier=relativeParentGroup.getModel().getParentIdentifier();
  }
}

Fixed version (ground truth):
@Override protected void beforeUpdate(AuthenticatedUser user,ConnectionGroupModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getName() == null || model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionGroupModel existing=connectionGroupMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
  }
  String relativeParentIdentifier=model.getParentIdentifier();
  while (relativeParentIdentifier != null) {
    if (relativeParentIdentifier.equals(model.getIdentifier()))     throw new GuacamoleUnsupportedException("String_Node_Str");
    ModeledConnectionGroup relativeParentGroup=retrieveObject(user,relativeParentIdentifier);
    relativeParentIdentifier=relativeParentGroup.getModel().getParentIdentifier();
  }
}
Program: 52319
Project: 52319
Buggy source:
@Override protected void beforeCreate(AuthenticatedUser user,ConnectionGroupModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionGroupModel existing=connectionGroupMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null)   throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void beforeCreate(AuthenticatedUser user,ConnectionGroupModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getName() == null || model.getName().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  ConnectionGroupModel existing=connectionGroupMapper.selectOneByName(model.getParentIdentifier(),model.getName());
  if (existing != null)   throw new GuacamoleClientException("String_Node_Str" + model.getName() + "String_Node_Str");
}
Program: 52320
Project: 52320
Buggy source:
@Override protected void beforeUpdate(AuthenticatedUser user,UserModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getIdentifier().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  UserModel existing=userMapper.selectOne(model.getIdentifier());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getIdentifier() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void beforeUpdate(AuthenticatedUser user,UserModel model) throws GuacamoleException {
  super.beforeUpdate(user,model);
  if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  UserModel existing=userMapper.selectOne(model.getIdentifier());
  if (existing != null) {
    if (!existing.getObjectID().equals(model.getObjectID()))     throw new GuacamoleClientException("String_Node_Str" + model.getIdentifier() + "String_Node_Str");
  }
}
Program: 52321
Project: 52321
Buggy source:
@Override protected void beforeCreate(AuthenticatedUser user,UserModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getIdentifier().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  Collection<UserModel> existing=userMapper.select(Collections.singleton(model.getIdentifier()));
  if (!existing.isEmpty())   throw new GuacamoleClientException("String_Node_Str" + model.getIdentifier() + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void beforeCreate(AuthenticatedUser user,UserModel model) throws GuacamoleException {
  super.beforeCreate(user,model);
  if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())   throw new GuacamoleClientException("String_Node_Str");
  Collection<UserModel> existing=userMapper.select(Collections.singleton(model.getIdentifier()));
  if (!existing.isEmpty())   throw new GuacamoleClientException("String_Node_Str" + model.getIdentifier() + "String_Node_Str");
}
Program: 52323
Project: 52323
Buggy source:
@Transactional @Override public org.glyptodon.guacamole.net.auth.User get(String identifier) throws GuacamoleException {
  MySQLUser user=userService.retrieveUser(identifier);
  permissionCheckService.verifyUserAccess(this.user_id,user.getUserID(),MySQLConstants.USER_READ);
  return userService.retrieveUser(identifier);
}

Fixed version (ground truth):
@Transactional @Override public org.glyptodon.guacamole.net.auth.User get(String identifier) throws GuacamoleException {
  MySQLUser user=userService.retrieveUser(identifier);
  if (user == null)   return null;
  permissionCheckService.verifyUserAccess(this.user_id,user.getUserID(),MySQLConstants.USER_READ);
  return user;
}
Program: 52324
Project: 52324
Buggy source:
/** 
 * Checks whether a user has the specified type of access to the affected connection group.
 * @param userID The ID of the user to check.
 * @param affectedConnectionGroupID The connection group that would be affected by theoperation if permission is granted.
 * @param permissionType The type of permission to check for.
 * @return true if the specified permission is granted, false otherwise.
 */
public boolean checkConnectionGroupAccess(int userID,Integer affectedConnectionGroupID,String permissionType){
  if (affectedConnectionGroupID == null)   return true;
  if (checkSystemAdministratorAccess(userID))   return true;
  ConnectionGroupPermissionExample example=new ConnectionGroupPermissionExample();
  example.createCriteria().andUser_idEqualTo(userID).andConnection_group_idEqualTo(affectedConnectionGroupID).andPermissionEqualTo(permissionType);
  return connectionGroupPermissionDAO.countByExample(example) > 0;
}

Fixed version (ground truth):
/** 
 * Checks whether a user has the specified type of access to the affected connection group.
 * @param userID The ID of the user to check.
 * @param affectedConnectionGroupID The connection group that would be affected by theoperation if permission is granted.
 * @param permissionType The type of permission to check for.
 * @return true if the specified permission is granted, false otherwise.
 */
public boolean checkConnectionGroupAccess(int userID,Integer affectedConnectionGroupID,String permissionType){
  if (affectedConnectionGroupID == null && MySQLConstants.CONNECTION_GROUP_READ.equals(permissionType) || MySQLConstants.CONNECTION_GROUP_UPDATE.equals(permissionType))   return true;
  if (checkSystemAdministratorAccess(userID))   return true;
  ConnectionGroupPermissionExample example=new ConnectionGroupPermissionExample();
  example.createCriteria().andUser_idEqualTo(userID).andConnection_group_idEqualTo(affectedConnectionGroupID).andPermissionEqualTo(permissionType);
  return connectionGroupPermissionDAO.countByExample(example) > 0;
}
Program: 52326
Project: 52326
Buggy source:
/** 
 * Retrieves the connection group having the given ID from the database.
 * @param id The ID of the connection group to retrieve.
 * @param userID The ID of the user who queried this connection.
 * @return The connection group having the given ID, or null if no suchconnection was found.
 */
public MySQLConnectionGroup retrieveConnectionGroup(int id,int userID){
  ConnectionGroup connectionGroup=connectionGroupDAO.selectByPrimaryKey(id);
  if (connectionGroup == null)   return null;
  return toMySQLConnectionGroup(connectionGroup,userID);
}

Fixed version (ground truth):
/** 
 * Retrieves the connection group having the given ID from the database.
 * @param id The ID of the connection group to retrieve.
 * @param userID The ID of the user who queried this connection.
 * @return The connection group having the given ID, or null if no suchconnection was found.
 */
public MySQLConnectionGroup retrieveConnectionGroup(Integer id,int userID){
  if (id == null) {
    MySQLConnectionGroup connectionGroup=mysqlConnectionGroupProvider.get();
    connectionGroup.init(null,null,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,net.sourceforge.guacamole.net.auth.ConnectionGroup.Type.BALANCING,userID);
    return connectionGroup;
  }
  ConnectionGroup connectionGroup=connectionGroupDAO.selectByPrimaryKey(id);
  if (connectionGroup == null)   return null;
  return toMySQLConnectionGroup(connectionGroup,userID);
}
Program: 52327
Project: 52327
Buggy source:
/** 
 * Creates a new connection group having the given name and protocol.
 * @param name The name to assign to the new connection group.
 * @param userID The ID of the user who created this connection group.
 * @return A new MySQLConnectionGroup containing the data of the newly createdconnection group.
 */
public MySQLConnectionGroup createConnectionGroup(String name,int userID,Integer parentID){
  ConnectionGroup connectionGroup=new ConnectionGroup();
  connectionGroup.setConnection_group_name(name);
  connectionGroup.setParent_id(parentID);
  connectionGroupDAO.insert(connectionGroup);
  return toMySQLConnectionGroup(connectionGroup,userID);
}

Fixed version (ground truth):
/** 
 * Creates a new connection group having the given name and protocol.
 * @param name The name to assign to the new connection group.
 * @param userID The ID of the user who created this connection group.
 * @param Type The type of the new connection group.
 * @return A new MySQLConnectionGroup containing the data of the newly createdconnection group.
 */
public MySQLConnectionGroup createConnectionGroup(String name,int userID,Integer parentID,String type){
  ConnectionGroup connectionGroup=new ConnectionGroup();
  connectionGroup.setConnection_group_name(name);
  connectionGroup.setParent_id(parentID);
  connectionGroup.setType(type);
  connectionGroupDAO.insert(connectionGroup);
  return toMySQLConnectionGroup(connectionGroup,userID);
}
Program: 52328
Project: 52328
Buggy source:
@Override protected void authenticatedService(UserContext context,HttpServletRequest request,HttpServletResponse response) throws GuacamoleException {
  String name=request.getParameter("String_Node_Str");
  String parentID=request.getParameter("String_Node_Str");
  Directory<String,ConnectionGroup> directory=ConnectionGroupUtility.findConnectionGroupDirectory(context,parentID);
  if (directory == null)   throw new GuacamoleException("String_Node_Str");
  ConnectionGroup connectionGroup=new DummyConnectionGroup();
  connectionGroup.setName(name);
  directory.add(connectionGroup);
}

Fixed version (ground truth):
@Override protected void authenticatedService(UserContext context,HttpServletRequest request,HttpServletResponse response) throws GuacamoleException {
  String name=request.getParameter("String_Node_Str");
  String type=request.getParameter("String_Node_Str");
  String parentID=request.getParameter("String_Node_Str");
  Directory<String,ConnectionGroup> directory=ConnectionGroupUtility.findConnectionGroupDirectory(context,parentID);
  if (directory == null)   throw new GuacamoleException("String_Node_Str");
  ConnectionGroup connectionGroup=new DummyConnectionGroup();
  connectionGroup.setName(name);
  if ("String_Node_Str".equals(type))   connectionGroup.setType(ConnectionGroup.Type.BALANCING);
 else   if ("String_Node_Str".equals(type))   connectionGroup.setType(ConnectionGroup.Type.ORGANIZATIONAL);
  directory.add(connectionGroup);
}
Program: 52329
Project: 52329
Buggy source:
@Override protected void authenticatedService(UserContext context,HttpServletRequest request,HttpServletResponse response) throws GuacamoleException {
  String identifier=request.getParameter("String_Node_Str");
  String name=request.getParameter("String_Node_Str");
  Directory<String,ConnectionGroup> directory=context.getRootConnectionGroup().getConnectionGroupDirectory();
  ConnectionGroup connectionGroup=directory.get(identifier);
  connectionGroup.setName(name);
  directory.update(connectionGroup);
}

Fixed version (ground truth):
@Override protected void authenticatedService(UserContext context,HttpServletRequest request,HttpServletResponse response) throws GuacamoleException {
  String identifier=request.getParameter("String_Node_Str");
  String name=request.getParameter("String_Node_Str");
  String type=request.getParameter("String_Node_Str");
  Directory<String,ConnectionGroup> directory=context.getRootConnectionGroup().getConnectionGroupDirectory();
  ConnectionGroup connectionGroup=directory.get(identifier);
  connectionGroup.setName(name);
  if ("String_Node_Str".equals(type))   connectionGroup.setType(ConnectionGroup.Type.BALANCING);
 else   if ("String_Node_Str".equals(type))   connectionGroup.setType(ConnectionGroup.Type.ORGANIZATIONAL);
  directory.update(connectionGroup);
}
Program: 52330
Project: 52330
Buggy source:
/** 
 * Create any new permissions having to do with connection groups  for a given user.
 * @param user_id The ID of the user to assign or remove permissions from.
 * @param permissions The new permissions the user should have after thisoperation completes.
 * @throws GuacamoleException If permission to alter the access permissionsof affected objects is deniedD
 */
private void createConnectionGroupPermissions(int user_id,Collection<ConnectionGroupPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  Set<Integer> administerableConnectionGroupIDs=Sets.<Integer>newHashSet(permissionCheckService.retrieveConnectionGroupIDs(this.user_id,MySQLConstants.CONNECTION_GROUP_ADMINISTER));
  for (  ConnectionGroupPermission permission : permissions) {
    Integer connection_group_id=Integer.valueOf(permission.getObjectIdentifier());
    if (!administerableConnectionGroupIDs.contains(connection_group_id))     throw new GuacamoleSecurityException("String_Node_Str" + this.user_id + "String_Node_Str"+ permission.getObjectIdentifier());
    ConnectionGroupPermissionKey newPermission=new ConnectionGroupPermissionKey();
    newPermission.setUser_id(user_id);
    newPermission.setPermission(MySQLConstants.getConnectionConstant(permission.getType()));
    newPermission.setConnection_group_id(connection_group_id);
    connectionGroupPermissionDAO.insert(newPermission);
  }
}

Fixed version (ground truth):
/** 
 * Create any new permissions having to do with connection groups  for a given user.
 * @param user_id The ID of the user to assign or remove permissions from.
 * @param permissions The new permissions the user should have after thisoperation completes.
 * @throws GuacamoleException If permission to alter the access permissionsof affected objects is deniedD
 */
private void createConnectionGroupPermissions(int user_id,Collection<ConnectionGroupPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  Set<Integer> administerableConnectionGroupIDs=Sets.<Integer>newHashSet(permissionCheckService.retrieveConnectionGroupIDs(this.user_id,MySQLConstants.CONNECTION_GROUP_ADMINISTER));
  for (  ConnectionGroupPermission permission : permissions) {
    Integer connection_group_id=Integer.valueOf(permission.getObjectIdentifier());
    if (!administerableConnectionGroupIDs.contains(connection_group_id))     throw new GuacamoleSecurityException("String_Node_Str" + this.user_id + "String_Node_Str"+ permission.getObjectIdentifier());
    ConnectionGroupPermissionKey newPermission=new ConnectionGroupPermissionKey();
    newPermission.setUser_id(user_id);
    newPermission.setPermission(MySQLConstants.getConnectionGroupConstant(permission.getType()));
    newPermission.setConnection_group_id(connection_group_id);
    connectionGroupPermissionDAO.insert(newPermission);
  }
}
Program: 52332
Project: 52332
Buggy source:
@Override protected void initialize(){
  bindDataSourceProviderType(PooledDataSourceProvider.class);
  bindTransactionFactoryType(JdbcTransactionFactory.class);
  addMapperClass(ConnectionHistoryMapper.class);
  addMapperClass(ConnectionMapper.class);
  addMapperClass(ConnectionGroupMapper.class);
  addMapperClass(ConnectionParameterMapper.class);
  addMapperClass(ConnectionPermissionMapper.class);
  addMapperClass(SystemPermissionMapper.class);
  addMapperClass(UserMapper.class);
  addMapperClass(UserPermissionMapper.class);
  bind(MySQLUserContext.class);
  bind(UserDirectory.class);
  bind(MySQLUser.class);
  bind(SaltService.class).to(SecureRandomSaltService.class);
  bind(PasswordEncryptionService.class).to(SHA256PasswordEncryptionService.class);
  bind(PermissionCheckService.class);
  bind(ConnectionService.class);
  bind(ConnectionGroupService.class);
  bind(UserService.class);
  bind(ActiveConnectionMap.class).toInstance(activeConnectionMap);
}

Fixed version (ground truth):
@Override protected void initialize(){
  bindDataSourceProviderType(PooledDataSourceProvider.class);
  bindTransactionFactoryType(JdbcTransactionFactory.class);
  addMapperClass(ConnectionHistoryMapper.class);
  addMapperClass(ConnectionMapper.class);
  addMapperClass(ConnectionGroupMapper.class);
  addMapperClass(ConnectionGroupPermissionMapper.class);
  addMapperClass(ConnectionParameterMapper.class);
  addMapperClass(ConnectionPermissionMapper.class);
  addMapperClass(SystemPermissionMapper.class);
  addMapperClass(UserMapper.class);
  addMapperClass(UserPermissionMapper.class);
  bind(MySQLUserContext.class);
  bind(UserDirectory.class);
  bind(MySQLUser.class);
  bind(SaltService.class).to(SecureRandomSaltService.class);
  bind(PasswordEncryptionService.class).to(SHA256PasswordEncryptionService.class);
  bind(PermissionCheckService.class);
  bind(ConnectionService.class);
  bind(ConnectionGroupService.class);
  bind(UserService.class);
  bind(ActiveConnectionMap.class).toInstance(activeConnectionMap);
}
Program: 52333
Project: 52333
Buggy source:
/** 
 * Initialize from explicit values.
 * @param connectionGroupID The ID of the associated database record, if any.
 * @param parentID The ID of the parent connection group for this connection group, if any.
 * @param identifier The unique identifier associated with this connection group.
 * @param type The type of this connection group.
 * @param userID The IID of the user who queried this connection.
 */
public void init(Integer connectionGroupID,Integer parentID,String name,String identifier,String type,int userID){
  this.connectionGroupID=connectionGroupID;
  this.parentID=parentID;
  setName(name);
  setIdentifier(identifier);
  this.userID=userID;
  connectionDirectory=connectionDirectoryProvider.get();
  connectionDirectory.init(userID,parentID);
  connectionGroupDirectory=connectionGroupDirectoryProvider.get();
  connectionGroupDirectory.init(userID,parentID);
}

Fixed version (ground truth):
/** 
 * Initialize from explicit values.
 * @param connectionGroupID The ID of the associated database record, if any.
 * @param parentID The ID of the parent connection group for this connection group, if any.
 * @param identifier The unique identifier associated with this connection group.
 * @param type The type of this connection group.
 * @param userID The IID of the user who queried this connection.
 */
public void init(Integer connectionGroupID,Integer parentID,String name,String identifier,ConnectionGroup.Type type,int userID){
  this.connectionGroupID=connectionGroupID;
  this.parentID=parentID;
  setName(name);
  setIdentifier(identifier);
  setType(type);
  this.userID=userID;
  connectionDirectory=connectionDirectoryProvider.get();
  connectionDirectory.init(userID,parentID);
  connectionGroupDirectory=connectionGroupDirectoryProvider.get();
  connectionGroupDirectory.init(userID,parentID);
}
Program: 52334
Project: 52334
Buggy source:
/** 
 * Initializes the user and directories associated with this context.
 * @param user_id The ID of the user owning this context.
 */
public void init(int user_id){
  this.user_id=user_id;
  userDirectory.init(user_id);
  mySQLConnectionGroup.init(null,null,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL,user_id);
}

Fixed version (ground truth):
/** 
 * Initializes the user and directories associated with this context.
 * @param user_id The ID of the user owning this context.
 */
public void init(int user_id){
  this.user_id=user_id;
  userDirectory.init(user_id);
  rootConnectionGroup.init(null,null,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER,ConnectionGroup.Type.ORGANIZATIONAL,user_id);
}
Program: 52335
Project: 52335
Buggy source:
@Override public ConnectionGroup getConnectionGroup() throws GuacamoleException {
  return mySQLConnectionGroup;
}

Fixed version (ground truth):
@Override public ConnectionGroup getConnectionGroup() throws GuacamoleException {
  return rootConnectionGroup;
}
Program: 52336
Project: 52336
Buggy source:
/** 
 * Convert the given database-retrieved Connection into a MySQLConnection. The parameters of the given connection will be read and added to the MySQLConnection in the process.
 * @param connection The connection to convert.
 * @param userID The user who queried this connection.
 * @return A new MySQLConnection containing all data associated with thespecified connection.
 */
private MySQLConnectionGroup toMySQLConnectionGroup(ConnectionGroup connectionGroup,int userID){
  MySQLConnectionGroup mySQLConnectionGroup=mysqlConnectionGroupProvider.get();
  mySQLConnectionGroup.init(connectionGroup.getConnection_group_id(),connectionGroup.getParent_id(),connectionGroup.getConnection_group_name(),Integer.toString(connectionGroup.getConnection_group_id()),connectionGroup.getType(),userID);
  return mySQLConnectionGroup;
}

Fixed version (ground truth):
/** 
 * Convert the given database-retrieved Connection into a MySQLConnection. The parameters of the given connection will be read and added to the MySQLConnection in the process.
 * @param connection The connection to convert.
 * @param userID The user who queried this connection.
 * @return A new MySQLConnection containing all data associated with thespecified connection.
 */
private MySQLConnectionGroup toMySQLConnectionGroup(ConnectionGroup connectionGroup,int userID){
  MySQLConnectionGroup mySQLConnectionGroup=mysqlConnectionGroupProvider.get();
  String mySqlType=connectionGroup.getType();
  net.sourceforge.guacamole.net.auth.ConnectionGroup.Type authType;
  if (mySqlType.equals(MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL))   authType=net.sourceforge.guacamole.net.auth.ConnectionGroup.Type.ORGANIZATIONAL;
 else   authType=net.sourceforge.guacamole.net.auth.ConnectionGroup.Type.BALANCING;
  mySQLConnectionGroup.init(connectionGroup.getConnection_group_id(),connectionGroup.getParent_id(),connectionGroup.getConnection_group_name(),Integer.toString(connectionGroup.getConnection_group_id()),authType,userID);
  return mySQLConnectionGroup;
}
Program: 52337
Project: 52337
Buggy source:
/** 
 * Creates a new InetGuacamoleSocket which reads and writes instructions to the Guacamole instruction stream of the Guacamole proxy server running at the given hostname and port.
 * @param hostname The hostname of the Guacamole proxy server to connect to.
 * @param port The port of the Guacamole proxy server to connect to.
 * @throws GuacamoleException If an error occurs while connecting to theGuacamole proxy server.
 */
public SSLGuacamoleSocket(String hostname,int port) throws GuacamoleException {
  SocketFactory socket_factory=SSLSocketFactory.getDefault();
  try {
    logger.debug("String_Node_Str",hostname,port);
    SocketAddress address=new InetSocketAddress(InetAddress.getByName(hostname),port);
    sock=socket_factory.createSocket();
    sock.connect(address,SOCKET_TIMEOUT);
    sock.setSoTimeout(SOCKET_TIMEOUT);
    reader=new ReaderGuacamoleReader(new InputStreamReader(sock.getInputStream(),"String_Node_Str"));
    writer=new WriterGuacamoleWriter(new OutputStreamWriter(sock.getOutputStream(),"String_Node_Str"));
  }
 catch (  IOException e) {
    throw new GuacamoleServerException(e);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new SSLGuacamoleSocket which reads and writes instructions to the Guacamole instruction stream of the Guacamole proxy server running at the given hostname and port using SSL.
 * @param hostname The hostname of the Guacamole proxy server to connect to.
 * @param port The port of the Guacamole proxy server to connect to.
 * @throws GuacamoleException If an error occurs while connecting to theGuacamole proxy server.
 */
public SSLGuacamoleSocket(String hostname,int port) throws GuacamoleException {
  SocketFactory socket_factory=SSLSocketFactory.getDefault();
  try {
    logger.debug("String_Node_Str",hostname,port);
    SocketAddress address=new InetSocketAddress(InetAddress.getByName(hostname),port);
    sock=socket_factory.createSocket();
    sock.connect(address,SOCKET_TIMEOUT);
    sock.setSoTimeout(SOCKET_TIMEOUT);
    reader=new ReaderGuacamoleReader(new InputStreamReader(sock.getInputStream(),"String_Node_Str"));
    writer=new WriterGuacamoleWriter(new OutputStreamWriter(sock.getOutputStream(),"String_Node_Str"));
  }
 catch (  IOException e) {
    throw new GuacamoleServerException(e);
  }
}
Program: 52338
Project: 52338
Buggy source:
/** 
 * Returns the value that will be sent to the client plugin if this option  is chosen.
 * @return The value that will be sent if this option is chosen.
 */
public String getValue(){
  return value;
}

Fixed version (ground truth):
/** 
 * Returns the value that will be sent to the client plugin if this option is chosen.
 * @return The value that will be sent if this option is chosen.
 */
public String getValue(){
  return value;
}
Program: 52339
Project: 52339
Buggy source:
/** 
 * Create any new system permissions for a given user. All permissions in the given list will be inserted.
 * @param user_id The ID of the user whose permissions should be updated.
 * @param permissions The new system permissions that the given user shouldhave when this operation completes.
 */
private void createSystemPermissions(int user_id,Collection<SystemPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  permissionCheckService.verifySystemAccess(this.user_id,SystemPermission.Type.ADMINISTER.name());
  for (  SystemPermission permission : permissions) {
    SystemPermissionKey newSystemPermission=new SystemPermissionKey();
    newSystemPermission.setUser_id(user_id);
    newSystemPermission.setPermission(MySQLConstants.getSystemConstant(permission.getType()));
    systemPermissionDAO.insert(newSystemPermission);
  }
}

Fixed version (ground truth):
/** 
 * Create any new system permissions for a given user. All permissions in the given list will be inserted.
 * @param user_id The ID of the user whose permissions should be updated.
 * @param permissions The new system permissions that the given user shouldhave when this operation completes.
 * @throws GuacamoleException If permission to administer system permissionsis denied.
 */
private void createSystemPermissions(int user_id,Collection<SystemPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  permissionCheckService.verifySystemAccess(this.user_id,SystemPermission.Type.ADMINISTER.name());
  for (  SystemPermission permission : permissions) {
    SystemPermissionKey newSystemPermission=new SystemPermissionKey();
    newSystemPermission.setUser_id(user_id);
    newSystemPermission.setPermission(MySQLConstants.getSystemConstant(permission.getType()));
    systemPermissionDAO.insert(newSystemPermission);
  }
}
Program: 52340
Project: 52340
Buggy source:
@Transactional @Override public Set<String> getIdentifiers() throws GuacamoleException {
  List<Integer> connectionIDs=permissionCheckService.retrieveConnectionIDs(this.user_id,MySQLConstants.CONNECTION_READ);
  return connectionService.translateNames(connectionIDs).keySet();
}

Fixed version (ground truth):
@Transactional @Override public Set<String> getIdentifiers() throws GuacamoleException {
  return permissionCheckService.retrieveConnectionNames(user_id,MySQLConstants.CONNECTION_READ);
}
Program: 52341
Project: 52341
Buggy source:
/** 
 * Delete permissions having to do with connections for a given user.
 * @param user_id The ID of the user to change the permissions of.
 * @param permissions The permissions the given user should no longer havewhen this operation completes.
 * @throws GuacamoleException If permission to alter the access permissionsof affected objects is denied.
 */
private void deleteConnectionPermissions(int user_id,Collection<ConnectionPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  List<Integer> administerableConnectionIDs=permissionCheckService.retrieveUserIDs(this.user_id,MySQLConstants.CONNECTION_ADMINISTER);
  Map<String,Integer> administerableConnections=userService.translateUsernames(administerableConnectionIDs);
  for (  ConnectionPermission permission : permissions) {
    Integer connection_id=administerableConnections.get(permission.getObjectIdentifier());
    if (connection_id == null)     throw new GuacamoleSecurityException("String_Node_Str" + this.user_id + "String_Node_Str"+ permission.getObjectIdentifier());
    ConnectionPermissionExample connectionPermissionExample=new ConnectionPermissionExample();
    connectionPermissionExample.createCriteria().andUser_idEqualTo(user_id).andPermissionEqualTo(MySQLConstants.getConnectionConstant(permission.getType())).andConnection_idEqualTo(connection_id);
    connectionPermissionDAO.deleteByExample(connectionPermissionExample);
  }
}

Fixed version (ground truth):
/** 
 * Delete permissions having to do with connections for a given user.
 * @param user_id The ID of the user to change the permissions of.
 * @param permissions The permissions the given user should no longer havewhen this operation completes.
 * @throws GuacamoleException If permission to alter the access permissionsof affected objects is denied.
 */
private void deleteConnectionPermissions(int user_id,Collection<ConnectionPermission> permissions) throws GuacamoleException {
  if (permissions.isEmpty())   return;
  List<Integer> administerableConnectionIDs=permissionCheckService.retrieveConnectionIDs(this.user_id,MySQLConstants.CONNECTION_ADMINISTER);
  Map<String,Integer> administerableConnections=connectionService.translateNames(administerableConnectionIDs);
  for (  ConnectionPermission permission : permissions) {
    Integer connection_id=administerableConnections.get(permission.getObjectIdentifier());
    if (connection_id == null)     throw new GuacamoleSecurityException("String_Node_Str" + this.user_id + "String_Node_Str"+ permission.getObjectIdentifier());
    ConnectionPermissionExample connectionPermissionExample=new ConnectionPermissionExample();
    connectionPermissionExample.createCriteria().andUser_idEqualTo(user_id).andPermissionEqualTo(MySQLConstants.getConnectionConstant(permission.getType())).andConnection_idEqualTo(connection_id);
    connectionPermissionDAO.deleteByExample(connectionPermissionExample);
  }
}
Program: 52342
Project: 52342
Buggy source:
@Transactional @Override public Set<String> getIdentifiers() throws GuacamoleException {
  List<Integer> userIDs=permissionCheckService.retrieveConnectionIDs(this.user_id,MySQLConstants.USER_READ);
  return userService.translateUsernames(userIDs).keySet();
}

Fixed version (ground truth):
@Transactional @Override public Set<String> getIdentifiers() throws GuacamoleException {
  return permissionCheckService.retrieveUsernames(user_id,MySQLConstants.USER_READ);
}
Program: 52343
Project: 52343
Buggy source:
/** 
 * Get the IDs of all the connection defined in the system.
 * @param userID The ID of the user who is querying the connections.
 * @return A list of IDs of all the connections defined in the system.
 */
public List<Integer> getAllConnectionIDs(int userID){
  List<Integer> connectionIDs=new ArrayList<Integer>();
  for (  MySQLConnection connection : getAllConnections(userID)) {
    connectionIDs.add(connection.getConnectionID());
  }
  return connectionIDs;
}

Fixed version (ground truth):
/** 
 * Get the connection IDs of all the connections defined in the system.
 * @return A list of connection IDs of all the connections defined in the system.
 */
public List<Integer> getAllConnectionIDs(){
  List<Integer> connectionIDs=new ArrayList<Integer>();
  List<Connection> connections=connectionDAO.selectByExample(new ConnectionExample());
  for (  Connection connection : connections)   connectionIDs.add(connection.getConnection_id());
  return connectionIDs;
}
Program: 52344
Project: 52344
Buggy source:
/** 
 * Find the list of the IDs of all connections a user has permission to. The access type is defined by permissionType.
 * @param userID The ID of the user to check.
 * @param permissionType The type of permission to check for.
 * @return A list of all connection IDs this user has the specified accessto.
 */
public List<Integer> retrieveConnectionIDs(int userID,String permissionType){
  if (checkSystemAdministratorAccess(userID)) {
    return connectionService.getAllConnectionIDs(userID);
  }
  ConnectionPermissionExample example=new ConnectionPermissionExample();
  example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(permissionType);
  example.setDistinct(true);
  List<ConnectionPermissionKey> connectionPermissions=connectionPermissionDAO.selectByExample(example);
  List<Integer> connectionIDs=new ArrayList<Integer>(connectionPermissions.size());
  for (  ConnectionPermissionKey permission : connectionPermissions)   connectionIDs.add(permission.getConnection_id());
  return connectionIDs;
}

Fixed version (ground truth):
/** 
 * Find the list of the IDs of all connections a user has permission to. The access type is defined by permissionType.
 * @param userID The ID of the user to check.
 * @param permissionType The type of permission to check for.
 * @return A list of all connection IDs this user has the specified accessto.
 */
public List<Integer> retrieveConnectionIDs(int userID,String permissionType){
  if (checkSystemAdministratorAccess(userID))   return connectionService.getAllConnectionIDs();
  ConnectionPermissionExample example=new ConnectionPermissionExample();
  example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(permissionType);
  example.setDistinct(true);
  List<ConnectionPermissionKey> connectionPermissions=connectionPermissionDAO.selectByExample(example);
  List<Integer> connectionIDs=new ArrayList<Integer>(connectionPermissions.size());
  for (  ConnectionPermissionKey permission : connectionPermissions)   connectionIDs.add(permission.getConnection_id());
  return connectionIDs;
}