@Test @WithMockUser(authorities = { "RESTORE_CONFIGURATION" }) public void restoreFromBackupWithLoggedOutTokens() { when(tokenService.hasHardwareTokens()).thenReturn(true); ResponseEntity<TokensLoggedOut> response = backupsApiController .restoreBackup(BACKUP_FILE_1_NAME); assertEquals(HttpStatus.OK, response.getStatusCode()); TokensLoggedOut tokensLoggedOut = response.getBody(); assertTrue(tokensLoggedOut.getHsmTokensLoggedOut()); }
@Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) { boolean hasHardwareTokens = tokenService.hasHardwareTokens(); TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens); try { restoreService.restoreFromBackup(filename); } catch (BackupFileNotFoundException e) { throw new BadRequestException(e); } catch (InterruptedException e) { throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED)); } catch (RestoreProcessFailedException e) { throw new InternalServerErrorException(e); } return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK); }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) { boolean hasHardwareTokens = tokenService.hasHardwareTokens(); TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens); try { restoreService.restoreFromBackup(filename); } catch (BackupFileNotFoundException e) { throw new BadRequestException(e); } catch (InterruptedException e) { throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED)); } catch (RestoreProcessFailedException e) { throw new InternalServerErrorException(e); } return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK); } }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) { boolean hasHardwareTokens = tokenService.hasHardwareTokens(); TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens); try { restoreService.restoreFromBackup(filename); } catch (BackupFileNotFoundException e) { throw new BadRequestException(e); } catch (InterruptedException e) { throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED)); } catch (RestoreProcessFailedException e) { throw new InternalServerErrorException(e); } return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK); } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) { boolean hasHardwareTokens = tokenService.hasHardwareTokens(); TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens); try { restoreService.restoreFromBackup(filename); } catch (BackupFileNotFoundException e) { throw new BadRequestException(e); } catch (InterruptedException e) { throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED)); } catch (RestoreProcessFailedException e) { throw new InternalServerErrorException(e); } return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK); } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<List<Backup>> getBackups(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = DELETE_BACKUP) ResponseEntity<Void> deleteBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<Resource> downloadBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = BACKUP) ResponseEntity<Backup> addBackup(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file); @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename); }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) { boolean hasHardwareTokens = tokenService.hasHardwareTokens(); TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens); try { restoreService.restoreFromBackup(filename); } catch (BackupFileNotFoundException e) { throw new BadRequestException(e); } catch (InterruptedException e) { throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED)); } catch (RestoreProcessFailedException e) { throw new InternalServerErrorException(e); } return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK); } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<List<Backup>> getBackups(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = DELETE_BACKUP) ResponseEntity<Void> deleteBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<Resource> downloadBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = BACKUP) ResponseEntity<Backup> addBackup(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file); @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename); static final String GENERATE_BACKUP_INTERRUPTED; static final String RESTORE_INTERRUPTED; }