@@ -0,0 +1,1943 @@
+package io.github.saidie.plantuml_api;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport javax.inject.Inject;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.social.connect.ConnectionRepository;%0Aimport org.springframework.social.twitter.api.Twitter;%0Aimport org.springframework.stereotype.Service;%0A%0A@Service%0Apublic class AccountService %7B%0A    @Inject%0A    private Twitter twitter;%0A%0A    @Inject%0A    private ConnectionRepository connectionRepository;%0A%0A    @Autowired%0A    private FederationRepository federationRepository;%0A%0A    @Autowired%0A    private AccountRepository accountRepository;%0A%0A    public boolean isIdpAuthenticated() %7B%0A        return isTwitterAuthenticated();%0A    %7D%0A%0A    protected boolean isTwitterAuthenticated() %7B%0A        return connectionRepository.findPrimaryConnection(Twitter.class) != null;%0A    %7D%0A%0A    public Account getCurrentAccount() %7B%0A        // TODO: check cookie%0A%0A        if (isTwitterAuthenticated()) %7B%0A            long id = twitter.userOperations().getUserProfile().getId();%0A            IdpId idpId = new IdpId(IdpId.FederationType.TWITTER, Long.toString(id));%0A            Federation federation = federationRepository.findOne(idpId);%0A            if (federation != null)%0A                return federation.getAccount();%0A        %7D%0A        return null;%0A    %7D%0A%0A    public Account createAccount(String username) %7B%0A        List%3CFederation%3E list = new ArrayList%3CFederation%3E();%0A%0A        IdpId idpId = null;%0A        if (isTwitterAuthenticated()) %7B%0A            long id = twitter.userOperations().getUserProfile().getId();%0A            idpId = new IdpId(IdpId.FederationType.TWITTER, Long.toString(id));%0A        %7D%0A        Account account = new Account();%0A        Federation federation = new Federation(idpId, account);%0A        list.add(federation);%0A%0A        account.setUsername(username);%0A        account.setFederations(list);%0A%0A        return accountRepository.save(account);%0A    %7D%0A%7D%0A

Add Account service