question: public String signMessage ( String message ) throws IllegalStateException { Validate . notNull ( getSignAlgorithm ( ) , "Signature Algorithm" ) ; Validate . notNull ( getPrivateKey ( ) , "PrivateKey for signing" ) ; Validate . notEmpty ( message , "message string" ) ; log . debug ( "Signing  message " + message + ", sigAlg " + getSignAlgorithm ( ) ) ; try { SignatureAlgorithm algo = SignatureAlgorithm . getSignatureAlgorithmForURI ( getSignAlgorithm ( ) ) ; Signature sig = Signature . getInstance ( algo . getAlgorithmName ( ) ) ; sig . initSign ( this . privateKey ) ; byte [ ] messageBytes = message . getBytes ( "UTF-8" ) ; sig . update ( messageBytes ) ; byte [ ] sigBytes = sig . sign ( ) ; String signature = SharedUtils . encodeBytes ( sigBytes ) ; log . debug ( "signature: " + signature ) ; return signature ; } catch ( Exception e ) { log . error ( "Failed to sign the message: exception cause" , e ) ; throw new IllegalStateException ( e ) ; } }
target:  Signs message with known private key and algorithm. Throws on error.