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


Java Base64.decodeBase64方法代码示例

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


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

示例1: verifyIdentity

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
@Override
protected boolean verifyIdentity(HttpServletRequest request) {
	String authHeader = request.getHeader("Authorization");
	if (authHeader != null) {
		StringTokenizer st = new StringTokenizer(authHeader);
		if (st.hasMoreTokens()) {
			String basic = st.nextToken();
			if (basic.equalsIgnoreCase("Basic")) {
				try {
					String credentials = new String(Base64.decodeBase64(st.nextToken()), "UTF-8");
					log.finest("Credentials: " + credentials);
					int p = credentials.indexOf(":");
					if (p != -1) {
						String login = credentials.substring(0, p).trim();
						String password = credentials.substring(p + 1).trim();
						if (AppConfiguration.USERNAME.equals(login) && AppConfiguration.PASSWORD.equals(password))
							return true;
						return false;
					} else {
						log.warning("Invalid authentication token from: " + request.getRemoteAddr());
						return false;
					}
				} catch (UnsupportedEncodingException e) {
					log.log(Level.WARNING, "Couldn't retrieve authentication", e);
					return false;
				}
			} else
				log.finest("Not basic auth " + basic + " from " + request.getRemoteAddr());
		} else
			log.finest("No tokens from: " + request.getRemoteAddr());
	} else
		log.finest("No auth header found from: " + request.getRemoteAddr());
	return false;
}
 
开发者ID:baldapps,项目名称:google-actions,代码行数:35,代码来源:DummyApiAiServlet.java

示例2: extractJwsData

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
/**
 * Extracts the data part from a JWS signature.
 */
private static byte[] extractJwsData(String jws) {
    // The format of a JWS is:
    // <Base64url encoded header>.<Base64url encoded JSON data>.<Base64url encoded signature>
    // Split the JWS into the 3 parts and return the JSON data part.
    String[] parts = jws.split("[.]");
    if (parts.length != 3) {
        System.err.println("Failure: Illegal JWS signature format. The JWS consists of "
                + parts.length + " parts instead of 3.");
        return null;
    }
    return Base64.decodeBase64(parts[1]);
}
 
开发者ID:googlesamples,项目名称:android-play-safetynet,代码行数:16,代码来源:OnlineVerify.java

示例3: getApkCertificateDigestSha256

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[][] getApkCertificateDigestSha256() {
    byte[][] certs = new byte[apkCertificateDigestSha256.length][];
    for (int i = 0; i < apkCertificateDigestSha256.length; i++) {
        certs[i] = Base64.decodeBase64(apkCertificateDigestSha256[i]);
    }
    return certs;
}
 
开发者ID:googlesamples,项目名称:android-play-safetynet,代码行数:8,代码来源:AttestationStatement.java

示例4: createAppEngineDefaultServiceAccountKey

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
/**
 * Creates and saves a service account key the App Engine default service account.
 *
 * @param credential credential to use to create a service account key
 * @param projectId GCP project ID for {@code serviceAccountId} 
 * @param destination path of a key file to be saved
 */
public static void createAppEngineDefaultServiceAccountKey(IGoogleApiFactory apiFactory,
    Credential credential, String projectId, Path destination)
        throws FileAlreadyExistsException, IOException {
  Preconditions.checkNotNull(credential, "credential not given");
  Preconditions.checkState(!projectId.isEmpty(), "project ID empty");
  Preconditions.checkArgument(destination.isAbsolute(), "destination not absolute");

  if (!Files.exists(destination.getParent())) {
    Files.createDirectories(destination.getParent());
  }

  Iam iam = apiFactory.newIamApi(credential);
  Keys keys = iam.projects().serviceAccounts().keys();
  
  String projectEmail = projectId;
  // The appengine service account for google.com:gcloud-for-eclipse-testing 
  // would be [email protected]m.
  if (projectId.contains(":")) {
    String[] parts = projectId.split(":");
    projectEmail = parts[1] + "." + parts[0];
  }
  String serviceAccountId = projectEmail + "@appspot.gserviceaccount.com";

  String keyId = "projects/" + projectId + "/serviceAccounts/" + serviceAccountId;
  CreateServiceAccountKeyRequest createRequest = new CreateServiceAccountKeyRequest();
  ServiceAccountKey key = keys.create(keyId, createRequest).execute();

  byte[] jsonKey = Base64.decodeBase64(key.getPrivateKeyData());
  Files.write(destination, jsonKey);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:38,代码来源:ServiceAccountUtil.java

示例5: uploadFile

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
/**
 * Uploads a given file to Google Storage.
 */
private void uploadFile(Path filePath) throws IOException {
  try {
    byte[] md5hash =
        Base64.decodeBase64(
            storage
                .objects()
                .get(projectName + "-cloud-pubsub-loadtest", filePath.getFileName().toString())
                .execute()
                .getMd5Hash());
    try (InputStream inputStream = Files.newInputStream(filePath, StandardOpenOption.READ)) {
      if (Arrays.equals(md5hash, DigestUtils.md5(inputStream))) {
        log.info("File " + filePath.getFileName() + " is current, reusing.");
        return;
      }
    }
    log.info("File " + filePath.getFileName() + " is out of date, uploading new version.");
    storage
        .objects()
        .delete(projectName + "-cloud-pubsub-loadtest", filePath.getFileName().toString())
        .execute();
  } catch (GoogleJsonResponseException e) {
    if (e.getStatusCode() != NOT_FOUND) {
      throw e;
    }
  }

  storage
      .objects()
      .insert(
          projectName + "-cloud-pubsub-loadtest",
          null,
          new FileContent("application/octet-stream", filePath.toFile()))
      .setName(filePath.getFileName().toString())
      .execute();
  log.info("File " + filePath.getFileName() + " created.");
}
 
开发者ID:GoogleCloudPlatform,项目名称:pubsub,代码行数:40,代码来源:GCEController.java

示例6: rowsFromEncodedQuery

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
static List<TableRow> rowsFromEncodedQuery(String query) throws IOException {
  ListCoder<TableRow> listCoder = ListCoder.of(TableRowJsonCoder.of());
  ByteArrayInputStream input = new ByteArrayInputStream(Base64.decodeBase64(query));
  List<TableRow> rows = listCoder.decode(input, Context.OUTER);
  for (TableRow row : rows) {
    convertNumbers(row);
  }
  return rows;
}
 
开发者ID:apache,项目名称:beam,代码行数:10,代码来源:FakeBigQueryServices.java

示例7: getPrivateKey

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
private PrivateKey getPrivateKey(String privateKey)
    throws NoSuchAlgorithmException, InvalidKeySpecException {
  byte[] privateKeyBytes = Base64.decodeBase64(privateKey);
  PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
  KeyFactory keyFactory = KeyFactory.getInstance("RSA");
  return keyFactory.generatePrivate(keySpec);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:OAuthAuthenticator.java

示例8: base64DecodePrivateKeyStore

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public static KeyStore base64DecodePrivateKeyStore(String pks) throws GeneralSecurityException, IOException {
    if (pks != null && !pks.equals("")) {
        ByteArrayInputStream privateKeyStream = new ByteArrayInputStream(Base64.decodeBase64(pks));
        if (privateKeyStream.available() > 0) {
            KeyStore privateKeyStore = KeyStore.getInstance("PKCS12");
            privateKeyStore.load(privateKeyStream, GoogleSpreadsheet.SECRET);
            if (privateKeyStore.containsAlias("privatekey")) {
                return privateKeyStore;
            }
        }
    }
    return null;
}
 
开发者ID:GlobalTechnology,项目名称:pdi-google-spreadsheet-plugin,代码行数:14,代码来源:GoogleSpreadsheet.java

示例9: getNonce

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getNonce() {
  return Base64.decodeBase64(nonce);
}
 
开发者ID:google,项目名称:webauthndemo,代码行数:4,代码来源:OfflineVerify.java

示例10: getApkDigestSha256

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getApkDigestSha256() {
  return Base64.decodeBase64(apkDigestSha256);
}
 
开发者ID:google,项目名称:webauthndemo,代码行数:4,代码来源:OfflineVerify.java

示例11: getNonce

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getNonce() {
    return Base64.decodeBase64(nonce);
}
 
开发者ID:googlesamples,项目名称:android-play-safetynet,代码行数:4,代码来源:AttestationStatement.java

示例12: getApkDigestSha256

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getApkDigestSha256() {
    return Base64.decodeBase64(apkDigestSha256);
}
 
开发者ID:googlesamples,项目名称:android-play-safetynet,代码行数:4,代码来源:AttestationStatement.java

示例13: decodeValue

import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public static String decodeValue(String value) throws UnsupportedEncodingException {
    byte[] valueDecoded = Base64.decodeBase64(value);
    return new String(valueDecoded, Constants.DEFAULT_ENCODING);
}
 
开发者ID:jenkinsci,项目名称:consul-kv-builder-plugin,代码行数:5,代码来源:ConsulRequestUtils.java


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