1

I'm having trouble while trying to validate a pair of token/sign for webservice login.

The WS is exposed as a soap-wsdl 1.1, but a client needs to consume it via a react-native application. After hours of research we (the client and I) ended up with the conclusion that would be faster to publish a Rest-proxy that consumes the wsdl and exposes it as a rest api.

The WS is solely for authentication and consists in two methods:

+login(String: username, String: password): LoginResponse(String token, Base64Binary sign);

+verifyToken(String: token, Base64Binary: sign): Boolean;

wsdl parameters for token and sign verification

<xs:sequence>
<xs:element minOccurs="0" name="token" type="xs:string"/>
<xs:element minOccurs="0" name="firma" type="xs:base64Binary"/>
</xs:sequence>

The LoginResponse is sent via json, with the following structure:

public class LoginResponse {

    private byte[] firma;
    private String token;

}

Then is received by verifyToken as a String:

@GET
@Path("/validarToken")
@Produces(MediaType.APPLICATION_JSON)
public Response verifyToken(@QueryParam("token") String token,
        @QueryParam("sign") String sign) {

}

Then, sign is converted using sign.getBytes();

I've noticed that when I debug the byteArray returned by login(), the array includes negative numbers, but when is received by verifyToken and converted to bytes non of the negative values are represented (the resulting array is not the same).

Nevertheless if I directly invoke verifyToken after login with the LoginResponse it verifies correctly, so the method verifyToken works correctly.

Thanks.

dantebarba
  • 1,396
  • 1
  • 12
  • 22

1 Answers1

2

As I couldn't solve the issue using base64 to String conversion, I've done the following:

-Converted the Base64 byte array to a hex string -verifyToken now accepts a hex string as sign. -converted the hex string sign back to byte array.

The hex conversion was provided by: https://stackoverflow.com/a/5942951/2350854

Community
  • 1
  • 1
dantebarba
  • 1,396
  • 1
  • 12
  • 22