我是Android新手,需要您的帮助。
我需要在Android设备上安装.pkcs12证书的位置,并需要从中获取私钥。
我有android设备(5.0),并且安装了.pkcs12证书后,它就会在“受信任的凭据”中“用户”标签下的“用户证书”标签中列出。
我尝试了以下代码。
Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery
.shop(shopQuery -> shopQuery
.collections(arg -> arg.first(10), collectionConnectionQuery -> collectionConnectionQuery
.edges(collectionEdgeQuery -> collectionEdgeQuery
.node(collectionQuery -> collectionQuery
.title()
.products(arg -> arg.first(10), productConnectionQuery -> productConnectionQuery
.edges(productEdgeQuery -> productEdgeQuery
.node(productQuery -> productQuery
.title()
.productType()
.description()
)
)
)
)
)
)
)
);
@Override
public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {
List<Storefront.Collection> collections = new ArrayList<>();
for (Storefront.CollectionEdge collectionEdge : response.data().getShop().getCollections().getEdges())
{
collections.add(collectionEdge.getNode());
for (Storefront.ProductEdge productEdge : collectionEdge.getNode().getProducts().getEdges())
{
products.add(productEdge.getNode());
}
for (int i = 0; i < products.size(); i++)
{
Log.i("PRODUCTS", String.valueOf(products.get(i).getId().toString()));
}
}
getActivity().runOnUiThread(new Runnable()
{
@Override
public void run()
{
product_recyclreview.setVisibility(View.VISIBLE);
shimmer.setVisibility(View.GONE);
productAdapter = new ProductAdapter(getActivity(), products);
product_recyclreview.setAdapter(productAdapter);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
{
@Override
public void onRefresh()
{
Refresh();
mSwipeRefreshLayout.setRefreshing(false);
}
});
}
});
}
@Override
public void onFailure(@NonNull GraphError error) {
}
});
Storefront.QueryRootQuery querySEC = null;
querySEC = Storefront.query(rootQuery -> rootQuery
.node(new ID(products.get(0).getId().toString()), nodeQuery -> nodeQuery
.onProduct(productQuery -> productQuery
.title()
.description()
.images(arg -> arg.first(10), imageConnectionQuery -> imageConnectionQuery
.edges(imageEdgeQuery -> imageEdgeQuery
.node(imageQuery -> imageQuery
.src()
)
)
)
.variants(arg -> arg.first(10), variantConnectionQuery -> variantConnectionQuery
.edges(variantEdgeQuery -> variantEdgeQuery
.node(productVariantQuery -> productVariantQuery
.price()
.title()
.available()
)
)
)
)
)
);
graphClientsec.queryGraph(querySEC).enqueue(new GraphCall.Callback<Storefront.QueryRoot>()
{
@Override
public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response)
{
Storefront.Product product = (Storefront.Product) response.data().getNode();
List<Storefront.Image> productImages = new ArrayList<>();
for (final Storefront.ImageEdge imageEdge : product.getImages().getEdges())
{
productImages.add(imageEdge.getNode());
}
List<Storefront.ProductVariant> productVariants = new ArrayList<>();
for (final Storefront.ProductVariantEdge productVariantEdge : product.getVariants().getEdges()) {
productVariants.add(productVariantEdge.getNode());
}
getActivity().runOnUiThread(new Runnable()
{
@Override
public void run()
{
Drawable mDefaultFailed = getResources().getDrawable(R.drawable.notfound);
for (int i = 0; i < productImages.size(); i++)
{
// String price= String.valueOf(productVariants.get(finalI).getPrice());
if (productImages.get(i).getSrc().isEmpty())
{
Glide.with(getActivity())
.load(productImages.get(i).getSrc())
.into((ImageView) getActivity().findViewById(R.id.img_prdimg)).
onLoadFailed(null, mDefaultFailed);
}
else
{
Glide.with(getActivity())
.load(productImages.get(i).getSrc()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable
resource, String model, Target<GlideDrawable> target,
boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
})
.into((ImageView) getActivity().findViewById(R.id.img_prdimg));
}
}
}
});
}
@Override
public void onFailure(@NonNull GraphError error) {
}
});
我正在获取一些如下所示的密钥 RSA专用CRT密钥
模量: c4e30867519fb567dc5298c7afa90abab037d519244a539ef542d33e054175c349e7fc5a5bf7f3437a5710621011ea4ae5cdcf2798246bbabd1211dce489d68d1c6d5c1da3bd6b7a20cd55a0779db0ba3e0ffdcf5110a955c4a3edfc189415706841411d75e209d210d4df4b3902bad5e3ff45cbcb6405736fe136a017ddfc95
公共指数: 10001
私人指数: 2133d83af43ce6aeb92d04aec824cdb665f9446a950023d1eeb2724547459ec26c383f0a4df02689fe9ba81ba17223fcb57c5baee5ad5ead832d04ee276c474e00f5b25849624351fe99e35a7b257ea41a5b030cc08c35c739ac65a8698600301d0490eac38646474cc3b0e8dc0dcc0663448d97cd055cbc8769b8d212384e01}
所以我不确定这是否是私钥,并且还需要生成X509Certificate2对象并为其分配PrivateKey属性。