2017-05-31 33 views
1

文档我目前使用深化发展作为露天GED和春季为framework.I要显示在导航文件而不认证requirment.So我该怎么办that.By的方式一个Java/JEE应用我在我的项目2个模块:前台和后台,它们通过休息calls.From通信的后端我试图传递对象的字节数组,但不幸的是我收到它作为字符串,所以我不能用it.So任何建议工作解决这个问题?显示没有认证

public Map<String, Object> getCourrierDetails(String idCourrier) throws Exception { 
     Map<String, Object> courriersDetails = runtimeService.getVariables(idCourrier); 
courriersDetails.put("idCourrier", idCourrier); 
     DocumentDaoImpl dao=new DocumentDaoImpl(); 

     Document docCmis = (Document) dao.getDocument("workspace://SpacesStore/73871a36-9a6c-42c6-b3e3-7d68362fe9c0"); 

     byte[] myByteArray = readContent(docCmis.getContentStream().getStream()); 


     ByteArrayResource resource = new ByteArrayResource(myByteArray) { 
      @Override 
      public String getFilename() { 
       return docCmis.getContentStreamFileName(); 
      } 
     }; 
     System.out.println(resource.getFilename()); 
     //courriersDetails.put("resources", myByteArray); 
     System.out.println(courriersDetails.get("resources")+" rrrr"); 
     //courriersDetails.put("contentStream",docCmis.getContentStream().getStream()); 
     return courriersDetails; 
    } 
+0

据我所知你只能显示PDF文档,你将使用InputStream –

回答

3

假设您的前端和后端是定制和后端与露天通信,所有你需要做的是编写驻留在后端的代理。

代理可以露天使用具​​有访问内容的预先配置的“服务帐户”建立会话。通过这种方式,使用自定义Web应用程序不使用自己的凭据的人摆脱露天的对象。而是使用服务帐户,并且Web应用程序将其传送给请求者。

例如,在我的项目之一,我有一个使用CMIS摆脱内容的InputStream给予其ID的AssetService:

public InputStream download(String assetId) { 
    CmisObject obj = session.getObject(assetId); 
    Document doc = null; 
    if (obj.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) { 
     doc = (Document) obj; 
    } 
    return doc.getContentStream().getStream(); 
} 

然后,我的控制器只要求提供资产获得一些服务关于它的信息可以很容易设置一些有用的头,然后将其从资产服务获取输入流,并返回:

@RequestMapping(value = "/api/asset/{assetId:.+}/download/{name}", method = RequestMethod.GET) 
public ResponseEntity<InputStreamResource> downloadAsset(
     @PathVariable("assetId") String assetId, 
     @PathVariable("name") String name) { 

    // get the asset so we can get some info about it 
    Asset asset = assetService.getAsset(assetId); 

    // set the http headers (mimetype and length at a minimum) 
    HttpHeaders httpHeaders = new HttpHeaders(); 
    httpHeaders.setContentType(MediaType.parseMediaType(asset.getMimetype())); 
    httpHeaders.setContentLength(asset.getLength()); 

    // get the content stream 
    InputStream inputStream = assetService.download(assetId); 
    InputStreamResource inputStreamResource = new InputStreamResource(inputStream); 

    return new ResponseEntity<InputStreamResource>(inputStreamResource, httpHeaders, HttpStatus.OK); 
} 

本例中使用Spring MVC的一个春天启动的应用程序中,但当然,你可以这样做与普通的旧servlet类似如果你想。

+0

当你在户外创建一个文档时,有可能在没有认证的情况下得到它,这是否意味着每个人都可以访问文档? ? –

+0

不,这是不可能得到其不进行验证,除非你做这样的事情是我的建议上面,基本上把一个代理在露天的前面并获取代表用户的文档。如果一个人能猜出一个节点的参考,他们会能够得到在“服务帐户”访问回购任何文件。 –

+0

谢谢@jeffPotts的回复和你的时间 –