code: public void setName(String newName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
          AgentInfo agentInfo = new AgentInfo();
          agentInfo.setType(IQ.Type.set);
          agentInfo.setTo(workgroupJID);
          agentInfo.setFrom(getUser());
          agentInfo.setName(newName);
          connection.createStanzaCollectorAndSend(agentInfo).nextResultOrThrow();
      }
docs: Changes the name of the agent in the server. The server may have this functionality
  disabled for all the agents or for this agent in particular. If the agent is not
  allowed to change his name then an exception will be thrown with a service_unavailable
  error code.
  
  @param newName the new name of the agent.
  @throws XMPPErrorException
  @throws NoResponseException
  @throws NotConnectedException
  @throws InterruptedException