Search in sources :

Example 1 with LdapNotFoundException

use of eu.cryptoeuro.accountmapper.error.LdapNotFoundException in project account-identity by cryptofiat.

the class LdapController method checkIdCode.

@RequestMapping(method = RequestMethod.GET, value = "/{idCode}")
public ResponseEntity<LdapResponse> checkIdCode(@PathVariable("idCode") long idCode) {
    LdapResponse lr = ldapService.lookupIdCode(idCode);
    // should check if didn't return, then respond with 404
    if (lr != null && lr.getIdCode() > 0) {
        HttpHeaders headers = new HttpHeaders();
        headers.setCacheControl("max-age=3600");
        return new ResponseEntity<LdapResponse>(lr, headers, HttpStatus.OK);
    } else {
        throw new LdapNotFoundException();
    }
}
Also used : LdapResponse(eu.cryptoeuro.accountmapper.response.LdapResponse) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) LdapNotFoundException(eu.cryptoeuro.accountmapper.error.LdapNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with LdapNotFoundException

use of eu.cryptoeuro.accountmapper.error.LdapNotFoundException in project account-identity by cryptofiat.

the class EscrowController method getEscrow.

@RequestMapping(method = RequestMethod.GET, value = "/{idCode}")
public ResponseEntity<AccountActivationResponse> getEscrow(@PathVariable("idCode") @Valid long idCode) throws IOException {
    if (accountService.hasActivatedAccount(idCode)) {
        throw new HasActiveAccountException();
    }
    ;
    if (ldapService.lookupIdCode(idCode) == null) {
        throw new LdapNotFoundException();
    }
    ;
    EthereumAccount account;
    account = escrowService.approveEscrowAccountForId(idCode);
    AccountActivationResponse aaResponse = AccountActivationResponse.builder().authenticationStatus(AuthenticationStatus.LOGIN_SUCCESS.name()).ownerId(account.getOwnerId()).address(account.getAddress()).transactionHash(account.getTransactionHash()).build();
    return new ResponseEntity<AccountActivationResponse>(aaResponse, HttpStatus.OK);
}
Also used : HasActiveAccountException(eu.cryptoeuro.accountmapper.error.HasActiveAccountException) ResponseEntity(org.springframework.http.ResponseEntity) LdapNotFoundException(eu.cryptoeuro.accountmapper.error.LdapNotFoundException) AccountActivationResponse(eu.cryptoeuro.accountmapper.response.AccountActivationResponse) EthereumAccount(eu.cryptoeuro.accountmapper.domain.EthereumAccount) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LdapNotFoundException (eu.cryptoeuro.accountmapper.error.LdapNotFoundException)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 EthereumAccount (eu.cryptoeuro.accountmapper.domain.EthereumAccount)1 HasActiveAccountException (eu.cryptoeuro.accountmapper.error.HasActiveAccountException)1 AccountActivationResponse (eu.cryptoeuro.accountmapper.response.AccountActivationResponse)1 LdapResponse (eu.cryptoeuro.accountmapper.response.LdapResponse)1 HttpHeaders (org.springframework.http.HttpHeaders)1