当前位置: 首页>>代码示例>>Java>>正文


Java CredentialItem.Password方法代码示例

本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem.Password方法的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem.Password方法的具体用法?Java CredentialItem.Password怎么用?Java CredentialItem.Password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.transport.CredentialItem的用法示例。


在下文中一共展示了CredentialItem.Password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUsernamePassword

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
public UsernamePassword getUsernamePassword(URIish uri) {
  addDefaultCredentials(credentials);

  String username = uri.getUser();
  String password = uri.getPass();

  CredentialItem.Username u = new CredentialItem.Username();
  CredentialItem.Password p = new CredentialItem.Password();

  if (supports(u, p) && get(uri, u, p)) {
    username = u.getValue();
    char[] v = p.getValue();
    password = (v == null) ? null : new String(p.getValue());
    p.clear();
  }

  return new UsernamePassword(username, password);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:19,代码来源:UsernamePasswordCredentialsProvider.java

示例2: get

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish urIish, CredentialItem... credentialItems) throws UnsupportedCredentialItem {
    if (userCredentials != null) {
        Iterator<String> userCredentialsIterator = userCredentials.iterator();
        for(CredentialItem item : credentialItems) {
            String nextValue = userCredentialsIterator.next();
            if (item instanceof CredentialItem.Username) {
                ((CredentialItem.Username)item).setValue(nextValue);
            } else if (item instanceof CredentialItem.Password) {
                ((CredentialItem.Password)item).setValue(nextValue.toCharArray());
            } else if (item instanceof CredentialItem.StringType) {
                ((CredentialItem.StringType)item).setValue(nextValue);
            } else {
                System.out.println(item);
                System.out.println(item.getPromptText());
                throw new UnsupportedCredentialItem(urIish, "Case not covered in ElegitCredentialsProvider");
            }
        }
    }
    return true;
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:22,代码来源:ElegitCredentialsProvider.java

示例3: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/**
 * We support username and password credential items only.
 * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[])
 */
@Override
public boolean supports(CredentialItem... items) {
	for (CredentialItem i : items) {
		if (i instanceof CredentialItem.Username) {
			continue;
		}
		else if (i instanceof CredentialItem.Password) {
			continue;
		}
		else {
			return false;
		}
	}
	return true;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:20,代码来源:AwsCodeCommitCredentialProvider.java

示例4: get

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items)
        throws UnsupportedCredentialItem {
    for (CredentialItem item : items) {
        if (item instanceof CredentialItem.Username) {
            ((CredentialItem.Username) item).setValue(username);
        } else if (item instanceof CredentialItem.Password) {
            ((CredentialItem.Password) item).setValue(password.toCharArray());
        } else if (item instanceof CredentialItem.StringType) {
            ((CredentialItem.StringType) item).setValue(password);
        } else if (item instanceof CredentialItem.InformationalMessage) {
            throw new UnsupportedCredentialItem(uri, "Not supported");
        } else if (item instanceof CredentialItem.YesNoType) {
            // TODO handle strict host key checking here
            throw new UnsupportedCredentialItem(uri, "Not supported");
        } else {
            throw new UnsupportedCredentialItem(uri, "Not supported");
        }
    }
    return true;
}
 
开发者ID:hdweiss,项目名称:mOrgAnd,代码行数:22,代码来源:JGitCredentialsProvider.java

示例5: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * If username/password is given, use it for HTTP auth.
 */
@Override
public boolean supports(CredentialItem... items) {
    if (!(cred instanceof StandardUsernamePasswordCredentials))
        return false;

    for (CredentialItem i : items) {
        if (i instanceof CredentialItem.Username)
            continue;

        else if (i instanceof CredentialItem.Password)
            continue;

        else
            return false;
    }
    return true;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:23,代码来源:CredentialsProviderImpl.java

示例6: setUp

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Before
public void setUp() {
    listener = StreamTaskListener.fromStdout();
    provider = new SmartCredentialsProvider(listener);
    username = new CredentialItem.Username();
    password = new CredentialItem.Password();

    maskedUsername = new StandardUsernameCredentialsCredentialItem(MASKED_USER_NAME_PROMPT, true);
    unmaskedUsername = new StandardUsernameCredentialsCredentialItem(UNMASKED_USER_NAME_PROMPT, false);

    maskedStringType = new CredentialItem.StringType(MASKED_STRING_TYPE_PROMPT, true);
    unmaskedStringType = new CredentialItem.StringType(UNMASKED_STRING_TYPE_PROMPT, false);
    specialStringType = new CredentialItem.StringType(SPECIAL_STRING_TYPE_PROMPT, false);

    assertNull(username.getValue());
    assertNull(password.getValue());
    assertNull(maskedUsername.getValue());
    assertNull(unmaskedUsername.getValue());
    assertNull(maskedStringType.getValue());
    assertNull(unmaskedStringType.getValue());
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:22,代码来源:SmartCredentialsProviderTest.java

示例7: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean supports (CredentialItem... items) {
    for (CredentialItem i : items) {
        if (!(i instanceof CredentialItem.Username
                || i instanceof CredentialItem.Password)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TransportCommand.java

示例8: get

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get (URIish uriish, CredentialItem... items) throws UnsupportedCredentialItem {
    String user = uriish.getUser();
    if (user == null) {
        user = "";
    }
    String password = uriish.getPass();
    if (password == null) {
        password = "";
    }
    for (CredentialItem i : items) {
        if (i instanceof CredentialItem.Username) {
            ((CredentialItem.Username) i).setValue(user);
            continue;
        }
        if (i instanceof CredentialItem.Password) {
            ((CredentialItem.Password) i).setValue(password.toCharArray());
            continue;
        }
        if (i instanceof CredentialItem.StringType) {
            if (i.getPromptText().equals("Password: ")) { //NOI18N
                ((CredentialItem.StringType) i).setValue(password);
                continue;
            }
        }
        throw new UnsupportedCredentialItem(uriish, i.getClass().getName()
                + ":" + i.getPromptText()); //NOI18N
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:TransportCommand.java

示例9: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean supports(CredentialItem... items) {
  for (CredentialItem i : items) {
    if (i instanceof CredentialItem.Username) {
      continue;
    } else if (i instanceof CredentialItem.Password) {
      continue;
    } else {
      return false;
    }
  }
  return true;
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:14,代码来源:SecureCredentialsProvider.java

示例10: get

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
  String username = uri.getUser();
  if (username == null) {
    username = cfgUser;
  }
  if (username == null) {
    return false;
  }

  String password = uri.getPass();
  if (password == null) {
    password = cfgPass;
  }
  if (password == null) {
    return false;
  }

  for (CredentialItem i : items) {
    if (i instanceof CredentialItem.Username) {
      ((CredentialItem.Username) i).setValue(username);
    } else if (i instanceof CredentialItem.Password) {
      ((CredentialItem.Password) i).setValue(password.toCharArray());
    } else {
      throw new UnsupportedCredentialItem(uri, i.getPromptText());
    }
  }
  return true;
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:30,代码来源:SecureCredentialsProvider.java

示例11: handle

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private void handle(URIish uri, CredentialItem.CharArrayType ci) {
    if (ci instanceof CredentialItem.Password && uri.getPass() != null) {
        ci.setValue(uri.getPass().toCharArray());
    } else {
        ci.setValue(blockingPrompt.request(prompt(String.class, uiNotificationFor(ci))).toCharArray());
    }
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:8,代码来源:GUICredentialsProvider.java

示例12: usernamePasswordShouldSetCredentials

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void usernamePasswordShouldSetCredentials() throws Exception {
	Git mockGit = mock(Git.class);
	MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);

	JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
	envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
	envRepository.setUri("git+ssh://[email protected]/somegitrepo");
	envRepository.setBasedir(new File("./mybasedir"));
	final String username = "someuser";
	final String password = "mypassword";
	envRepository.setUsername(username);
	envRepository.setPassword(password);
	envRepository.setCloneOnStart(true);
	envRepository.afterPropertiesSet();

	assertTrue(mockCloneCommand.getCredentialsProvider() instanceof UsernamePasswordCredentialsProvider);

	CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
	CredentialItem.Username usernameCredential = new CredentialItem.Username();
	CredentialItem.Password passwordCredential = new CredentialItem.Password();
	assertTrue(provider.supports(usernameCredential));
	assertTrue(provider.supports(passwordCredential));

	provider.get(new URIish(), usernameCredential);
	assertEquals(usernameCredential.getValue(), username);
	provider.get(new URIish(), passwordCredential);
	assertEquals(String.valueOf(passwordCredential.getValue()), password);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:30,代码来源:JGitEnvironmentRepositoryTests.java

示例13: gitCredentialsProviderFactoryCreatesUsernamePasswordProvider

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Test
public void gitCredentialsProviderFactoryCreatesUsernamePasswordProvider() throws Exception {
	GitCredentialsProviderFactory credentialsFactory = new GitCredentialsProviderFactory();
	Git mockGit = mock(Git.class);
	MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);
	final String username = "someuser";
	final String password = "mypassword";

	JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
	envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
	envRepository.setUri("git+ssh://[email protected]/somegitrepo");
	envRepository.setBasedir(new File("./mybasedir"));
	envRepository.setGitCredentialsProvider(
			credentialsFactory.createFor(envRepository.getUri(), username, password, null));
	envRepository.setCloneOnStart(true);
	envRepository.afterPropertiesSet();

	assertTrue(mockCloneCommand.getCredentialsProvider() instanceof UsernamePasswordCredentialsProvider);

	CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
	CredentialItem.Username usernameCredential = new CredentialItem.Username();
	CredentialItem.Password passwordCredential = new CredentialItem.Password();
	assertTrue(provider.supports(usernameCredential));
	assertTrue(provider.supports(passwordCredential));

	provider.get(new URIish(), usernameCredential);
	assertEquals(usernameCredential.getValue(), username);
	provider.get(new URIish(), passwordCredential);
	assertEquals(String.valueOf(passwordCredential.getValue()), password);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:31,代码来源:JGitEnvironmentRepositoryTests.java

示例14: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
@Override
public boolean supports(CredentialItem... items) {
  for (CredentialItem item : items) {
    if (item instanceof CredentialItem.Password) {
      continue;
    }
    if (item instanceof CredentialItem.Username) {
      continue;
    }
    return false;
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:GitHttpCredentialsProvider.java

示例15: supports

import org.eclipse.jgit.transport.CredentialItem; //导入方法依赖的package包/类
private boolean supports(StandardCredentials c, CredentialItem i) {
    if (c == null) {
        return false;
    }
    if (i instanceof StandardUsernameCredentialsCredentialItem) {
        return c instanceof StandardUsernameCredentials;
    }
    if (i instanceof CredentialItem.Username) {
        return c instanceof UsernameCredentials;
    }
    if (i instanceof CredentialItem.Password) {
        return c instanceof PasswordCredentials;
    }
    return false;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:16,代码来源:SmartCredentialsProvider.java


注:本文中的org.eclipse.jgit.transport.CredentialItem.Password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。