@Test public void testExtractInformationFromTimestamp() throws Exception { final InputStream tokenFile = PropertiesUtils.getResourceAsStream("token.tsp"); String encodedTimeStampToken = IOUtils.toString(tokenFile, "UTF-8"); final JsonNode timeStampInfo = userInterfaceTransactionManager.extractInformationFromTimestamp(encodedTimeStampToken); assertTrue(!timeStampInfo.isNull()); assertTrue("2017-05-26T17:25:26".equals(timeStampInfo.get("genTime").asText())); assertTrue( "C=FR,ST=idf,L=paris,O=Vitam.,CN=CA_timestamping".equals(timeStampInfo.get("signerCertIssuer").asText())); try { userInterfaceTransactionManager.extractInformationFromTimestamp("FakeTimeStamp"); fail("Should raized an exception"); } catch (BadRequestException e) { } }
public JsonNode extractInformationFromTimestamp(String timestamp) throws BadRequestException { final ObjectNode result = JsonHandler.createObjectNode(); try { ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream( org.bouncycastle.util.encoders.Base64.decode(timestamp.getBytes()))); ASN1Primitive obj = bIn.readObject(); TimeStampResponse tsResp = new TimeStampResponse(obj.toASN1Primitive().getEncoded()); SignerId signerId = tsResp.getTimeStampToken().getSID(); X500Name signerCertIssuer = signerId.getIssuer(); result.put("genTime", LocalDateUtil.getString( LocalDateUtil.fromDate(tsResp.getTimeStampToken().getTimeStampInfo().getGenTime()))); result.put("signerCertIssuer", signerCertIssuer.toString()); } catch (TSPException | IOException | DecoderException e) { LOGGER.error("Error while transforming timestamp", e); throw new BadRequestException("Error while transforming timestamp", e); } return result; }
UserInterfaceTransactionManager { public JsonNode extractInformationFromTimestamp(String timestamp) throws BadRequestException { final ObjectNode result = JsonHandler.createObjectNode(); try { ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream( org.bouncycastle.util.encoders.Base64.decode(timestamp.getBytes()))); ASN1Primitive obj = bIn.readObject(); TimeStampResponse tsResp = new TimeStampResponse(obj.toASN1Primitive().getEncoded()); SignerId signerId = tsResp.getTimeStampToken().getSID(); X500Name signerCertIssuer = signerId.getIssuer(); result.put("genTime", LocalDateUtil.getString( LocalDateUtil.fromDate(tsResp.getTimeStampToken().getTimeStampInfo().getGenTime()))); result.put("signerCertIssuer", signerCertIssuer.toString()); } catch (TSPException | IOException | DecoderException e) { LOGGER.error("Error while transforming timestamp", e); throw new BadRequestException("Error while transforming timestamp", e); } return result; } }
UserInterfaceTransactionManager { public JsonNode extractInformationFromTimestamp(String timestamp) throws BadRequestException { final ObjectNode result = JsonHandler.createObjectNode(); try { ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream( org.bouncycastle.util.encoders.Base64.decode(timestamp.getBytes()))); ASN1Primitive obj = bIn.readObject(); TimeStampResponse tsResp = new TimeStampResponse(obj.toASN1Primitive().getEncoded()); SignerId signerId = tsResp.getTimeStampToken().getSID(); X500Name signerCertIssuer = signerId.getIssuer(); result.put("genTime", LocalDateUtil.getString( LocalDateUtil.fromDate(tsResp.getTimeStampToken().getTimeStampInfo().getGenTime()))); result.put("signerCertIssuer", signerCertIssuer.toString()); } catch (TSPException | IOException | DecoderException e) { LOGGER.error("Error while transforming timestamp", e); throw new BadRequestException("Error while transforming timestamp", e); } return result; } UserInterfaceTransactionManager(); @VisibleForTesting  UserInterfaceTransactionManager(
        AccessExternalClientFactory accessExternalClientFactory,
        AdminExternalClientFactory adminExternalClientFactory,
        AccessExternalClientV2Factory accessExternalClientV2Factory,
        DslQueryHelper dslQueryHelper); }
UserInterfaceTransactionManager { public JsonNode extractInformationFromTimestamp(String timestamp) throws BadRequestException { final ObjectNode result = JsonHandler.createObjectNode(); try { ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream( org.bouncycastle.util.encoders.Base64.decode(timestamp.getBytes()))); ASN1Primitive obj = bIn.readObject(); TimeStampResponse tsResp = new TimeStampResponse(obj.toASN1Primitive().getEncoded()); SignerId signerId = tsResp.getTimeStampToken().getSID(); X500Name signerCertIssuer = signerId.getIssuer(); result.put("genTime", LocalDateUtil.getString( LocalDateUtil.fromDate(tsResp.getTimeStampToken().getTimeStampInfo().getGenTime()))); result.put("signerCertIssuer", signerCertIssuer.toString()); } catch (TSPException | IOException | DecoderException e) { LOGGER.error("Error while transforming timestamp", e); throw new BadRequestException("Error while transforming timestamp", e); } return result; } UserInterfaceTransactionManager(); @VisibleForTesting  UserInterfaceTransactionManager(
        AccessExternalClientFactory accessExternalClientFactory,
        AdminExternalClientFactory adminExternalClientFactory,
        AccessExternalClientV2Factory accessExternalClientV2Factory,
        DslQueryHelper dslQueryHelper); static UserInterfaceTransactionManager getInstance(); RequestResponse<JsonNode> searchUnits(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> searchObjects(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> getArchiveUnitDetails(JsonNode preparedDslQuery, String unitId,
        VitamContext context); RequestResponse<JsonNode> selectUnitsWithInheritedRules(JsonNode preparedDslQuery,
        VitamContext context); RequestResponse<JsonNode> startEliminationAnalysis(EliminationRequestBody parameters,
        VitamContext context); RequestResponse<JsonNode> startEliminationAction(EliminationRequestBody parameters,
        VitamContext context); RequestResponse<JsonNode> massiveUnitsUpdate(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> computinheritedrules(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> deleteComputedInheritedRules(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> massiveRulesUpdate(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> updateUnits(JsonNode parameters, String unitId, VitamContext context); RequestResponse<JsonNode> selectObjectbyId(JsonNode preparedDslQuery, String objectId,
        VitamContext context); boolean getObjectAsInputStream(AsyncResponse asyncResponse,
        String unitId, String usage, int version, String filename, VitamContext context,
        List<MediaType> allowedMediaTypes); RequestResponse<LogbookLifecycle> selectUnitLifeCycleById(String unitLifeCycleId,
        VitamContext context); RequestResponse<LogbookOperation> selectOperation(JsonNode query, VitamContext context); RequestResponse<LogbookOperation> selectOperationbyId(String operationId, VitamContext context); RequestResponse<LogbookLifecycle> selectObjectGroupLifeCycleById(String objectGroupLifeCycleId,
        VitamContext context); RequestResponse<AccessionRegisterSummaryModel> findAccessionRegisterSummary(String options,
        VitamContext context); RequestResponse<AccessionRegisterSymbolicModel> findAccessionRegisterSymbolic(String options,
        VitamContext context); RequestResponse<JsonNode> findAccessionRegisterDetail(String originatingAgency, String options, VitamContext context); RequestResponse<JsonNode> checkTraceabilityOperation(JsonNode query, VitamContext context); JsonNode extractInformationFromTimestamp(String timestamp); RequestResponse evidenceAudit(JsonNode query, VitamContext context); RequestResponse exportProbativeValue(ProbativeValueRequest request, VitamContext context); RequestResponse<JsonNode> exportDIP(DipRequest dipRequest, VitamContext context); RequestResponse<JsonNode> transferSIP(TransferRequest transferRequest, VitamContext context); boolean downloadExports(AsyncResponse asyncResponse, String exportId, VitamContext context, boolean isTransfer); VitamContext getVitamContext(HttpServletRequest request); VitamContext getVitamContext(Integer tenantId, String contractId, String personalCert); VitamContext getVitamContext(Integer tenantId, String contractId, HttpServletRequest request); String getPersonalCertificate(HttpServletRequest request); String getContractId(HttpServletRequest request); Integer getTenantId(HttpServletRequest request); String getAppSessionId(); }
UserInterfaceTransactionManager { public JsonNode extractInformationFromTimestamp(String timestamp) throws BadRequestException { final ObjectNode result = JsonHandler.createObjectNode(); try { ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream( org.bouncycastle.util.encoders.Base64.decode(timestamp.getBytes()))); ASN1Primitive obj = bIn.readObject(); TimeStampResponse tsResp = new TimeStampResponse(obj.toASN1Primitive().getEncoded()); SignerId signerId = tsResp.getTimeStampToken().getSID(); X500Name signerCertIssuer = signerId.getIssuer(); result.put("genTime", LocalDateUtil.getString( LocalDateUtil.fromDate(tsResp.getTimeStampToken().getTimeStampInfo().getGenTime()))); result.put("signerCertIssuer", signerCertIssuer.toString()); } catch (TSPException | IOException | DecoderException e) { LOGGER.error("Error while transforming timestamp", e); throw new BadRequestException("Error while transforming timestamp", e); } return result; } UserInterfaceTransactionManager(); @VisibleForTesting  UserInterfaceTransactionManager(
        AccessExternalClientFactory accessExternalClientFactory,
        AdminExternalClientFactory adminExternalClientFactory,
        AccessExternalClientV2Factory accessExternalClientV2Factory,
        DslQueryHelper dslQueryHelper); static UserInterfaceTransactionManager getInstance(); RequestResponse<JsonNode> searchUnits(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> searchObjects(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> getArchiveUnitDetails(JsonNode preparedDslQuery, String unitId,
        VitamContext context); RequestResponse<JsonNode> selectUnitsWithInheritedRules(JsonNode preparedDslQuery,
        VitamContext context); RequestResponse<JsonNode> startEliminationAnalysis(EliminationRequestBody parameters,
        VitamContext context); RequestResponse<JsonNode> startEliminationAction(EliminationRequestBody parameters,
        VitamContext context); RequestResponse<JsonNode> massiveUnitsUpdate(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> computinheritedrules(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> deleteComputedInheritedRules(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> massiveRulesUpdate(JsonNode parameters, VitamContext context); RequestResponse<JsonNode> updateUnits(JsonNode parameters, String unitId, VitamContext context); RequestResponse<JsonNode> selectObjectbyId(JsonNode preparedDslQuery, String objectId,
        VitamContext context); boolean getObjectAsInputStream(AsyncResponse asyncResponse,
        String unitId, String usage, int version, String filename, VitamContext context,
        List<MediaType> allowedMediaTypes); RequestResponse<LogbookLifecycle> selectUnitLifeCycleById(String unitLifeCycleId,
        VitamContext context); RequestResponse<LogbookOperation> selectOperation(JsonNode query, VitamContext context); RequestResponse<LogbookOperation> selectOperationbyId(String operationId, VitamContext context); RequestResponse<LogbookLifecycle> selectObjectGroupLifeCycleById(String objectGroupLifeCycleId,
        VitamContext context); RequestResponse<AccessionRegisterSummaryModel> findAccessionRegisterSummary(String options,
        VitamContext context); RequestResponse<AccessionRegisterSymbolicModel> findAccessionRegisterSymbolic(String options,
        VitamContext context); RequestResponse<JsonNode> findAccessionRegisterDetail(String originatingAgency, String options, VitamContext context); RequestResponse<JsonNode> checkTraceabilityOperation(JsonNode query, VitamContext context); JsonNode extractInformationFromTimestamp(String timestamp); RequestResponse evidenceAudit(JsonNode query, VitamContext context); RequestResponse exportProbativeValue(ProbativeValueRequest request, VitamContext context); RequestResponse<JsonNode> exportDIP(DipRequest dipRequest, VitamContext context); RequestResponse<JsonNode> transferSIP(TransferRequest transferRequest, VitamContext context); boolean downloadExports(AsyncResponse asyncResponse, String exportId, VitamContext context, boolean isTransfer); VitamContext getVitamContext(HttpServletRequest request); VitamContext getVitamContext(Integer tenantId, String contractId, String personalCert); VitamContext getVitamContext(Integer tenantId, String contractId, HttpServletRequest request); String getPersonalCertificate(HttpServletRequest request); String getContractId(HttpServletRequest request); Integer getTenantId(HttpServletRequest request); String getAppSessionId();  }