Search in sources :

Example 6 with CertificateCredentialVersionData

use of org.cloudfoundry.credhub.entity.CertificateCredentialVersionData in project credhub by cloudfoundry-incubator.

the class CredentialRotationTest method rotate_givenCertificateCredential_reEncryptsWithActiveKey.

@Test
public void rotate_givenCertificateCredential_reEncryptsWithActiveKey() {
    CertificateCredentialVersionData certificateCredentialData = new CertificateCredentialVersionData("some-name");
    CertificateCredentialVersion credential = new CertificateCredentialVersion(certificateCredentialData);
    assertRotation(credential, certificateCredentialData);
}
Also used : CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData) Test(org.junit.Test)

Example 7 with CertificateCredentialVersionData

use of org.cloudfoundry.credhub.entity.CertificateCredentialVersionData in project credhub by cloudfoundry-incubator.

the class EncryptionKeyRotatorTest method createCertificateWithOldKey.

private void createCertificateWithOldKey(Key oldKey) throws Exception {
    final EncryptedValue encryption = encryptionService.encrypt(oldCanary.getUuid(), oldKey, "old-certificate-private-key");
    CertificateCredentialVersionData certificateCredentialData1 = new CertificateCredentialVersionData("/old-key");
    certificateCredentialData1.setEncryptedValueData(encryption);
    credentialVersionWithOldKey = new CertificateCredentialVersion(certificateCredentialData1);
    credentialVersionDataService.save(credentialVersionWithOldKey);
}
Also used : CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue) CertificateCredentialVersion(org.cloudfoundry.credhub.domain.CertificateCredentialVersion)

Example 8 with CertificateCredentialVersionData

use of org.cloudfoundry.credhub.entity.CertificateCredentialVersionData in project credhub by cloudfoundry-incubator.

the class CertificateVersionDataService method unsetTransitionalVerison.

public void unsetTransitionalVerison(UUID certificateUuid) {
    CertificateCredentialVersionData transitionalCertificate = (CertificateCredentialVersionData) credentialVersionRepository.findTransitionalCertificateVersion(certificateUuid);
    if (transitionalCertificate != null) {
        transitionalCertificate.setTransitional(false);
        credentialVersionRepository.save(transitionalCertificate);
    }
}
Also used : CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData)

Example 9 with CertificateCredentialVersionData

use of org.cloudfoundry.credhub.entity.CertificateCredentialVersionData in project credhub by cloudfoundry-incubator.

the class CredentialVersionDataServiceTest method setupTestFixturesForFindContainingName.

private void setupTestFixturesForFindContainingName(String valueName, String passwordName, String certificateName) {
    fakeTimeSetter.accept(2000000000123L);
    valueCredentialData = new ValueCredentialVersionData(valueName);
    valueCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue("value".getBytes()).setNonce(new byte[] {}));
    ValueCredentialVersion namedValueCredential = new ValueCredentialVersion(valueCredentialData);
    namedValueCredential.setEncryptor(encryptor);
    subject.save(namedValueCredential);
    PasswordCredentialVersionData passwordCredentialData = new PasswordCredentialVersionData("/mySe.cret");
    passwordCredentialData.setEncryptedValueData(new EncryptedValue(activeCanaryUuid, "", ""));
    new PasswordCredentialVersion(passwordCredentialData);
    PasswordCredentialVersion namedPasswordCredential;
    subject.save(namedValueCredential);
    fakeTimeSetter.accept(1000000000123L);
    passwordCredentialData = new PasswordCredentialVersionData(passwordName);
    passwordCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue("password".getBytes()).setNonce(new byte[] {}));
    namedPasswordCredential = new PasswordCredentialVersion(passwordCredentialData);
    subject.save(namedPasswordCredential);
    CertificateCredentialVersionData certificateCredentialData = new CertificateCredentialVersionData("/myseecret");
    CertificateCredentialVersion certificateCredential = new CertificateCredentialVersion(certificateCredentialData);
    subject.save(certificateCredential);
    fakeTimeSetter.accept(3000000000123L);
    certificateCredentialData = new CertificateCredentialVersionData(certificateName);
    certificateCredential = new CertificateCredentialVersion(certificateCredentialData);
    subject.save(certificateCredential);
}
Also used : ValueCredentialVersion(org.cloudfoundry.credhub.domain.ValueCredentialVersion) CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData) PasswordCredentialVersionData(org.cloudfoundry.credhub.entity.PasswordCredentialVersionData) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) CertificateCredentialVersion(org.cloudfoundry.credhub.domain.CertificateCredentialVersion)

Example 10 with CertificateCredentialVersionData

use of org.cloudfoundry.credhub.entity.CertificateCredentialVersionData in project credhub by cloudfoundry-incubator.

the class CredentialVersionDataServiceTest method saveCertificate.

private CertificateCredentialVersion saveCertificate(long timeMillis, String name, String caName, UUID canaryUuid, boolean transitional) {
    fakeTimeSetter.accept(timeMillis);
    Credential credential = credentialDataService.find(name);
    if (credential == null) {
        credential = credentialDataService.save(new Credential(name));
    }
    CertificateCredentialVersionData credentialObject = new CertificateCredentialVersionData();
    credentialObject.setCredential(credential);
    credentialObject.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(canaryUuid).setEncryptedValue(new byte[] {}).setNonce(new byte[] {}));
    if (caName != null) {
        credentialObject.setCaName(caName);
    }
    credentialObject.setTransitional(transitional);
    return subject.save(credentialObject);
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue)

Aggregations

CertificateCredentialVersionData (org.cloudfoundry.credhub.entity.CertificateCredentialVersionData)11 EncryptedValue (org.cloudfoundry.credhub.entity.EncryptedValue)5 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)4 Test (org.junit.Test)4 Credential (org.cloudfoundry.credhub.entity.Credential)3 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)2 ValueCredentialVersion (org.cloudfoundry.credhub.domain.ValueCredentialVersion)2 PasswordCredentialVersionData (org.cloudfoundry.credhub.entity.PasswordCredentialVersionData)2 ValueCredentialVersionData (org.cloudfoundry.credhub.entity.ValueCredentialVersionData)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Before (org.junit.Before)1 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)1 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)1