List of usage examples for org.eclipse.jgit.util Base64 encodeBytes
public static String encodeBytes(byte[] source)
From source file:com.google.gerrit.httpd.SignedTokenRestTokenVerifier.java
License:Apache License
@Override public String sign(Account.Id user, String url) { try {//from ww w . j a v a 2 s . co m String payload = String.format("%s:%s", user, url); byte[] utf8 = payload.getBytes("UTF-8"); String base64 = Base64.encodeBytes(utf8); return restToken.newToken(base64); } catch (XsrfException e) { throw new IllegalArgumentException(e); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } }
From source file:com.google.gerrit.server.mail.RegisterNewEmailSender.java
License:Apache License
public String getEmailRegistrationToken() { try {//www . java 2 s . c om return authConfig.getEmailRegistrationToken().newToken(Base64.encodeBytes(addr.getBytes("UTF-8"))); } catch (XsrfException e) { throw new IllegalArgumentException(e); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } }
From source file:com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.java
License:Apache License
@Override public String encode(Account.Id accountId, String emailAddress) { try {/*from w w w . j a v a 2 s . co m*/ String payload = String.format("%s:%s", accountId, emailAddress); byte[] utf8 = payload.getBytes("UTF-8"); String base64 = Base64.encodeBytes(utf8); return emailRegistrationToken.newToken(base64); } catch (XsrfException | UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } }
From source file:com.googlesource.gerrit.plugins.lfs.auth.LfsCipher.java
License:Apache License
public String encrypt(String input) { try {/*from ww w . j av a 2 s .c o m*/ byte[] initVector = new byte[IV_LENGTH]; random.nextBytes(initVector); Cipher cipher = cipher(initVector, Cipher.ENCRYPT_MODE); return Base64.encodeBytes(Bytes.concat(initVector, cipher.doFinal(input.getBytes(UTF_8)))); } catch (GeneralSecurityException e) { log.atSevere().withCause(e).log("Token generation failed with error"); throw new RuntimeException(e); } }
From source file:com.meltmedia.cadmium.core.github.ApiClient.java
License:Apache License
private static void setupBasicAuth(String username, String password, HttpMessage message) { message.addHeader("Authorization", "Basic " + Base64.encodeBytes(new String(username + ":" + password).getBytes())); }
From source file:com.photon.phresco.framework.impl.SCMManagerImpl.java
License:Apache License
private static final String toBase64(final byte[] content) { return Base64.encodeBytes(content); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.github.GitHubRawFileContentProvider.java
License:Apache License
private URLConnection getConnection(@NotNull GitVcsRoot root, @NotNull String filePath, @NotNull String version) throws IOException { URL url = new URL( "https://raw.github.com/" + myOwner + "/" + myRepository + "/" + version + "/" + filePath); URLConnection c = url.openConnection(); AuthSettings auth = root.getAuthSettings(); if (auth.getAuthMethod() == AuthenticationMethod.PASSWORD && auth.getUserName() != null && auth.getPassword() != null) { String credentials = auth.getUserName() + ":" + auth.getPassword(); c.setRequestProperty("Authorization", "Basic " + Base64.encodeBytes(credentials.getBytes("UTF-8"))); }//from w ww. j a v a 2s . c o m return c; }