public static byte[] convertDEREncodedSignatureToJWSConcatenated(final byte[] derEncodedSignatureValue) throws IOException {
  final ASN1InputStream asn1InputStream=new ASN1InputStream(derEncodedSignatureValue);
  final ASN1Primitive asn1Primitive=asn1InputStream.readObject();
  asn1InputStream.close();
  final ASN1Sequence asn1Sequence=(ASN1Sequence.getInstance(asn1Primitive));
  final ASN1Integer rASN1=(ASN1Integer)asn1Sequence.getObjectAt(0);
  final ASN1Integer sASN1=(ASN1Integer)asn1Sequence.getObjectAt(1);
  final X9IntegerConverter x9IntegerConverter=new X9IntegerConverter();
  final byte[] r=x9IntegerConverter.integerToBytes(rASN1.getValue(),32);
  final byte[] s=x9IntegerConverter.integerToBytes(sASN1.getValue(),32);
  final byte[] concatenatedSignatureValue=new byte[64];
  System.arraycopy(r,0,concatenatedSignatureValue,0,32);
  System.arraycopy(s,0,concatenatedSignatureValue,32,32);
  return concatenatedSignatureValue;
}

public static byte [ ] convertDEREncodedSignatureToJWSConcatenated ( final byte [ ] derEncodedSignatureValue ) throws IOException { final ASN1InputStream asn1InputStream = new ASN1InputStream ( derEncodedSignatureValue ) ; final ASN1Primitive asn1Primitive = asn1InputStream . readObject ( ) ; asn1InputStream . close ( ) ; final ASN1Sequence asn1Sequence = ( ASN1Sequence . getInstance ( asn1Primitive ) ) ; final ASN1Integer rASN1 = ( ASN1Integer ) asn1Sequence . getObjectAt ( 0 ) ; final ASN1Integer sASN1 = ( ASN1Integer ) asn1Sequence . getObjectAt ( 1 ) ; final X9IntegerConverter x9IntegerConverter = new X9IntegerConverter ( ) ; final byte [ ] r = x9IntegerConverter . integerToBytes ( rASN1 . getValue ( ) , 32 ) ; final byte [ ] s = x9IntegerConverter . integerToBytes ( sASN1 . getValue ( ) , 32 ) ; final byte [ ] concatenatedSignatureValue = new byte [ 64 ] ; System . arraycopy ( r , 0 , concatenatedSignatureValue , 0 , 32 ) ; System . arraycopy ( s , 0 , concatenatedSignatureValue , 32 , 32 ) ; return concatenatedSignatureValue ; }
helper method to convert der - encoded signature values ( e . g . used by java ) to concatenated signature values ( as used by the jws - standard )
