Example usage for java.security SignatureException toString

List of usage examples for java.security SignatureException toString

Introduction

In this page you can find the example usage for java.security SignatureException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.netscape.cmscore.apps.CMSEngine.java

/**
 * sign some known data to determine if signing key is botched;
 * if so, proceed to graceful shutdown//from ww  w  .  j a va  2  s .co  m
 */
public void checkForAndAutoShutdown() {
    String method = "CMSEngine: checkForAndAutoShutdown: ";
    logger.debug(method + "begins");

    try {
        boolean allowShutdown = mConfig.getBoolean("autoShutdown.allowed", false);
        if ((!allowShutdown) || (mSigningKey == null) || (mSigningData == null)) {
            logger.debug(method + "autoShutdown not allowed");
            return;
        }
        logger.debug(method + "autoShutdown allowed");
        CryptoToken token = ((org.mozilla.jss.pkcs11.PK11PrivKey) mSigningKey).getOwningToken();
        SignatureAlgorithm signAlg = Cert.mapAlgorithmToJss("SHA256withRSA");
        Signature signer = token.getSignatureContext(signAlg);

        signer.initSign(mSigningKey);
        signer.update(mSigningData);
        byte[] result = signer.sign();
        logger.debug(method + " signining successful: " + new String(result));
    } catch (SignatureException e) {

        //Let's write to the error console in case we are in a bad memory situation
        //This will be the most likely to work, giving us a record of the signing failure
        ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_CA_SIGNING_OPERATION_FAILED", e.toString())));

        logger.warn(method + "autoShutdown for " + e.getMessage(), e);

        autoShutdown();
    } catch (Exception e) {
        logger.warn(method + "continue for " + e.getMessage(), e);
    }
    logger.debug(method + "passed; continue");
}