Search in sources :

Example 1 with PersonalAccessTokenInfo

use of com.oxygenxml.git.options.PersonalAccessTokenInfo in project oxygen-git-client-addon by oxygenxml.

the class AuthUtil method getCredentialsProvider.

/**
 * Get the credentials provider for the given host.
 *
 * @param host The host.
 *
 * @return The credentials provider.
 */
public static SSHCapableUserCredentialsProvider getCredentialsProvider(String host) {
    CredentialsBase credentials = OptionsManager.getInstance().getGitCredentials(host);
    CredentialsType credentialsType = credentials.getType();
    return new SSHCapableUserCredentialsProvider(credentialsType == CredentialsType.USER_AND_PASSWORD ? ((UserAndPasswordCredentials) credentials).getUsername() : ((PersonalAccessTokenInfo) credentials).getTokenValue(), credentialsType == CredentialsType.USER_AND_PASSWORD ? ((UserAndPasswordCredentials) credentials).getPassword() : ((PersonalAccessTokenInfo) credentials).getTokenValue(), OptionsManager.getInstance().getSshPassphrase(), credentials.getHost());
}
Also used : CredentialsBase(com.oxygenxml.git.options.CredentialsBase) CredentialsType(com.oxygenxml.git.options.CredentialsBase.CredentialsType) UserAndPasswordCredentials(com.oxygenxml.git.options.UserAndPasswordCredentials) PersonalAccessTokenInfo(com.oxygenxml.git.options.PersonalAccessTokenInfo)

Example 2 with PersonalAccessTokenInfo

use of com.oxygenxml.git.options.PersonalAccessTokenInfo in project oxygen-git-client-addon by oxygenxml.

the class LoginDialog method doOK.

@Override
protected void doOK() {
    if (basicAuthRadio.isSelected()) {
        String username = tfUsername.getText().trim();
        String password = new String(pfPassword.getPassword());
        credentials = new UserAndPasswordCredentials(username, password, host);
    } else {
        String tokenValue = new String(tokenPassField.getPassword());
        credentials = new PersonalAccessTokenInfo(host, tokenValue);
    }
    OptionsManager.getInstance().saveGitCredentials(credentials);
    super.doOK();
}
Also used : UserAndPasswordCredentials(com.oxygenxml.git.options.UserAndPasswordCredentials) PersonalAccessTokenInfo(com.oxygenxml.git.options.PersonalAccessTokenInfo)

Aggregations

PersonalAccessTokenInfo (com.oxygenxml.git.options.PersonalAccessTokenInfo)2 UserAndPasswordCredentials (com.oxygenxml.git.options.UserAndPasswordCredentials)2 CredentialsBase (com.oxygenxml.git.options.CredentialsBase)1 CredentialsType (com.oxygenxml.git.options.CredentialsBase.CredentialsType)1