/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(PrivateKeyCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($arrCredentials as $credential) { if ($credential->getPrivateKey()) { $result[] = $credential; } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(X509CredentialCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($arrCredentials as $credential) { if ($credential instanceof X509CredentialInterface) { $result[] = $credential; } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(UsageCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($criteriaSet->get(UsageCriteria::class) as $criteria) { /* @var UsageCriteria $criteria */ foreach ($arrCredentials as $credential) { if (false == $credential->getUsageType() || $criteria->getUsage() == $credential->getUsageType()) { $result[] = $credential; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(AlgorithmCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($criteriaSet->get(AlgorithmCriteria::class) as $criteria) { /* @var AlgorithmCriteria $criteria */ foreach ($arrCredentials as $credential) { if ($credential->getPrivateKey() && $credential->getPrivateKey()->getAlgorith() == $criteria->getAlgorithm() || $credential->getPublicKey() && $credential->getPublicKey()->getAlgorith() == $criteria->getAlgorithm()) { $result[] = $credential; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(PublicKeyThumbprintCriteria::class)) { return $arrCredentials; } $result = array(); /** @var PublicKeyThumbprintCriteria $criteria */ foreach ($criteriaSet->get(PublicKeyThumbprintCriteria::class) as $criteria) { foreach ($arrCredentials as $credential) { if ($credential->getPublicKey() && $credential->getPublicKey()->getX509Thumbprint() == $criteria->getThumbprint()) { $result[] = $credential; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param EndpointReference[] $candidates * * @return EndpointReference[] */ public function resolve(CriteriaSet $criteriaSet, array $candidates) { if (false === $criteriaSet->has(LocationCriteria::class)) { return $candidates; } $result = array(); /** @var LocationCriteria $locationCriteria */ foreach ($criteriaSet->get(LocationCriteria::class) as $locationCriteria) { foreach ($candidates as $endpointReference) { if ($endpointReference->getEndpoint()->getLocation() == $locationCriteria->getLocation()) { $result[] = $endpointReference; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param EndpointReference[] $candidates * * @return EndpointReference[] */ public function resolve(CriteriaSet $criteriaSet, array $candidates) { if (false === $criteriaSet->has(ServiceTypeCriteria::class)) { return $candidates; } $result = array(); /** @var ServiceTypeCriteria $serviceTypeCriteria */ foreach ($criteriaSet->get(ServiceTypeCriteria::class) as $serviceTypeCriteria) { foreach ($candidates as $endpointReference) { $type = $serviceTypeCriteria->getServiceType(); if ($endpointReference->getEndpoint() instanceof $type) { $result[] = $endpointReference; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(MetadataCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($criteriaSet->get(MetadataCriteria::class) as $criteria) { /* @var MetadataCriteria $criteria */ foreach ($arrCredentials as $credential) { /** @var MetadataCredentialContext $metadataContext */ $metadataContext = $credential->getCredentialContext()->get(MetadataCredentialContext::class); if (false == $metadataContext || $criteria->getMetadataType() == MetadataCriteria::TYPE_IDP && $metadataContext->getRoleDescriptor() instanceof IdpSsoDescriptor || $criteria->getMetadataType() == MetadataCriteria::TYPE_SP && $metadataContext->getRoleDescriptor() instanceof SpSsoDescriptor) { $result[] = $credential; } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param EndpointReference[] $candidates * * @return EndpointReference[] */ public function resolve(CriteriaSet $criteriaSet, array $candidates) { if (false === $criteriaSet->has(IndexCriteria::class)) { return $candidates; } $result = array(); /** @var IndexCriteria $indexCriteria */ foreach ($criteriaSet->get(IndexCriteria::class) as $indexCriteria) { foreach ($candidates as $endpointReference) { $endpoint = $endpointReference->getEndpoint(); if ($endpoint instanceof IndexedEndpoint) { if ($endpoint->getIndex() == $indexCriteria->getIndex()) { $result[] = $endpointReference; } } } } return $result; }
/** * @param CriteriaSet $criteriaSet * @param CredentialInterface[] $arrCredentials * * @return CredentialInterface[] */ public function resolve(CriteriaSet $criteriaSet, array $arrCredentials = array()) { if (false == $criteriaSet->has(CredentialNameCriteria::class)) { return $arrCredentials; } $result = array(); foreach ($criteriaSet->get(CredentialNameCriteria::class) as $criteria) { /* @var CredentialNameCriteria $criteria */ foreach ($arrCredentials as $credential) { $arrCredentialNames = $credential->getKeyNames(); $criteriaName = $criteria->getName(); foreach ($arrCredentialNames as $credentialName) { if ($credentialName == $criteriaName) { $result[] = $credential; break; } } } } return $result; }
/** * @param \PHPUnit_Framework_TestCase $test * @param CriteriaSet $criteriaSet * @param string $class * @param string $getter * @param string $value */ public static function assertCriteria(\PHPUnit_Framework_TestCase $test, CriteriaSet $criteriaSet, $class, $getter, $value) { $test->assertTrue($criteriaSet->has($class)); $criteria = $criteriaSet->getSingle($class); if ($getter) { $test->assertEquals($value, $criteria->{$getter}()); } }
/** * @param CriteriaSet $criteriaSet * @param string $value */ protected function criteriaSetShouldHaveLocationCriteria(CriteriaSet $criteriaSet, $value) { if ($value) { $this->assertTrue($criteriaSet->has(LocationCriteria::class)); /** @var LocationCriteria $criteria */ $criteria = $criteriaSet->getSingle(LocationCriteria::class); $this->assertEquals($value, $criteria->getLocation()); } else { $this->assertFalse($criteriaSet->has(LocationCriteria::class)); } }