PageRenderTime 54ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/com/atlassian/jira/plugins/bitbucket/api/impl/DefaultAuthenticationFactory.java

https://bitbucket.org/atlassian/jira-bitbucket-connector/
Java | 29 lines | 21 code | 5 blank | 3 comment | 2 complexity | b9f4101af43f1885191e19c5ac26f006 MD5 | raw file
  1. package com.atlassian.jira.plugins.bitbucket.api.impl;
  2. import org.apache.commons.lang.StringUtils;
  3. import com.atlassian.jira.plugins.bitbucket.api.Authentication;
  4. import com.atlassian.jira.plugins.bitbucket.api.AuthenticationFactory;
  5. import com.atlassian.jira.plugins.bitbucket.api.SourceControlRepository;
  6. public class DefaultAuthenticationFactory implements AuthenticationFactory
  7. {
  8. @Override
  9. public Authentication getAuthentication(SourceControlRepository repository)
  10. {
  11. // oAuth
  12. if (StringUtils.isNotBlank(repository.getAccessToken()))
  13. {
  14. return new GithubOAuthAuthentication(repository.getAccessToken());
  15. }
  16. // basic
  17. if (StringUtils.isNotBlank(repository.getUsername()))
  18. {
  19. return new BasicAuthentication(repository.getUsername(), repository.getPassword());
  20. }
  21. // none
  22. return Authentication.ANONYMOUS;
  23. }
  24. }