Java Code Examples for java.security.SignatureException#getMessage()

The following examples show how to use java.security.SignatureException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockWrapper.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean validateSignature(Manager dbManager) throws ValidateSignatureException {
    try {
        byte[] sigAddress = ECKey.signatureToAddress(getRawHash().getBytes(),
                TransactionWrapper.getBase64FromByteString(block.getBlockHeader().getWitnessSignature()));
        byte[] witnessAccountAddress = block.getBlockHeader().getRawData().getWitnessAddress()
                .toByteArray();

        if (dbManager.getDynamicPropertiesStore().getAllowMultiSign() != 1) {
            return Arrays.equals(sigAddress, witnessAccountAddress);
        } else {
            byte[] witnessPermissionAddress = dbManager.getAccountStore().get(witnessAccountAddress)
                    .getWitnessPermissionAddress();
            return Arrays.equals(sigAddress, witnessPermissionAddress);
        }

    } catch (SignatureException e) {
        throw new ValidateSignatureException(e.getMessage());
    }
}
 
Example 2
Source File: SignatureExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Test for <code>SignatureException(Throwable)</code> constructor
 * Assertion: constructs SignatureException when <code>cause</code> is not
 * null
 */
public void testSignatureException05() {
    SignatureException tE = new SignatureException(tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() should contain ".concat(toS), (getM
                .indexOf(toS) != -1));
    }
    assertNotNull("getCause() must not return null", tE.getCause());
    assertEquals("getCause() must return ".concat(tCause.toString()), tE
            .getCause(), tCause);
}
 
Example 3
Source File: SignatureExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Test for <code>SignatureException(String, Throwable)</code> constructor
 * Assertion: constructs SignatureException when <code>cause</code> is not
 * null <code>msg</code> is null
 */
public void testSignatureException08() {
    SignatureException tE = new SignatureException(null, tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() must should ".concat(toS), (getM
                .indexOf(toS) != -1));
    }
    assertNotNull("getCause() must not return null", tE.getCause());
    assertEquals("getCause() must return ".concat(tCause.toString()), tE
            .getCause(), tCause);
}
 
Example 4
Source File: SignatureSigner.java    From xipki with Apache License 2.0 5 votes vote down vote up
@Override
public void write(int singleByte) throws IOException {
  try {
    signer.update((byte) singleByte);
  } catch (SignatureException ex) {
    throw new IOException(ex.getMessage(), ex);
  }
}
 
Example 5
Source File: SignatureSigner.java    From xipki with Apache License 2.0 5 votes vote down vote up
@Override
public void write(byte[] bytes) throws IOException {
  try {
    signer.update(bytes);
  } catch (SignatureException ex) {
    throw new IOException(ex.getMessage(), ex);
  }
}
 
Example 6
Source File: SignatureSigner.java    From xipki with Apache License 2.0 5 votes vote down vote up
@Override
public void write(byte[] bytes, int off, int len) throws IOException {
  try {
    signer.update(bytes, off, len);
  } catch (SignatureException ex) {
    throw new IOException(ex.getMessage(), ex);
  }
}
 
Example 7
Source File: SignatureSigner.java    From xipki with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getSignature() {
  try {
    return stream.getSignature();
  } catch (SignatureException ex) {
    throw new RuntimeOperatorException("exception obtaining signature: " + ex.getMessage(), ex);
  }
}