本文整理汇总了Java中android.security.KeyChain.getCertificateChain方法的典型用法代码示例。如果您正苦于以下问题:Java KeyChain.getCertificateChain方法的具体用法?Java KeyChain.getCertificateChain怎么用?Java KeyChain.getCertificateChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.security.KeyChain
的用法示例。
在下文中一共展示了KeyChain.getCertificateChain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchCertificateChain
import android.security.KeyChain; //导入方法依赖的package包/类
private X509Certificate[] fetchCertificateChain(Context context, String alias)
throws KeyChainException, InterruptedException, MessagingException {
X509Certificate[] chain = KeyChain.getCertificateChain(context, alias);
if (chain == null || chain.length == 0) {
throw new MessagingException("No certificate chain found for: " + alias);
}
try {
for (X509Certificate certificate : chain) {
certificate.checkValidity();
}
} catch (CertificateException e) {
throw new CertificateValidationException(e.getMessage(), Reason.Expired, alias);
}
return chain;
}
示例2: fetchCertificateChain
import android.security.KeyChain; //导入方法依赖的package包/类
private X509Certificate[] fetchCertificateChain(Context context, String alias)
throws KeyChainException, InterruptedException, MessagingException {
X509Certificate[] chain = KeyChain.getCertificateChain(context, alias);
if (chain == null || chain.length == 0) {
throw new MessagingException("No certificate chain found for: " + alias);
}
try {
for (X509Certificate certificate : chain) {
certificate.checkValidity();
}
} catch (CertificateException e) {
// Client certificate has expired or is not yet valid
throw new CertificateValidationException(context.getString(R.string.client_certificate_expired, alias, e.toString()));
}
return chain;
}
示例3: getCertificateChain
import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public X509Certificate[] getCertificateChain(String alias) {
Log.d(Config.LOGTAG, "getting certificate chain");
try {
return KeyChain.getCertificateChain(mXmppConnectionService, alias);
} catch (Exception e) {
Log.d(Config.LOGTAG, e.getMessage());
return new X509Certificate[0];
}
}
示例4: getCertificateChain
import android.security.KeyChain; //导入方法依赖的package包/类
@Override
public X509Certificate[] getCertificateChain(String alias) {
Log.d(Config.LOGTAG, "getting certificate chain");
try {
return KeyChain.getCertificateChain(mXmppConnectionService, alias);
} catch (Exception e) {
Log.d(Config.LOGTAG, e.getMessage());
return new X509Certificate[0];
}
}
示例5: signWithAlias
import android.security.KeyChain; //导入方法依赖的package包/类
public void signWithAlias(final String path,
final String alias,
final String name,
final String location,
final String reason,
byte[] imageData,
int page,
float x,
float y,
float width,
float height) throws IOException, InterruptedException, KeyChainException
{
byte[] buffer = new byte[BUFFER_SIZE];
this.callbackContext = callbackContext;
privKey = KeyChain.getPrivateKey(context, alias);
Certificate[] chain = KeyChain.getCertificateChain(context, alias);
File document = new File(path);
if (!(document != null && document.exists()))
new RuntimeException("");
Signature signature = new Signature(chain, privKey);
File outputPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
outputPath.mkdirs();
if (imageData.length > 0) {
ByteArrayInputStream image = new ByteArrayInputStream(imageData);
signature.setVisual(image, page, x, y, width, height);
System.err.println("page " + page + ":" + x + "," + y + " " + width + "x" + height);
}
signature.sign(path, outputPath.getAbsolutePath(), name, location, reason);
File outputDocument = new File(outputPath.getAbsolutePath() + "/" + document.getName() + ".signed.pdf");
File resultDocument = new File(path);
File removeDocument = new File(document.getPath() + ".unsigned.pdf");
document.renameTo(removeDocument);
outputDocument.renameTo(resultDocument);
return;
}