public function checkUserAuthentication(JiraToken $token)
 {
     $userInfo = $this->jiraRest->getUserInfo($token->getJiraUsername(), $token->getJiraPassword());
     $user = new User();
     $user->setUsername($token->getJiraUsername());
     $user->setBase64Hash($token->getJiraUsername() . ':' . $token->getJiraPassword());
     $user->setRoles('ROLE_USER');
     if ($userInfo) {
         $user->setEmail($userInfo->emailAddress);
         return $user;
     }
     throw new AuthenticationException('Incorrect login and/or password');
 }
 public function refreshUser(UserInterface $user)
 {
     if (!$user instanceof User) {
         throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
     }
     $decodedUserData = base64_decode($user->getBase64Hash());
     list($username, $password) = explode(':', $decodedUserData);
     $userInfoResponse = $this->jiraRest->getUserInfo($username, $password);
     $userInfo = $userInfoResponse;
     $user = new User();
     $user->setUsername($user->getUsername());
     $user->setEmail($userInfo->emailAddress);
     $user->setBase64Hash($user->getBase64Hash());
     $user->setRoles('ROLE_USER');
     return $user;
 }