public boolean verifySignature ( String message , String signature , PublicKey publicKey ) { boolean result = false ; try { byte [ ] sigbytes = Base64 . decode ( signature . getBytes ( ) ) ; Signature sigChecker = SIG_CHECKER . get ( ) ; sigChecker . initVerify ( publicKey ) ; sigChecker . update ( message . getBytes ( ) ) ; result = sigChecker . verify ( sigbytes ) ; } catch ( InvalidKeyException e ) { // Rare exception: The private key was incorrectly formatted } catch ( SignatureException e ) { // Rare exception: Catch-all exception for the signature checker } return result ; }
Does the actual Java cryptographic verification of the signature . This method does no handling of the many rare exceptions it is required to catch .