use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509KeyWikiStoreTest method retrieveEncryptedPrivateKeyFromDocument.
@Test
public void retrieveEncryptedPrivateKeyFromDocument() 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_ENCRYPTED_PRIVATEKEY);
CertifiedKeyPair keyPair = store.retrieve(DOC_STORE_REF, PASSWORD);
assertThat(keyPair, notNullValue());
assertThat(keyPair.getPrivateKey(), equalTo(privateKey));
assertThat(keyPair.getCertificate(), equalTo((CertifiedPublicKey) certificate));
}
use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509KeyWikiStoreTest method retrieveEncryptedPrivateKeyFromSpace.
@Test
public void retrieveEncryptedPrivateKeyFromSpace() throws Exception {
XWikiDocument storeDoc = mock(XWikiDocument.class);
when(xwiki.getDocument(new DocumentReference(WIKI, SPACE, ENCODED_SUBJECTKEYID), xcontext)).thenReturn(storeDoc);
BaseObject pkObj = mock(BaseObject.class);
when(storeDoc.getXObject(X509KeyWikiStore.PRIVATEKEYCLASS)).thenReturn(pkObj);
when(pkObj.getLargeStringValue(X509KeyWikiStore.PRIVATEKEYCLASS_PROP_KEY)).thenReturn(ENCODED_ENCRYPTED_PRIVATEKEY);
when(query.<Object[]>execute()).thenReturn(Collections.singletonList(new Object[] { "space." + ENCODED_SUBJECTKEYID, 0 }));
CertifiedKeyPair keyPair = store.retrieve(SPACE_STORE_REF, certificate, PASSWORD);
assertThat(keyPair, notNullValue());
assertThat(keyPair.getPrivateKey(), equalTo(privateKey));
assertThat(keyPair.getCertificate(), equalTo((CertifiedPublicKey) certificate));
}
use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509KeyWikiStoreTest method retrievePrivateKeyFromSpace.
@Test
public void retrievePrivateKeyFromSpace() throws Exception {
XWikiDocument storeDoc = mock(XWikiDocument.class);
when(xwiki.getDocument(new DocumentReference(WIKI, SPACE, ENCODED_SUBJECTKEYID), xcontext)).thenReturn(storeDoc);
BaseObject pkObj = mock(BaseObject.class);
when(storeDoc.getXObject(X509KeyWikiStore.PRIVATEKEYCLASS)).thenReturn(pkObj);
when(pkObj.getLargeStringValue(X509KeyWikiStore.PRIVATEKEYCLASS_PROP_KEY)).thenReturn(ENCODED_PRIVATEKEY);
when(query.<Object[]>execute()).thenReturn(Collections.singletonList(new Object[] { "space." + ENCODED_SUBJECTKEYID, 0 }));
CertifiedKeyPair keyPair = store.retrieve(SPACE_STORE_REF, certificate);
assertThat(keyPair, notNullValue());
assertThat(keyPair.getPrivateKey(), equalTo(privateKey));
assertThat(keyPair.getCertificate(), equalTo((CertifiedPublicKey) certificate));
}
use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509CertificateWikiStoreTest method testRetrievingCertificateUsingKeyIdFromSpace.
@Test
public void testRetrievingCertificateUsingKeyIdFromSpace() throws Exception {
CertifiedPublicKey certificate = mockSingleCertQuery();
assertThat(this.store.getCertificateProvider(SPACE_STORE_REF).getCertificate(SUBJECT_KEYID), equalTo(certificate));
verify(this.query).bindValue(BIND_KEYID, ENCODED_SUBJECTKEYID);
verify(this.query, times(3)).bindValue(BIND_STORE, SPACE);
}
use of org.xwiki.crypto.pkix.params.CertifiedPublicKey in project xwiki-platform by xwiki.
the class X509CertificateWikiStoreTest method testRetrievingCertificateUsingKeyIdFromDocument.
@Test
public void testRetrievingCertificateUsingKeyIdFromDocument() throws Exception {
CertifiedPublicKey certificate = mockSingleCertQuery();
assertThat(this.store.getCertificateProvider(DOC_STORE_REF).getCertificate(SUBJECT_KEYID), equalTo(certificate));
verify(this.query).bindValue(BIND_KEYID, ENCODED_SUBJECTKEYID);
verify(this.query, times(3)).bindValue(BIND_STORE, FULLNAME);
}
Aggregations