本文整理汇总了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;
}
示例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]);
}
示例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;
}
示例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);
}
示例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.");
}
示例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;
}
示例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);
}
示例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;
}
示例9: getNonce
import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getNonce() {
return Base64.decodeBase64(nonce);
}
示例10: getApkDigestSha256
import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getApkDigestSha256() {
return Base64.decodeBase64(apkDigestSha256);
}
示例11: getNonce
import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getNonce() {
return Base64.decodeBase64(nonce);
}
示例12: getApkDigestSha256
import com.google.api.client.util.Base64; //导入方法依赖的package包/类
public byte[] getApkDigestSha256() {
return Base64.decodeBase64(apkDigestSha256);
}
示例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);
}