Returns the associated Signature object with this event, if the event is
associated with a Signature Request.

@return Signature
@throws HelloSignException thrown if there is a problem parsing the
backing JSONObject.
174570
public Signature getRelatedSignature() throws HelloSignException {
        String id = getRelatedSignatureId();
        if (id == null) {
            return null;
        }
        for (Signature sig : ((SignatureRequest) resource).getSignatures()) {
            if (id.equals(sig.getId())) {
                return sig;
            }
        }
        return null;
    }
80154
public SignatureRequest sendSignatureRequest(SignatureRequest req) throws HelloSignException {
        if (req.hasId()) {
            throw new HelloSignException("Sending an existing signature request is not supported");
        }
        return new SignatureRequest(httpClient.withAuth(auth).withPostFields(req.getPostFields())
                .post(BASE_URI + SIGNATURE_REQUEST_SEND_URI).asJson());
    }
661296
public Map<String, Serializable> getPostFields() throws HelloSignException {
        Map<String, Serializable> fields = new HashMap<String, Serializable>();
        try {
            if (hasName()) {
                fields.put(APIAPP_NAME, getName());
            }
            if (hasDomain()) {
                fields.put(APIAPP_DOMAIN, getDomain());
            }
            if (hasCallbackUrl()) {
                fields.put(APIAPP_CALLBACK_URL, getCallbackUrl());
            }
            if (custom_logo != null && custom_logo.exists()) {
                fields.put(APIAPP_CUSTOM_LOGO, custom_logo);
            }
            ApiAppOauth oauth = getOauthInfo();
            if (oauth != null) {
                if (oauth.hasCallbackUrl()) {
                    fields.put("oauth[callback_url]", oauth.getCallbackUrl());
                }
                Set<ApiAppOauthScopeType> scopes = oauth.getScopes();
                if (scopes.size() > 0) {
                    String scopeStr = "";
                    for (ApiAppOauthScopeType type : scopes) {
                        scopeStr += type.toString() + ",";
                    }
                    scopeStr = scopeStr.substring(0, scopeStr.length() - 1);
                    fields.put("oauth[scopes]", scopeStr);
                }
            }
            if (white_labeling_options != null) {
                fields.put(WhiteLabelingOptions.WHITE_LABELING_OPTIONS_KEY, white_labeling_options.toString(0));
            }
        } catch (Exception e) {
            throw new HelloSignException(e);
        }
        return fields;
    }
1103033
public function generateSignature()
    {
        $signatureArray = array();

        // Create a pre-hash string based on the security credentials
        // The order is important
        foreach ($this->validSecurityKeys as $key) {
            if (array_key_exists($key, $this->securityPacket)) {
                array_push($signatureArray, $this->securityPacket[$key]);
            }
        }

        // Add the secret
        array_push($signatureArray, $this->secret);

        // Add the requestPacket if necessary
        if ($this->signRequestData && !empty($this->requestString)) {
            array_push($signatureArray, $this->requestString);
        }

        // Add the action if necessary
        if (!empty($this->action)) {
            array_push($signatureArray, $this->action);
        }

        return $this->hashValue($signatureArray);
    }
1368947
private String getParamJVMSignature(String paramsig) throws SignatureException {
        String paramJVMSig = "";
        String componentType ="";

        if(paramsig != null){

            if(paramsig.contains("[]")) {
                // Gets array dimension.
                int endindex = paramsig.indexOf("[]");
                componentType = paramsig.substring(0, endindex);
                String dimensionString =  paramsig.substring(endindex);
                if(dimensionString != null){
                    while(dimensionString.contains("[]")){
                        paramJVMSig += "[";
                        int beginindex = dimensionString.indexOf("]") + 1;
                        if(beginindex < dimensionString.length()){
                            dimensionString = dimensionString.substring(beginindex);
                        }else
                            dimensionString = "";
                    }
                }
            } else componentType = paramsig;

            paramJVMSig += getComponentType(componentType);
        }
        return paramJVMSig;
    }
273035
public AbstractRequest createEmbeddedRequest(EmbeddedRequest embeddedReq) throws HelloSignException {
        String url = BASE_URI;
        Class<?> returnType = SignatureRequest.class;
        AbstractRequest req = embeddedReq.getRequest();
        if (req instanceof TemplateSignatureRequest) {
            url += SIGNATURE_REQUEST_EMBEDDED_TEMPLATE_URI;
        } else if (req instanceof UnclaimedDraft) {
            if (((UnclaimedDraft) req).getRequest() instanceof TemplateSignatureRequest) {
                url += UNCLAIMED_DRAFT_CREATE_EMBEDDED_WITH_TEMPLATE_URI;
            } else {
                url += UNCLAIMED_DRAFT_CREATE_EMBEDDED_URI;
            }
            returnType = UnclaimedDraft.class;
        } else {
            url += SIGNATURE_REQUEST_EMBEDDED_URI;
        }
        try {
            Constructor<?> constructor = returnType.getConstructor(JSONObject.class);
            return (AbstractRequest) constructor.newInstance(
                    httpClient.withAuth(auth).withPostFields(embeddedReq.getPostFields()).post(url).asJson());
        } catch (Exception ex) {
            throw new HelloSignException(ex);
        }
    }
4205
public ClassTypeSignature getTypeSignature() {
        if (typeSignatureStr == null) {
            return null;
        }
        if (typeSignature == null) {
            try {
                typeSignature = ClassTypeSignature.parse(typeSignatureStr, this);
                typeSignature.setScanResult(scanResult);
            } catch (final ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }
        return typeSignature;
    }
882651
public HashMap<String, List<String>> parseUidAssignV1() {
    final String json = query.getContent();
    if (json == null || json.isEmpty()) {
      throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
          "Missing message content",
          "Supply valid JSON formatted data in the body of your request");
    }
    try {
      return JSON.parseToObject(json, UID_ASSIGN);
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException("Unable to parse the given JSON", iae);
    }
  }
1229265
public String getEventMessage() throws HelloSignException {
        JSONObject metadata = (JSONObject) get(EVENT_METADATA);
        String eventMessage = null;
        try {
            eventMessage = metadata.getString(EVENT_MESSAGE);
        } catch (JSONException ex) {
            throw new HelloSignException(ex);
        }
        return eventMessage;
    }
5701
public function getSignature()
    {
        /** @var int $timestamp */
        $timestamp = $this->getTimeStamp();
        $nonceStr  = $this->getnonceStr();
        $ticket    = $this->getTicket();

        $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

        $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

        /** @var array $signature_array */
        $signature_array              = [];
        $signature_array['appId']     = $this->getAppId();
        $signature_array['nonceStr']  = $nonceStr;
        $signature_array['timestamp'] = $timestamp;
        $signature_array['signature'] = $this->getSignatures($ticket, $nonceStr, $timestamp, $url);

        return $signature_array;
    }
1332512
public static function fromSignatureString(string $signature): Signature
    {
        $obj = new self();
        $obj->_signature = strval($signature);
        return $obj;
    }
1156367
protected PrivateKey getSigningPrivateKey() throws Exception {
        val samlIdp = casProperties.getAuthn().getSamlIdp();
        val signingKey = samlIdPMetadataLocator.getSigningKey();
        val privateKeyFactoryBean = new PrivateKeyFactoryBean();
        privateKeyFactoryBean.setLocation(signingKey);
        privateKeyFactoryBean.setAlgorithm(samlIdp.getMetadata().getPrivateKeyAlgName());
        privateKeyFactoryBean.setSingleton(false);
        LOGGER.debug("Locating signature signing key from [{}]", signingKey);
        return privateKeyFactoryBean.getObject();
    }
1260322
@Override
    public SignatureVerifier getSignatureVerifier() throws Exception {
        try {
            HttpEntity<Void> request = new HttpEntity<>(new HttpHeaders());

            String content = restTemplate.exchange(getPublicKeyEndpoint(),
                HttpMethod.GET, request, String.class).getBody();

            if (StringUtils.isEmpty(content)) {
                log.info("Public key not fetched");
                return null;
            }

            InputStream fin = new ByteArrayInputStream(content.getBytes());
            CertificateFactory f = CertificateFactory.getInstance("X.509");
            X509Certificate certificate = (X509Certificate) f.generateCertificate(fin);
            PublicKey pk = certificate.getPublicKey();

            return new RsaVerifier(String.format(PUBLIC_KEY, new String(Base64.getEncoder().encode(pk.getEncoded()))));
        } catch (IllegalStateException ex) {
            log.warn("could not contact Config to get public key");
            return null;
        }
    }
909239
private static Signature getInstanceRSA(Provider p)
            throws NoSuchAlgorithmException {
        // try Signature first
        Service s = p.getService("Signature", RSA_SIGNATURE);
        if (s != null) {
            Instance instance = GetInstance.getInstance(s, SignatureSpi.class);
            return getInstance(instance, RSA_SIGNATURE);
        }
        // check Cipher
        try {
            Cipher c = Cipher.getInstance(RSA_CIPHER, p);
            return new Delegate(new CipherAdapter(c), RSA_SIGNATURE);
        } catch (GeneralSecurityException e) {
            // throw Signature style exception message to avoid confusion,
            // but append Cipher exception as cause
            throw new NoSuchAlgorithmException("no such algorithm: "
                + RSA_SIGNATURE + " for provider " + p.getName(), e);
        }
    }
369911
public function getToken()
    {
        $payload = array(
            $this->serializer->toBase64URL($this->serializer->toJSON($this->headers)),
            $this->serializer->toBase64URL($this->serializer->toJSON($this->claims))
        );

        if ($this->signature !== null) {
            $payload[] = $this->serializer->toBase64URL($this->signature);
        }

        return new Token($this->headers, $this->claims, $this->signature, $payload);
    }
283866
public String signature() {
        if (typeParameters.isEmpty()) {
            return name;
        } else {
            return name + '<' + Joiner.on(", ").join(typeParameters) + '>';
        }
    }
67628
public function getParsedSignature()
    {
        if (Podium::getInstance()->podiumConfig->get('use_wysiwyg') == '0') {
            $parser = new GithubMarkdown();
            $parser->html5 = true;
            return $parser->parse($this->signature);
        }
        return $this->signature;
    }