Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 70... Línea 70...
70
     *                                          policy.
70
     *                                          policy.
71
     *
71
     *
72
     * @return array The values needed to construct a signed URL or cookie
72
     * @return array The values needed to construct a signed URL or cookie
73
     * @throws \InvalidArgumentException  when not provided either a policy or a
73
     * @throws \InvalidArgumentException  when not provided either a policy or a
74
     *                                    resource and a expires
74
     *                                    resource and a expires
-
 
75
     * @throws \RuntimeException when generated signature is empty
75
     *
76
     *
76
     * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-cookies.html
77
     * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-cookies.html
77
     */
78
     */
78
    public function getSignature($resource = null, $expires = null, $policy = null)
79
    public function getSignature($resource = null, $expires = null, $policy = null)
79
    {
80
    {
Línea 111... Línea 112...
111
    }
112
    }
Línea 112... Línea 113...
112
 
113
 
113
    private function sign($policy)
114
    private function sign($policy)
114
    {
115
    {
-
 
116
        $signature = '';
115
        $signature = '';
117
        
-
 
118
        if(!openssl_sign($policy, $signature, $this->pkHandle)) {
-
 
119
            $errorMessages = [];
-
 
120
            while(($newMessage = openssl_error_string()) !== false) {
-
 
121
                $errorMessages[] = $newMessage;
-
 
122
            }
-
 
123
            
-
 
124
            $exceptionMessage = "An error has occurred when signing the policy";
-
 
125
            if (count($errorMessages) > 0) {
-
 
126
                $exceptionMessage = implode("\n", $errorMessages);
-
 
127
            }
-
 
128
 
-
 
129
            throw new \RuntimeException($exceptionMessage);
Línea 116... Línea 130...
116
        openssl_sign($policy, $signature, $this->pkHandle);
130
        }
117
 
131
 
Línea 118... Línea 132...
118
        return $signature;
132
        return $signature;