Search in sources :

Example 1 with CrlContextExample

use of com.itrus.portal.db.CrlContextExample in project portal by ixinportal.

the class CrlContextController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    // count,pages
    Integer count = sqlSession.selectOne("com.itrus.portal.db.CrlContextMapper.countByExample", null);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // query data
    Integer offset = size * (page - 1);
    RowBounds rowBounds = new RowBounds(offset, size);
    CrlContextExample example = new CrlContextExample();
    List crlList = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectByExample", example, rowBounds);
    uiModel.addAttribute("crlList", crlList);
    // itemcount
    uiModel.addAttribute("itemcount", crlList.size());
    return "crlcontext/list";
}
Also used : CrlContextExample(com.itrus.portal.db.CrlContextExample) RowBounds(org.apache.ibatis.session.RowBounds) List(java.util.List) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CrlContextExample

use of com.itrus.portal.db.CrlContextExample in project portal by ixinportal.

the class TrustService method initCVM.

/**
 * 初始化CVM
 */
public void initCVM() {
    CVM.clear();
    CrlContextExample example = new CrlContextExample();
    List<CrlContext> contexts = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectByExampleWithBLOBs", example);
    // 若没有配置信任源则不进行初始化
    if (contexts.isEmpty())
        return;
    try {
        for (CrlContext context : contexts) {
            X509Certificate x509cert = null;
            if (context.getCaCertBuf() != null && context.getCaCertBuf().length > 0) {
                x509cert = X509Certificate.getInstance(context.getCaCertBuf());
            }
            CVM.addSupportCA(x509cert, context.getCrlUrl().trim(), context.getRetryPolicy().trim(), !context.getCheckCrl());
        }
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (NoSuchProviderException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CrlContext(com.itrus.portal.db.CrlContext) CrlContextExample(com.itrus.portal.db.CrlContextExample) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) NoSuchProviderException(java.security.NoSuchProviderException) X509Certificate(com.itrus.cert.X509Certificate)

Aggregations

CrlContextExample (com.itrus.portal.db.CrlContextExample)2 X509Certificate (com.itrus.cert.X509Certificate)1 CrlContext (com.itrus.portal.db.CrlContext)1 IOException (java.io.IOException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 CertificateException (java.security.cert.CertificateException)1 List (java.util.List)1 RowBounds (org.apache.ibatis.session.RowBounds)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1