Example usage for javax.security.jacc PolicyContextException getMessage

List of usage examples for javax.security.jacc PolicyContextException getMessage

Introduction

In this page you can find the example usage for javax.security.jacc PolicyContextException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:test.be.fedict.eid.applet.model.XmlSignatureServiceBean.java

public void postSign(byte[] signatureValue, List<X509Certificate> signingCertificateChain) {
    LOG.debug("postSign");

    HttpServletRequest httpServletRequest;
    try {/*from w w  w .  java  2 s  . c  o m*/
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession session = httpServletRequest.getSession();
    String documentStr = (String) session.getAttribute("xmlDocument");

    Document document;
    try {
        document = getDocument(documentStr);
    } catch (Exception e) {
        throw new RuntimeException("DOM error: " + e.getMessage(), e);
    }

    // insert signature value
    NodeList signatureValueNodeList = document.getElementsByTagNameNS(javax.xml.crypto.dsig.XMLSignature.XMLNS,
            "SignatureValue");
    Element signatureValueElement = (Element) signatureValueNodeList.item(0);
    signatureValueElement.setTextContent(Base64.encode(signatureValue));

    try {
        documentStr = toString(document);
    } catch (Exception e) {
        throw new RuntimeException("DOM error: " + e.getMessage(), e);
    }

    session.setAttribute("xmlDocument", documentStr);
}

From source file:test.be.fedict.eid.applet.model.XmlSignatureServiceBean.java

public DigestInfo preSign(List<DigestInfo> digestInfos, List<X509Certificate> signingCertificateChain)
        throws NoSuchAlgorithmException {
    LOG.debug("preSign");
    HttpServletRequest httpServletRequest;
    try {//  w  w  w .  ja va2s  .  co m
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    String digestAlgo = (String) httpSession.getAttribute("signDigestAlgo");
    LOG.debug("digest algo: " + digestAlgo);

    byte[] digestValue;
    try {
        digestValue = getXmlSignatureDigestValue(digestAlgo, digestInfos, httpSession);
    } catch (Exception e) {
        throw new RuntimeException("XML signature error: " + e.getMessage(), e);
    }

    String description = "Test XML Document";
    return new DigestInfo(digestValue, digestAlgo, description);
}

From source file:test.be.fedict.eid.applet.SignatureServiceImpl.java

private HttpSession getHttpSession() {
    HttpServletRequest httpServletRequest;
    try {//from ww w  .  ja  v  a2s . c  om
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession session = httpServletRequest.getSession();
    return session;
}