@Test public void signJsonPayload() { String jsonString = "{\n" + " \"sub\": \"1234567890\",\n" + " \"name\": \"John Doe\",\n" + " \"iat\": 1516239022\n" + "}"; String signed = signingService.signJsonPayload(jsonString); System.out.println(signed); }
@Override public String signJsonPayload(String jsonString) { try { JWSAlgorithm jwsAlgorithm = new JWSAlgorithm(config.getJwtOutboundAlgorithm()); JWSSigner signer = new MACSigner(getKey(config.getJwtOutboundKey())); JWSHeader header = new JWSHeader(jwsAlgorithm); JWSObject jwsObject = new JWSObject(header, new Payload(jsonString)); jwsObject.sign(signer); return jwsObject.serialize(); } catch (Exception e) { throw new OnlyOfficeException("Can't sign payload. Reason: " + e.getMessage(), e); } }
JWTSigningServiceImpl implements JWTSigningService { @Override public String signJsonPayload(String jsonString) { try { JWSAlgorithm jwsAlgorithm = new JWSAlgorithm(config.getJwtOutboundAlgorithm()); JWSSigner signer = new MACSigner(getKey(config.getJwtOutboundKey())); JWSHeader header = new JWSHeader(jwsAlgorithm); JWSObject jwsObject = new JWSObject(header, new Payload(jsonString)); jwsObject.sign(signer); return jwsObject.serialize(); } catch (Exception e) { throw new OnlyOfficeException("Can't sign payload. Reason: " + e.getMessage(), e); } } }
JWTSigningServiceImpl implements JWTSigningService { @Override public String signJsonPayload(String jsonString) { try { JWSAlgorithm jwsAlgorithm = new JWSAlgorithm(config.getJwtOutboundAlgorithm()); JWSSigner signer = new MACSigner(getKey(config.getJwtOutboundKey())); JWSHeader header = new JWSHeader(jwsAlgorithm); JWSObject jwsObject = new JWSObject(header, new Payload(jsonString)); jwsObject.sign(signer); return jwsObject.serialize(); } catch (Exception e) { throw new OnlyOfficeException("Can't sign payload. Reason: " + e.getMessage(), e); } }  }
JWTSigningServiceImpl implements JWTSigningService { @Override public String signJsonPayload(String jsonString) { try { JWSAlgorithm jwsAlgorithm = new JWSAlgorithm(config.getJwtOutboundAlgorithm()); JWSSigner signer = new MACSigner(getKey(config.getJwtOutboundKey())); JWSHeader header = new JWSHeader(jwsAlgorithm); JWSObject jwsObject = new JWSObject(header, new Payload(jsonString)); jwsObject.sign(signer); return jwsObject.serialize(); } catch (Exception e) { throw new OnlyOfficeException("Can't sign payload. Reason: " + e.getMessage(), e); } }  @Override boolean verifyToken(String token); @Override String signJsonPayload(String jsonString); void setConfig(OnlyOfficeConfig config); }
JWTSigningServiceImpl implements JWTSigningService { @Override public String signJsonPayload(String jsonString) { try { JWSAlgorithm jwsAlgorithm = new JWSAlgorithm(config.getJwtOutboundAlgorithm()); JWSSigner signer = new MACSigner(getKey(config.getJwtOutboundKey())); JWSHeader header = new JWSHeader(jwsAlgorithm); JWSObject jwsObject = new JWSObject(header, new Payload(jsonString)); jwsObject.sign(signer); return jwsObject.serialize(); } catch (Exception e) { throw new OnlyOfficeException("Can't sign payload. Reason: " + e.getMessage(), e); } }  @Override boolean verifyToken(String token); @Override String signJsonPayload(String jsonString); void setConfig(OnlyOfficeConfig config);  }