Search in sources :

Example 1 with VcsTokenType

use of com.orion.ops.consts.app.VcsTokenType in project orion-ops by lijiahangmax.

the class ApplicationVcsServiceImpl method getVcsUsernamePassword.

@Override
public String[] getVcsUsernamePassword(ApplicationVcsDO vcs) {
    String username = null;
    String password = null;
    VcsAuthType authType = VcsAuthType.of(vcs.getVcsAuthType());
    if (VcsAuthType.PASSWORD.equals(authType)) {
        // 用户名
        String vscUsername = vcs.getVscUsername();
        if (!Strings.isBlank(vscUsername)) {
            username = vscUsername;
            password = ValueMix.decrypt(vcs.getVcsPassword());
        }
    } else {
        // token
        VcsTokenType tokenType = VcsTokenType.of(vcs.getVcsTokenType());
        switch(tokenType) {
            case GITHUB:
                username = Const.EMPTY;
                break;
            case GITEE:
                username = vcs.getVscUsername();
                break;
            case GITLAB:
                username = Const.OAUTH2;
                break;
            default:
                break;
        }
        password = ValueMix.decrypt(vcs.getVcsPrivateToken());
    }
    return new String[] { username, password };
}
Also used : VcsTokenType(com.orion.ops.consts.app.VcsTokenType) VcsAuthType(com.orion.ops.consts.app.VcsAuthType)

Aggregations

VcsAuthType (com.orion.ops.consts.app.VcsAuthType)1 VcsTokenType (com.orion.ops.consts.app.VcsTokenType)1