Creates a new Signature object from its Soap counterpart.

@internal

@param SignatureInfo $info

@return Signature
181675
public static function createFromSoap(SignatureInfo $info)
    {
        $signature = new static();
        $signature->id = $info->Id;
        $signature->seal();

        return $signature;
    }
721678
public static function createFromUnsignedJwt(UnsignedJwt $unsignedJwt, string $signature) : SignedJwt
    {
        return new self($unsignedJwt->getHeader(), $unsignedJwt->getPayload(), $signature);
    }
1158334
protected function createTable(Infoset $info) {
		$table = new Table();
		$table->addClass('content-table');
		
		if ($info instanceof InfosetTable) {
			if (($widths = $info->getColsWidths()) !== null) {
				$table->getColgroup()->addElements($widths);
			}
			
			if (($headRow = $info->getHeadContent()) !== null) {
				$table->getHead()->addElement($headRow);
			}
		}
		
		foreach ($info as $row) {
			if (! is_array($row) && ! $row instanceof Traversable) {
				throw new InvalidContent('Table row content must be an array or a Traversable implementation');
			}
			
			$cols = [];
			
			foreach ($row as $content) {
				if ($content instanceof Infoset) {
					$content = $this->createContent($content);
				}
				
				$content = $this->specialCharsHandle($content);
				
				if ($info->isContentBbCodes()) {
					$content = $this->bbCodesHandle($content);
				}
				
				$cols[] = $content;
			}
			
			if ($row instanceof Row && $row->isMarked()) {
				$cols['_class_'] = $row->getMark();
			}
			
			$table[] = $cols;
		}
		
		return $table->render();
	}
301012
private function buildAuthHeader() {
		$auth_params = array(
			'user' => $this->getCredentials()->getUser(),
			'signature' => $this->getCredentials()->getSignature(),
			'type' => 0
		);

		return new SoapHeader(self::DHL_SOAP_HEADER_URI, 'Authentification', $auth_params);
	}
329315
protected function createTitle(Infoset $info) {
		preg_match('/([0-9\.]+)/i', phpversion(), $matches);
		$title = 'PHP ' . $matches[1];
		
		if (extension_loaded('xdebug')) {
			$title .= ' / [alert]xdebug[/alert]';
		}
		
		if (extension_loaded('apc')) {
			$title .= ' / [success]apc[/success]';
		}
		
		if (extension_loaded('Zend OPcache')) {
			$title .= ' / [success]opcache[/success]';
		}
		
		$info->setTitle($title);
	}
112091
def sign(xml, private, public):
    '''
    
    '''
    xml = xml.encode('utf-8', 'xmlcharrefreplace')
    signed_info_xml = _generate_signed_info(xml)

    signer = PKCS1_v1_5.PKCS115_SigScheme(private)
    signature_value = signer.sign(SHA.new(c14n(signed_info_xml)))

    signature_xml = PTN_SIGNATURE_XML % {
        'signed_info_xml': signed_info_xml,
        'signature_value': binascii.b2a_base64(signature_value)[:-1],
        'key_info_xml': _generate_key_info_xml_rsa(public.key.n, public.key.e)
    }

    position = xml.rfind('</')
    return xml[0:position] + signature_xml + xml[position:]
1145803
public static void signToInfo(String info, String signfile) {
		// 从文件当中读取私匙
		PrivateKey myprikey = (PrivateKey) getObjFromFile("mykeys.bat", 1);
		// 从文件中读取公匙
		PublicKey mypubkey = (PublicKey) getObjFromFile("mykeys.bat", 2);
		try {
			// Signature 对象可用来生成和验证数字签名
			Signature signet = Signature.getInstance("DSA");
			// 初始化签署签名的私钥
			signet.initSign(myprikey);
			// 更新要由字节签名或验证的数据
			signet.update(info.getBytes());
			// 签署或验证所有更新字节的签名，返回签名
			byte[] signed = signet.sign();
			// 将数字签名,公匙,信息放入文件中
			doObjToFile(signfile, new Object[] { signed, mypubkey, info });
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
700192
public function make($identifier, $expireTime = 3600)
    {
        $json = [
            'TLS.account_type' => $this->accountType,
            'TLS.identifier' => (string)$identifier,
            'TLS.appid_at_3rd' => (string)$this->appId,
            'TLS.sdk_appid' => (string)$this->appId,
            'TLS.expire_after' => (string)$expireTime,
            'TLS.version' => '201512300000',
            'TLS.time' => (string)time()
        ];

        $content = $this->genSignatureContent($json);
        $signature = $this->makeSignature($content);
        $json['TLS.sig'] = base64_encode($signature);
        if ($json['TLS.sig'] === false) {
            throw new SignatureException('base64_encode error.');
        }
        $json_text = json_encode($json);
        if ($json_text === false) {
            throw new SignatureException('json_encode error.');
        }
        $compressed = gzcompress($json_text);
        if ($compressed === false) {
            throw new SignatureException('gzcompress error.');
        }
        return $this->base64Encode($compressed);

    }
789570
public static function fallback($info) {
        $user = isset($info['user']) ? $info['user'] : null;
        $publicKey = isset($info['publicKey']) ? $info['publicKey'] : null;

        if (!$user && $publicKey) {
            $info['user'] = $publicKey;
        } else if (!$publicKey && $user) {
            $info['publicKey'] = $user;
        }

        return $info;
    }
233842
public function setMunimentSignature(\Core\Entity\MunimentSignature $muniment_signature = null) {
        $this->muniment_signature = $muniment_signature;

        return $this;
    }
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);
    }
1332512
public static function fromSignatureString(string $signature): Signature
    {
        $obj = new self();
        $obj->_signature = strval($signature);
        return $obj;
    }
270951
public function createAuthHeader()
    {
        if ($this->timestamp === null) {
            $this->setTimestamp();
        }

        if (!$this->timestamp->isValid()) {
            throw new InvalidSignDataException('Timestamp is invalid. Too old?');
        }

        if ($this->nonce === null) {
            $this->nonce = new Nonce();
        }

        $auth_header =
            'EG1-HMAC-SHA256 ' .
            'client_token=' . $this->auth['client_token'] . ';' .
            'access_token=' . $this->auth['access_token'] . ';' .
            'timestamp=' . $this->timestamp . ';' .
            'nonce=' . $this->nonce . ';';

        return $auth_header . 'signature=' . $this->signRequest($auth_header);
    }
177657
public function add(AttachmentCreationInformation $information)
    {
        $attachment = new Attachment($this->getContext(),$this->getResourcePath());
        $qry = new InvokePostMethodQuery(
            $this->getResourcePath(),
            "add",
            array("FileName" =>rawurlencode($information->FileName)),
            $information->ContentStream);
        $this->getContext()->addQuery($qry,$attachment);
        $this->addChild($attachment);
        return $attachment;
    }
1090626
protected function createContent(Infoset $info) {
		foreach ($this->errors as $error) {
			if (isset(self::$errorTypes[$error['type']])) {
				$type = self::$errorTypes[$error['type']];
			} else {
				$type = 'Uncnown';
			}

			$info[] = sprintf($this->errorTemplate, $type, $error['message'], $error['file'], $error['line']);
		}
	}
1216865
public static function Rrsig($typeCovered, $algorithm, $labels, $originalTtl,
                          $signatureExpiration, $signatureInception, $keyTag,
                          $signersName, $signature)
    {
        $rdata = new RRSIG();
        $rdata->setTypeCovered($typeCovered);
        $rdata->setAlgorithm($algorithm);
        $rdata->setLabels($labels);
        $rdata->setOriginalTtl($originalTtl);
        $rdata->setSignatureExpiration($signatureExpiration);
        $rdata->setSignatureInception($signatureInception);
        $rdata->setKeyTag($keyTag);
        $rdata->setSignersName($signersName);
        $rdata->setSignature($signature);

        return $rdata;
    }
33594
public function createSign($data = '')
    {
        if (!is_string($data)) {
            return null;
        }
        return openssl_sign(
                    $data,
                    $sign,
                    self::getPrivateKey(),
                    OPENSSL_ALGO_SHA256
                  ) ? base64_encode($sign) : null;
    }