use of de.trustable.ca3s.core.domain.RDNAttribute in project ca3sCore by kuehne-trustable-de.
the class RDNAttributeResourceIT method createRDNAttribute.
@Test
@Transactional
public void createRDNAttribute() throws Exception {
int databaseSizeBeforeCreate = rDNAttributeRepository.findAll().size();
// Create the RDNAttribute
restRDNAttributeMockMvc.perform(post("/api/rdn-attributes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(rDNAttribute))).andExpect(status().isCreated());
// Validate the RDNAttribute in the database
List<RDNAttribute> rDNAttributeList = rDNAttributeRepository.findAll();
assertThat(rDNAttributeList).hasSize(databaseSizeBeforeCreate + 1);
RDNAttribute testRDNAttribute = rDNAttributeList.get(rDNAttributeList.size() - 1);
assertThat(testRDNAttribute.getAttributeType()).isEqualTo(DEFAULT_ATTRIBUTE_TYPE);
assertThat(testRDNAttribute.getAttributeValue()).isEqualTo(DEFAULT_ATTRIBUTE_VALUE);
}
use of de.trustable.ca3s.core.domain.RDNAttribute in project ca3sCore by kuehne-trustable-de.
the class CaCmpConnector method buildCertRequest.
/**
* @param certReqId
* @param csr
* @param hmacSecret
* @return PKIMessage
* @throws GeneralSecurityException
*/
public PKIMessage buildCertRequest(long certReqId, final CSR csr, final String hmacSecret) throws GeneralSecurityException {
// read the pem csr and verify the signature
PKCS10CertificationRequest p10Req;
try {
p10Req = cryptoUtil.parseCertificateRequest(csr.getCsrBase64()).getP10Req();
} catch (IOException e) {
LOGGER.error("parsing csr", e);
throw new GeneralSecurityException(e.getMessage());
}
List<RDN> rdnList = new ArrayList<>();
for (de.trustable.ca3s.core.domain.RDN rdnDao : csr.getRdns()) {
LOGGER.debug("rdnDao : " + rdnDao.getRdnAttributes());
List<AttributeTypeAndValue> attrTVList = new ArrayList<AttributeTypeAndValue>();
if (rdnDao != null && rdnDao.getRdnAttributes() != null) {
for (RDNAttribute rdnAttr : rdnDao.getRdnAttributes()) {
ASN1ObjectIdentifier aoi = new ASN1ObjectIdentifier(rdnAttr.getAttributeType());
ASN1Encodable ae = new DERUTF8String(rdnAttr.getAttributeValue());
AttributeTypeAndValue attrTV = new AttributeTypeAndValue(aoi, ae);
attrTVList.add(attrTV);
}
}
RDN rdn = new RDN(attrTVList.toArray(new AttributeTypeAndValue[attrTVList.size()]));
LOGGER.debug("rdn : " + rdn.size() + " elements");
rdnList.add(rdn);
}
X500Name subjectDN = new X500Name(rdnList.toArray(new RDN[rdnList.size()]));
LOGGER.debug("subjectDN : " + subjectDN);
Collection<Extension> certExtList = new ArrayList<>();
// copy CSR attributes to Extension list
for (Attribute attribute : p10Req.getAttributes()) {
for (ASN1Encodable asn1Encodable : attribute.getAttributeValues()) {
if (asn1Encodable != null) {
try {
Extensions extensions = Extensions.getInstance(asn1Encodable);
for (ASN1ObjectIdentifier oid : extensions.getExtensionOIDs()) {
LOGGER.debug("copying oid '" + oid.toString() + "' from csr to PKIMessage");
certExtList.add(extensions.getExtension(oid));
}
} catch (IllegalArgumentException iae) {
LOGGER.debug("processing asn1 value '" + asn1Encodable + "' caused exception", iae);
}
}
}
}
final SubjectPublicKeyInfo keyInfo = p10Req.getSubjectPublicKeyInfo();
return cryptoUtil.buildCertRequest(certReqId, subjectDN, certExtList, keyInfo, hmacSecret);
}
use of de.trustable.ca3s.core.domain.RDNAttribute in project ca3sCore by kuehne-trustable-de.
the class RDNAttributeResourceIT method updateRDNAttribute.
@Test
@Transactional
public void updateRDNAttribute() throws Exception {
// Initialize the database
rDNAttributeService.save(rDNAttribute);
int databaseSizeBeforeUpdate = rDNAttributeRepository.findAll().size();
// Update the rDNAttribute
RDNAttribute updatedRDNAttribute = rDNAttributeRepository.findById(rDNAttribute.getId()).get();
// Disconnect from session so that the updates on updatedRDNAttribute are not directly saved in db
em.detach(updatedRDNAttribute);
updatedRDNAttribute.attributeType(UPDATED_ATTRIBUTE_TYPE).attributeValue(UPDATED_ATTRIBUTE_VALUE);
restRDNAttributeMockMvc.perform(put("/api/rdn-attributes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedRDNAttribute))).andExpect(status().isOk());
// Validate the RDNAttribute in the database
List<RDNAttribute> rDNAttributeList = rDNAttributeRepository.findAll();
assertThat(rDNAttributeList).hasSize(databaseSizeBeforeUpdate);
RDNAttribute testRDNAttribute = rDNAttributeList.get(rDNAttributeList.size() - 1);
assertThat(testRDNAttribute.getAttributeType()).isEqualTo(UPDATED_ATTRIBUTE_TYPE);
assertThat(testRDNAttribute.getAttributeValue()).isEqualTo(UPDATED_ATTRIBUTE_VALUE);
}
use of de.trustable.ca3s.core.domain.RDNAttribute in project ca3sCore by kuehne-trustable-de.
the class RDNAttributeResource method createRDNAttribute.
/**
* {@code POST /rdn-attributes} : Create a new rDNAttribute.
*
* @param rDNAttribute the rDNAttribute to create.
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new rDNAttribute, or with status {@code 400 (Bad Request)} if the rDNAttribute has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@PostMapping("/rdn-attributes")
public ResponseEntity<RDNAttribute> createRDNAttribute(@Valid @RequestBody RDNAttribute rDNAttribute) throws URISyntaxException {
log.debug("REST request to save RDNAttribute : {}", rDNAttribute);
if (rDNAttribute.getId() != null) {
throw new BadRequestAlertException("A new rDNAttribute cannot already have an ID", ENTITY_NAME, "idexists");
}
RDNAttribute result = rDNAttributeService.save(rDNAttribute);
return ResponseEntity.created(new URI("/api/rdn-attributes/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())).body(result);
}
use of de.trustable.ca3s.core.domain.RDNAttribute in project ca3sCore by kuehne-trustable-de.
the class RDNAttributeResource method updateRDNAttribute.
/**
* {@code PUT /rdn-attributes} : Updates an existing rDNAttribute.
*
* @param rDNAttribute the rDNAttribute to update.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated rDNAttribute,
* or with status {@code 400 (Bad Request)} if the rDNAttribute is not valid,
* or with status {@code 500 (Internal Server Error)} if the rDNAttribute couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@PutMapping("/rdn-attributes")
public ResponseEntity<RDNAttribute> updateRDNAttribute(@Valid @RequestBody RDNAttribute rDNAttribute) throws URISyntaxException {
log.debug("REST request to update RDNAttribute : {}", rDNAttribute);
if (rDNAttribute.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
RDNAttribute result = rDNAttributeService.save(rDNAttribute);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, rDNAttribute.getId().toString())).body(result);
}
Aggregations