Beispiel #1
0
 protected function verifySignature()
 {
     $publicAccountKey = PublicKey::formatPEM(SocialRecordManager::retrieveSocialRecord($this->headers[SONIC_HEADER__SOURCE_GID])->getAccountPublicKey());
     if (!Signature::verifySignature($this->getStringForRequestSignature(), $publicAccountKey, $this->headers[SONIC_HEADER__SIGNATURE])) {
         throw new MalformedRequestHeaderException("Invalid request signature!");
     } else {
         return true;
     }
 }
 /**
  * Sends a SocialRecord to the GSLS. The SocialRecord is updated/overwritten if it already exists. Otherwise, the
  * new SocialRecord is stored. In case of a failed ateempt to (over-)write a SocialRecord, an Exception is thrown.
  * 
  * @param $entityAuthData EntityAuthData The EntityAuthData object for the SocialRecord to be pushed. The personal
  * key pair must be configured
  */
 public static function pushToGSLS(EntityAuthData $entityAuthData)
 {
     if ($entityAuthData->getPersonalKeyPair() == NULL) {
         throw new \Exception('SocialRecord can only be pushed with PersonalKeyPair configured');
     }
     if (SocialRecordManager::socialRecordExists($entityAuthData->getGlobalID())) {
         GSLS::putSocialRecord($entityAuthData->getSocialRecord(), $entityAuthData->getPersonalKeyPair()->getPrivateKey());
     } else {
         GSLS::postSocialRecord($entityAuthData->getSocialRecord(), $entityAuthData->getPersonalKeyPair()->getPrivateKey());
     }
 }
 public function __construct($targetGID)
 {
     if (!GID::isValid($targetGID)) {
         throw new MalformedRequestException('Invalid GlobalID: [' . $targetGID . ']');
     }
     $this->targetGID = $targetGID;
     try {
         $this->targetSocialRecord = SocialRecordManager::retrieveSocialRecord($this->targetGID);
     } catch (\Exception $e) {
         throw new MalformedRequestException('Could not resolve GlobalID: [' . $this->targetGID . ']');
     }
 }
Beispiel #4
0
 public function __construct()
 {
     $this->platformSR = SocialRecordManager::importSocialRecord($this->platformSRjson);
     $this->platformSocialRecord = $this->platformSR['socialRecord'];
     $this->platformAccountKeyPair = $this->platformSR['accountKeyPair'];
     $this->platformPersonalKeyPair = $this->platformSR['personalKeyPair'];
     $this->aliceSR = SocialRecordManager::importSocialRecord($this->aliceSRjson);
     $this->aliceSocialRecord = $this->aliceSR['socialRecord'];
     $this->aliceAccountKeyPair = $this->aliceSR['accountKeyPair'];
     $this->alicePersonalKeyPair = $this->aliceSR['personalKeyPair'];
     $this->sonic = Sonic::initInstance(new EntityAuthData($this->platformSocialRecord, $this->platformAccountKeyPair, $this->platformPersonalKeyPair));
     Sonic::setUserAuthData(new EntityAuthData($this->aliceSocialRecord, $this->aliceAccountKeyPair));
     Sonic::setContext(Sonic::CONTEXT_USER);
 }
Beispiel #5
0
 public function testSonic()
 {
     $platformSR = SocialRecordManager::importSocialRecord($this->platformSRjson);
     $platformSocialRecord = $platformSR['socialRecord'];
     $platformAccountKeyPair = $platformSR['accountKeyPair'];
     $platformPersonalKeyPair = $platformSR['personalKeyPair'];
     $aliceSR = SocialRecordManager::importSocialRecord($this->aliceSRjson);
     $aliceSocialRecord = $aliceSR['socialRecord'];
     $aliceAccountKeyPair = $aliceSR['accountKeyPair'];
     $alicePersonalKeyPair = $aliceSR['personalKeyPair'];
     $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair));
     $this->assertEquals($platformSocialRecord->getGlobalID(), Sonic::getContextGlobalID());
     Sonic::setUserAuthData(new EntityAuthData($aliceSocialRecord, $aliceAccountKeyPair));
     Sonic::setContext(Sonic::CONTEXT_USER);
     $this->assertEquals($aliceSocialRecord->getGlobalID(), Sonic::getContextGlobalID());
 }
<?php

namespace sgoendoer\Sonic\examples;

require_once __DIR__ . '/../vendor/autoload.php';
use sgoendoer\Sonic\Sonic;
use sgoendoer\Sonic\Identity\EntityAuthData;
use sgoendoer\Sonic\Identity\SocialRecordManager;
try {
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // importing SocialRecord objects to work with
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // load SocialRecords from files to instatiaze the Sonic framework
    $srp = SocialRecordManager::importSocialRecord(file_get_contents(__DIR__ . '/data/SRPlatform.json'));
    $platformSocialRecord = $srp['socialRecord'];
    $platformAccountKeyPair = $srp['accountKeyPair'];
    $platformPersonalKeyPair = $srp['personalKeyPair'];
    $sra = SocialRecordManager::importSocialRecord(file_get_contents(__DIR__ . '/data/SRAlice.json'));
    $userSocialRecord = $sra['socialRecord'];
    $userAccountKeyPair = $sra['accountKeyPair'];
    $userPersonalKeyPair = $sra['personalKeyPair'];
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // initializing Sonic SDK
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // instantiaze the Sonic framework with the platform's SocialRecord
    $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair));
    Sonic::setUserAuthData(new EntityAuthData($userSocialRecord, $userAccountKeyPair));
    Sonic::setContext(Sonic::CONTEXT_USER);
} catch (\Exception $e) {
    die($e->getMessage() . "\n\n" . $e->getTraceAsString());
}
try {
    $platformSR = '{"socialRecord":{"@context":"http://sonic-project.net/","@type":"socialrecord","type":"platform","globalID":"2UZCAI2GM45T160MDN44OIQ8GKN5GGCKO96LC9ZOQCAEVAURA8","platformGID":"2UZCAI2GM45T160MDN44OIQ8GKN5GGCKO96LC9ZOQCAEVAURA8","displayName":"social.snet.tu-berlin.de","profileLocation":"http://social.snet.tu-berlin.de/sonic-sdk/","personalPublicKey":"-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtKXJWNeV1ld7oSXWelgeJlJSabwL2YN0f3tg6ZPEf3mlmt7e+PpBHp8ECsbZlkcKvRuoDxy+7YSFoPcy0nACrPVw4xX+9+fSvJQXlM/3yNi30U/VvdUBaWBzxuI7IAqoUYSV5dVA4FFgHlIOIDktQeQmz+Ob06cxRg2TgqOjaaERkC1tTc0TO4UsqQOfl03IPc0ZrVyuHTWZd/Cc/UE9LRhJvZ/eV4OgZL0f5rJXD3N9XyKsd6npRTJPEBqj1ixNKzBiP8tvkD23FUGdOFpiUq3eLmIoxljWw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YuAz0lEbeYRMuSBsPJ12nXc2BB3N2wyp+cyZ2KDnDJQO246bPDQTIm+P1pzXCnWdo54wJmD10g/E10pfY1SYsXM+XEV/tobwJXECAwEAAQ==-----END PUBLIC KEY-----","salt":"82daf2b77b46f36d","datetime":"2016-01-13T10:58:52+01:00","active":1,"keyRevocationList":[]},"accountPrivateKey":"-----BEGIN PRIVATE KEY-----MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCc7+lXWFFsAVnrk6EGvzjfGbki7bTQ6kjf0AOGmkpwfzutXRI+9EV81coYy3RQ9/ph5gBqBaC+b6j5ie7qNvS7d6/1s9uW8zqvhLKP6T1J8INLdC9UuItQT9Xke3y1b99zIamCD7oZi8GSwPRD6R6wta1tB0vH+bi3F2Iju1WSZrnTg/hdL5fTK8ip0LyOHm36ZIGR3D2a01/9zXRW+zaKMFzf2o8gGQDusTvbhyDa4+ivxNaCybetnhkIJj+XBuEN8PE9tBsS1YKr3iSz36aiLXElM/T3rzwqa4VfkaPC1iXjMv3qbN70HUtetDqQkFkR/x+lpYBIfojE0w0L5Te/tj8TQIjajJ81Xk7rDori7dr+sZdmAhe4710d8HqsxKmjHY4vuZtj7sf9/zoBtdZlYZeambgJoibKz0L0FpQXV/ke+3dlAevWj6qf5ISayN8A2iCyKwKjLyvVzAFRj2tQ4gWjxMcRzozz4TpDGLd4rtg2swm9qxaHlYfkAbh16PKXOggpBxHrloGXmNQjNVVgt8/E/oPmp8BOqcQgbGFvc1pI2us8sPES+UdVZ4g90FFJlEnBc5Fi4DPSURt5hEy5IGw8nXaddzYEHc3bDKn5zJnYoOcMlA7bjps8NBMib4/WnNcKdZ2jnjAmYPXSD8TXSl9jVJixcz5cRX+2hvAlcQIDAQABAoICAHrNOFfCoiPTgttV78DpzMS2yinMu5pmWZPYn4mqHemdhcMIewiL9/vRBo0UVvYstN36LgTIVpntodlx12OqkSJIa4XlsUSTGy7QtTDrH6xF6VcXmRnANjMn5YUeI92NptneU1e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LyLK4hvpkuwl9WmIod4X80yKiJVWt6/maEsPVSc9zvr+FBSxoiSXMMyq88/D6lXkcGI0x/XG9NCcAdLBQrj1ERkimgdN9iCdWfK+MLh7BX3j6BFPnWnOwwaw==-----END PRIVATE KEY-----"}';
    $aliceSR = '{"socialRecord":{"@context":"http://sonic-project.net/","@type":"socialrecord","type":"user","globalID":"4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7","platformGID":"2UZCAI2GM45T160MDN44OIQ8GKN5GGCKO96LC9ZOQCAEVAURA8","displayName":"Alice","profileLocation":"http://social.snet.tu-berlin.de/sonic-sdk/","personalPublicKey":"-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzMp0mukaLQl2Ya0RmZKtioXx3gifTe6Bu2UUsrOgwd/SHB3g438pcJBqF8pvPKKhx0hgp8MX1W3IGyqsNsIbFF2b4r9VrtDqUUd0WBCKsvBNcqxfqWkez2kVB+Q3hQkOjyocuO8I6v1rvkFNsio0E9XLPcLOiYJL3qHrbQFI+qtshfgjeK9taZbrEX6uY4VQ602fb8dHK9ieCV/W46RCTQS4+ac1+y1CAyH7gQ5TPMZ2vraeLR4kA1r8l/u3ZhB8b8biMt81K/WVcEf+8K4LAi/Tub1uDowKU2HNveG5ov055hvbvYv/9z1kEFGpTEMOzl0hiK4DGkvpugVO9nUfyy7VA85ZgkBpY4WoHGoZQbubyBsMwqpmT1pkUwAQTKnv6ME1YLLY81YjeshQz+YezT/gqH0uC3a+ZcQotFanNyTvQrtjxQSqeOA87K1RwfJvn9QS4Lz3MMt8eSK1/H+aFavDBARgzAGPgDRBTtjKSvdImZ1g5zd9pItzGV9ZcasvTY3/m6U5L9ByiiFEHLQJr9eKBb0OAoQVG9G5vYQ1f1CF7OtYQA2L0ygc4TwwLCjILBJDoqiOuYgq/wVzE1200G1tQ504hLdaUJIETCLxvDhyMI3TbywxLSyihYjC3Tge68X+rKPgZoY4ahTok0CszOzYf4lDsYmKAPIVDH5C5AECAwEAAQ==-----END PUBLIC KEY-----","accountPublicKey":"-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvgeptoYIVDvxPPIk4ZBpRy/SohpJPTHSguP3VjWG0xL8zllZSkdBLS1ijBGCxG/jx5KebBSLSkIAjEdby0/FKRjLTBqC7eak6s/1zUUzoABXwu/JckAToOJK5R/iSwAd5jOa94Bl6q7Pu6kfBsDSg43JOkIU0rvfMNcgdo/9GJwI2tg6/ZjM5YWNoRcHvl2XXM0lljJrxfVlXpWNhTUUoy/IrnyPhBlhHCXtbCVo/U5gQ5O6ymqwewRyWwhfvaWrWiwAW6KnvBz3ddCmjBArerOciVtcSXRoJ01jQP4HeDTzQDxvDb4ymAewfoRuzp0ctL4tMMS8P+XxpQmNrivZP+thwEM+jB8XLkbFB1Pj0aTdQzCkrJupiSz8mK5aBBptjPsek50egoOEyf5LY3y/daup5rbLFLE58pNO13GdtDiin0NDVwrC19uKrvy5vca/+O1lZjTaVNrP9FN9ug2wZ62N7Q6vyZT0H+7wkdbGWeKhxMa1j05dx0v61dp91k6N4wWXEeAknLw06FrCKicKjA6LQIVrT9KYjWDI9ewwaoKbRyrKJrHNoZg1+Mua+x3TWsXAEGE91+Mgdd0UZQ+XBihjyq76ccZULbzJ/flGeOyVUMwXg05QNT6zXRDyNUPUyb8HoI0kHlT8nRDF9kkKu2Yx40EhsrAQogoEqgxeYoUCAwEAAQ==-----END PUBLIC KEY-----","salt":"abb0afd289f102f3","datetime":"2016-01-13T10:58:54+01:00","active":1,"keyRevocationList":[]},"accountPrivateKey":"-----BEGIN PRIVATE KEY-----MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC+B6m2hghUO/E88iThkGlHL9KiGkk9MdKC4/dWNYbTEvzOWVlKR0EtLWKMEYLEb+PHkp5sFItKQgCMR1vLT8UpGMtMGoLt5qTqz/XNRTOgAFfC78lyQB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RxA65KGjk27DYwtfGth/BIr6zzhaNyZOHJe983EO3jvOxS877xDc5gILwzTECcGSIODA4dfvX8EDqeVT5VK49GLBbj48z3Md6H8M/c40lfTuuERSYdDB4/VuOYwbXvniJvQCkRzxqmtai+4be8T7PbcdzW99uPR3wtCeW3gub7BNNTc7AoIBABFaKJHZHQ56+lZfhd9fZRFAqDmcvLvDNMGbEcdD4Y0uWXiAFKLvTao0v60wrtibz7ZJr7m86XS4dKStr1lFN6QFpFeryZQT8intQud9DsW8DVb/9vJ4Lor32cnVpG37cU9tsmMBq7Iyo5wueWTA8watAsoJLcqzHe3crHzawQDsgZXDArEw2SR+wCjtRLUjqclq8S3C4InqiONPQzOP2/aA5Xch641RBl0Xx4IbOMWaKufr1rFG9IYiz1L9flkbnEFZjIEj3T3rrEWnI/tMDvP3Dm73TH9gbZUjKFinKaIE4ijDgX5+iuHsZHv15ky806HrtJs9K09X8W/j29FugJ8CggEAXeDzML3vNiaWnNTN9e39kG574ni7lWTgixK9Hqx4dmDk1FXfNwtpKKyjurtjCn0nihUPfUcuFrQzirma2nQcqsfrbn4FjcDvzjeioiQS0jjGMqAm39CATIIWBtifQiv9ukyOn5K36T4J6VxJ42Nxq2m3oVSLlT8bMkQApPszHjgK1zjPF0j2G2Co/S1DwL6LHy67iGhGu5ghJqZWysepaERDXelJMUGJ6CRit7ekKS9Y5dnLdMpy5kitptvIoy3KSQ4YLzmY8UrkQ7m5W1o319oMVHjUAg90xhldbfuUoT4z57M80Hj8+/NSzbaSrfGoVb7GlAhHY0BktlSp4Z4Hww==-----END PRIVATE KEY-----","personalPrivateKey":"-----BEGIN PRIVATE KEY-----MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDMynSa6RotCXZhrRGZkq2KhfHeCJ9N7oG7ZRSys6DB39IcHeDjfylwkGoXym88oqHHSGCnwxfVbcgbKqw2whsUXZviv1Wu0OpRR3RYEIqy8E1yrF+paR7PaRUH5DeFCQ6PKhy47wjq/W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Xb2PUWUYd2YtT5TlCh6QwPA0VqqotcOMrXjqSJOX5nj6a3dXkl5VZ+s8aRMnTViQ+0ZFan6FqV042XuQbs9Yp6ctynzmZo7YY3TgayrioUGN+JaQxd0XkcY/DFh4BnBvby08N2tTwyrAoIBAQC8DY2ZW3Nc8RyFapMygi/fpLeOqnt7uX9t8qK9HMvQ89dPOaRcmKX2Dg7hLB63aJiuInSlAsmBhLqgMV1FXkZ5pF2wT8Wreqe8EPXXPj2uGO4Upnej/JJ+JcprEC4gKc/0OIwZp7PkNZm4drrk8RLmmsFgaXngRmiS3xPJ73eEvpjouuXtVrk2JhC243KOHYl8O8L4zIIYe6WGpFtYvt+u1Ufi0qrFDDsHrtr8kNbwYiRVARvSW2lsUxu94crDfNJP0f27/iFouqlvVeT5w9msnZ9oBwhM84yImab7y5IBGwmyOxgR1kvZKk5Eap+4E8LTWOZVZ1OkMQ0FKH2n7QgLAoIBAFQJf839Cku/9+uDMptxPihgyU6xrUa1PGXoVy+z5RQMCmv4xnp7CaogtCFoDaiKEE36JEVDwVE/V+Bn4hXTtoS3rJurYLVILnu+p7iKTx8A9c1lqCMeHCUxMHMvyySVMrB0PbbatBbRi+rsIAUHi+jdvarym3GdOpdAkWs2vkmqKjt7rhSxF+YCmaIlwYG1QF9rvPu6lqy5X6GT2tPtsMnPvIxYCFwtfW3Zca40ULNNFR59LGbFcLtJE/ydF4pOb8XEeBvW3zcGD7bmDETlx2n7FFq8zUVBcR2ekNpwE2n7gzU9oUaUs3k0STDDlC7IHYyQQkjttDVYvKnIvpukBJA=-----END PRIVATE KEY-----"}';
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // creating SocialRecord object to work with
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    echo "Initializing platform SocialRecord... ";
    // Init with imported SocialRecord $sr /////////////////////////////////////////////////////////////////////////////
    $sr = SocialRecordManager::importSocialRecord($platformSR);
    $platformSocialRecord = $sr['socialRecord'];
    $platformAccountKeyPair = $sr['accountKeyPair'];
    $platformPersonalKeyPair = $sr['personalKeyPair'];
    echo "done!\n";
    echo "Initializing user SocialRecord... ";
    // Init with imported SocialRecord $sr /////////////////////////////////////////////////////////////////////////////
    $sr = SocialRecordManager::importSocialRecord($aliceSR);
    $userSocialRecord = $sr['socialRecord'];
    $userAccountKeyPair = $sr['accountKeyPair'];
    $userPersonalKeyPair = $sr['personalKeyPair'];
    echo "done!\n";
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // initializing Sonic SDK
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    echo "Initializing SONIC SDK... ";
    $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair));
    Sonic::setUserAuthData(new EntityAuthData($userSocialRecord, $userAccountKeyPair));
    Sonic::setContext(Sonic::CONTEXT_USER);
    echo "done!\n";
} catch (\Exception $e) {
    echo "\n\n>> Exception >> \n\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString() . "\n\n";
}
Beispiel #8
0
 protected function verifySignature()
 {
     $socialRecord = SocialRecordManager::retrieveSocialRecord($this->headers[SONIC_HEADER__SOURCE_GID]);
     if ($this->expectedGID !== NULL) {
         if ($this->headers[SONIC_HEADER__SOURCE_GID] != $this->expectedGID && $this->headers[SONIC_HEADER__SOURCE_GID] != $socialRecord->getPlatformGID()) {
             throw new MalformedRequestHeaderException('Request signature from unexpected source GID. Expected [' . $this->expectedGID . '] found [' . $this->headers[SONIC_HEADER__SOURCE_GID] . ']');
         }
     }
     if (!Signature::verifySignature($this->getStringForResponseSignature(), $socialRecord->getAccountPublicKey(), $this->headers[SONIC_HEADER__SIGNATURE])) {
         throw new MalformedRequestHeaderException("Invalid response signature");
     } else {
         return true;
     }
 }
 public function verify()
 {
     $personalPublicKey = SocialRecordManager::retrieveSocialRecord($this->globalID)->getPersonalPublicKey();
     return Signature::verifySignature($this->getStringForSignature(), $personalPublicKey, $this->signature);
 }