public function testSigEnc()
 {
     $sc = new BeSimpleSoapClient(__DIR__ . '/Fixtures/WsSecuritySigEnc.wsdl', $this->options);
     $wssFilter = new BeSimpleWsSecurityFilter();
     // user key for signature and encryption
     $securityKeyUser = new BeSimpleWsSecurityKey();
     $securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/clientkey.pem', true);
     $securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/clientcert.pem', true);
     $wssFilter->setUserSecurityKeyObject($securityKeyUser);
     // service key for encryption
     $securityKeyService = new BeSimpleWsSecurityKey();
     $securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
     $securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__ . '/Fixtures/servercert.pem', true);
     $wssFilter->setServiceSecurityKeyObject($securityKeyService);
     // TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
     $wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
     $wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
     $soapKernel = $sc->getSoapKernel();
     $soapKernel->registerFilter($wssFilter);
     $gb = new getBook();
     $gb->isbn = '0061020052';
     $result = $sc->getBook($gb);
     $this->assertInstanceOf('BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\BookInformation', $result->getBookReturn);
     $ab = new addBook();
     $ab->isbn = '0445203498';
     $ab->title = 'The Dragon Never Sleeps';
     $ab->author = 'Cook, Glen';
     $ab->type = 'scifi';
     $this->assertTrue((bool) $sc->addBook($ab));
     // getBooksByType("scifi");
 }
예제 #2
0
 public function testAddPublicKeyNoFile()
 {
     $wsk = new WsSecurityKey();
     $filename = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures/clientcert.pem';
     $wsk->addPublicKey(\ass\XmlSecurity\Key::RSA_SHA1, file_get_contents($filename), false);
     $this->assertTrue($wsk->hasPublicKey());
     $this->assertInstanceOf('ass\\XmlSecurity\\Key', $wsk->getPublicKey());
 }
use BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation;
$options = array('soap_version' => SOAP_1_2, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'trace' => true, 'classmap' => array('getBook' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\getBook', 'getBookResponse' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\getBookResponse', 'getBooksByType' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\getBooksByType', 'getBooksByTypeResponse' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\getBooksByTypeResponse', 'addBook' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\addBook', 'addBookResponse' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\addBookResponse', 'BookInformation' => 'BeSimple\\SoapClient\\Tests\\ServerInterop\\Fixtures\\BookInformation'));
$sc = new BeSimpleSoapClient(__DIR__ . '/Fixtures/WsSecuritySigEnc.wsdl', $options);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
    $wssFilter = new BeSimpleWsSecurityFilter();
    // user key for signature and encryption
    $securityKeyUser = new BeSimpleWsSecurityKey();
    $securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/clientkey.pem', true);
    $securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__ . '/Fixtures/clientcert.pem', true);
    $wssFilter->setUserSecurityKeyObject($securityKeyUser);
    // service key for encryption
    $securityKeyService = new BeSimpleWsSecurityKey();
    $securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
    $securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__ . '/Fixtures/servercert.pem', true);
    $wssFilter->setServiceSecurityKeyObject($securityKeyService);
    // TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
    $wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
    $wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
    $soapKernel = $sc->getSoapKernel();
    $soapKernel->registerFilter($wssFilter);
    $gb = new getBook();
    $gb->isbn = '0061020052';
    $result = $sc->getBook($gb);
    var_dump($result->getBookReturn);
    $ab = new addBook();
    $ab->isbn = '0445203498';
    $ab->title = 'The Dragon Never Sleeps';
    $ab->author = 'Cook, Glen';
    $ab->type = 'scifi';
}
class BookInformation
{
}
$options['classmap'] = array('getBook' => 'getBook', 'getBookResponse' => 'getBookResponse', 'getBooksByType' => 'getBooksByType', 'getBooksByTypeResponse' => 'getBooksByTypeResponse', 'addBook' => 'addBook', 'addBookResponse' => 'addBookResponse', 'BookInformation' => 'BookInformation');
$sc = new BeSimpleSoapClient('WsSecuritySigEnc.wsdl', $options);
$wssFilter = new BeSimpleWsSecurityFilter();
// user key for signature and encryption
$securityKeyUser = new BeSimpleWsSecurityKey();
$securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, 'clientkey.pem', true);
$securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, 'clientcert.pem', true);
$wssFilter->setUserSecurityKeyObject($securityKeyUser);
// service key for encryption
$securityKeyService = new BeSimpleWsSecurityKey();
$securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC);
$securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, 'servercert.pem', true);
$wssFilter->setServiceSecurityKeyObject($securityKeyService);
// TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1
$wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN);
$wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);
//var_dump($sc->__getFunctions());
//var_dump($sc->__getTypes());
try {
    $gb = new getBook();
    $gb->isbn = '0061020052';
    var_dump($sc->getBook($gb));
    $ab = new addBook();
    $ab->isbn = '0445203498';
    $ab->title = 'The Dragon Never Sleeps';