| Conditions | 4 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | public function getByEntityId($entityId) |
||
| 25 | { |
||
| 26 | $qb = $this->pool->getQueryBuilderForTable('tx_mksamlauth_domain_model_identityprovider'); |
||
| 27 | $qb->select('*'); |
||
| 28 | $qb->from('tx_mksamlauth_domain_model_identityprovider'); |
||
| 29 | $qb->where($qb->expr()->eq('idp_entity_id', '?')); |
||
| 30 | $qb->setMaxResults(1); |
||
| 31 | $qb->setParameters([$entityId]); |
||
| 32 | |||
| 33 | if (false === $stmt = $qb->execute()) { |
||
|
|
|||
| 34 | return []; |
||
| 35 | } |
||
| 36 | |||
| 37 | if (false === $row = $stmt->fetch()) { |
||
| 38 | return []; |
||
| 39 | } |
||
| 40 | |||
| 41 | $certificate = new X509Certificate(); |
||
| 42 | $certificate->loadPem($row['certificate']); |
||
| 43 | |||
| 44 | $privateKey = null; |
||
| 45 | if (0 < \strlen($row['cert_key'])) { |
||
| 46 | $privateKey = KeyHelper::createPrivateKey( |
||
| 47 | $row['cert_key'], |
||
| 48 | $row['passphrase'], |
||
| 49 | false, |
||
| 50 | $certificate->getSignatureAlgorithm() |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | |||
| 54 | $credential = new X509Credential($certificate, $privateKey); |
||
| 55 | $credential->setEntityId($entityId); |
||
| 56 | |||
| 57 | return [$credential]; |
||
| 58 | } |
||
| 60 |