use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509CertificateWikiStoreTest method mockSingleCertQuery.
private CertifiedPublicKey mockSingleCertQuery() throws Exception {
CertifiedPublicKey certificate = getMockedCertificate(true);
CertificateFactory factory = mocker.getInstance(CertificateFactory.class, "X509");
when(factory.decode(CERTIFICATE)).thenReturn(certificate);
when(query.<String>execute()).thenReturn(Collections.singletonList(ENCODED_CERTIFICATE));
return certificate;
}
use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509KeyWikiStoreTest method retrievePrivateKeyFromDocument.
@Test
public void retrievePrivateKeyFromDocument() throws Exception {
XWikiDocument storeDoc = mock(XWikiDocument.class);
when(xwiki.getDocument(new DocumentReference(WIKI, SPACE, DOCUMENT), xcontext)).thenReturn(storeDoc);
BaseObject certObj = mock(BaseObject.class);
when(storeDoc.getXObject(X509CertificateWikiStore.CERTIFICATECLASS)).thenReturn(certObj);
when(certObj.getLargeStringValue(X509CertificateWikiStore.CERTIFICATECLASS_PROP_CERTIFICATE)).thenReturn(ENCODED_CERTIFICATE);
BaseObject pkObj = mock(BaseObject.class);
when(storeDoc.getXObject(X509KeyWikiStore.PRIVATEKEYCLASS)).thenReturn(pkObj);
when(pkObj.getLargeStringValue(X509KeyWikiStore.PRIVATEKEYCLASS_PROP_KEY)).thenReturn(ENCODED_PRIVATEKEY);
CertifiedKeyPair keyPair = store.retrieve(DOC_STORE_REF);
assertThat(keyPair, notNullValue());
assertThat(keyPair.getPrivateKey(), equalTo(privateKey));
assertThat(keyPair.getCertificate(), equalTo((CertifiedPublicKey) certificate));
}
Aggregations