use of de.trustable.ca3s.core.domain.AcmeAuthorization in project ca3sCore by kuehne-trustable-de.
the class AuthorizationController method getAuthorization.
@RequestMapping(value = "/{authorizationId}", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAuthorization(@PathVariable final long authorizationId) {
LOG.info("Received Authorization request 'get' ");
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
LOG.debug("header {} : {} ", key, value);
}
final HttpHeaders additionalHeaders = buildNonceHeader();
if (rejectGet) {
return ResponseEntity.status(HttpStatus.METHOD_NOT_ALLOWED).headers(additionalHeaders).build();
}
List<AcmeAuthorization> authList = authorizationRepository.findByAcmeAuthorizationId(authorizationId);
if (authList.isEmpty()) {
return ResponseEntity.notFound().headers(additionalHeaders).build();
} else {
AcmeAuthorization authDao = authList.get(0);
// No authentication and check against an account!!!
AuthorizationResponse authResp = buildAuthResponse(authDao);
return ResponseEntity.ok().headers(additionalHeaders).body(authResp);
}
}
use of de.trustable.ca3s.core.domain.AcmeAuthorization in project ca3sCore by kuehne-trustable-de.
the class ChallengeController method alignOrderState.
void alignOrderState(AcmeOrder orderDao) {
if (orderDao.getStatus().equals(AcmeOrderStatus.READY)) {
LOG.info("order status already '{}', no re-check after challenge state change required", orderDao.getStatus());
return;
}
if (orderDao.getStatus() != AcmeOrderStatus.PENDING) {
LOG.warn("unexpected order status '{}' (!= Pending), no re-check after challenge state change required", orderDao.getStatus());
return;
}
boolean orderReady = true;
/*
* check all authorizations having at least one successfully validated challenge
*/
for (AcmeAuthorization authDao : orderDao.getAcmeAuthorizations()) {
boolean authReady = false;
for (AcmeChallenge challDao : authDao.getChallenges()) {
if (challDao.getStatus() == ChallengeStatus.VALID) {
LOG.debug("challenge {} of type {} is valid ", challDao.getChallengeId(), challDao.getType());
authReady = true;
break;
}
}
if (authReady) {
LOG.debug("found valid challenge, authorization id {} is valid ", authDao.getAcmeAuthorizationId());
} else {
LOG.debug("no valid challange, authorization id {} and order {} fails ", authDao.getAcmeAuthorizationId(), orderDao.getOrderId());
orderReady = false;
break;
}
}
if (orderReady) {
LOG.debug("order status set to READY");
orderDao.setStatus(AcmeOrderStatus.READY);
orderRepository.save(orderDao);
}
}
use of de.trustable.ca3s.core.domain.AcmeAuthorization in project ca3sCore by kuehne-trustable-de.
the class ACMEOrderUtil method challengeListfrom.
public List<ACMEChallengeView> challengeListfrom(AcmeOrder acmeOrder) {
List<ACMEChallengeView> acmeChallengeViewList = new ArrayList<>();
for (AcmeAuthorization acmeAuthorization : acmeOrder.getAcmeAuthorizations()) {
for (AcmeChallenge acmeChallenge : acmeAuthorization.getChallenges()) {
ACMEChallengeView acmeChallengeView = getAcmeChallengeView(acmeAuthorization, acmeChallenge);
acmeChallengeViewList.add(acmeChallengeView);
}
}
return acmeChallengeViewList;
}
use of de.trustable.ca3s.core.domain.AcmeAuthorization in project ca3sCore by kuehne-trustable-de.
the class AcmeAuthorizationResourceIT method updateAcmeAuthorization.
@Test
@Transactional
public void updateAcmeAuthorization() throws Exception {
// Initialize the database
acmeAuthorizationService.save(acmeAuthorization);
int databaseSizeBeforeUpdate = acmeAuthorizationRepository.findAll().size();
// Update the acmeAuthorization
AcmeAuthorization updatedAcmeAuthorization = acmeAuthorizationRepository.findById(acmeAuthorization.getId()).get();
// Disconnect from session so that the updates on updatedAcmeAuthorization are not directly saved in db
em.detach(updatedAcmeAuthorization);
updatedAcmeAuthorization.acmeAuthorizationId(UPDATED_ACME_AUTHORIZATION_ID).type(UPDATED_TYPE).value(UPDATED_VALUE);
restAcmeAuthorizationMockMvc.perform(put("/api/acme-authorizations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedAcmeAuthorization))).andExpect(status().isOk());
// Validate the AcmeAuthorization in the database
List<AcmeAuthorization> acmeAuthorizationList = acmeAuthorizationRepository.findAll();
assertThat(acmeAuthorizationList).hasSize(databaseSizeBeforeUpdate);
AcmeAuthorization testAcmeAuthorization = acmeAuthorizationList.get(acmeAuthorizationList.size() - 1);
assertThat(testAcmeAuthorization.getAcmeAuthorizationId()).isEqualTo(UPDATED_ACME_AUTHORIZATION_ID);
assertThat(testAcmeAuthorization.getType()).isEqualTo(UPDATED_TYPE);
assertThat(testAcmeAuthorization.getValue()).isEqualTo(UPDATED_VALUE);
}
use of de.trustable.ca3s.core.domain.AcmeAuthorization in project ca3sCore by kuehne-trustable-de.
the class AcmeAuthorizationResourceIT method createAcmeAuthorization.
@Test
@Transactional
public void createAcmeAuthorization() throws Exception {
int databaseSizeBeforeCreate = acmeAuthorizationRepository.findAll().size();
// Create the AcmeAuthorization
restAcmeAuthorizationMockMvc.perform(post("/api/acme-authorizations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(acmeAuthorization))).andExpect(status().isCreated());
// Validate the AcmeAuthorization in the database
List<AcmeAuthorization> acmeAuthorizationList = acmeAuthorizationRepository.findAll();
assertThat(acmeAuthorizationList).hasSize(databaseSizeBeforeCreate + 1);
AcmeAuthorization testAcmeAuthorization = acmeAuthorizationList.get(acmeAuthorizationList.size() - 1);
assertThat(testAcmeAuthorization.getAcmeAuthorizationId()).isEqualTo(DEFAULT_ACME_AUTHORIZATION_ID);
assertThat(testAcmeAuthorization.getType()).isEqualTo(DEFAULT_TYPE);
assertThat(testAcmeAuthorization.getValue()).isEqualTo(DEFAULT_VALUE);
}
Aggregations