|
6 | 6 | use DateTimeImmutable; |
7 | 7 | use DateTimeZone; |
8 | 8 | use SimpleSAML\SAML2\Constants as C; |
| 9 | +use SimpleSAML\SAML2\Type\{SAMLAnyURIValue, SAMLDateTimeValue, SAMLStringValue}; |
9 | 10 | use SimpleSAML\SAML2\XML\mdattr\EntityAttributes; |
10 | 11 | use SimpleSAML\SAML2\XML\saml\Assertion; |
11 | 12 | use SimpleSAML\SAML2\XML\saml\Attribute; |
|
17 | 18 | use SimpleSAML\SAML2\XML\saml\Issuer; |
18 | 19 | use SimpleSAML\SAML2\XML\saml\NameID; |
19 | 20 | use SimpleSAML\SAML2\XML\saml\Subject; |
| 21 | +use SimpleSAML\XML\Type\IDValue; |
20 | 22 | use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory; |
21 | 23 | use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock; |
22 | 24 |
|
|
28 | 30 | ); |
29 | 31 |
|
30 | 32 | $unsignedAssertion = new Assertion( |
31 | | - issuer: new Issuer('urn:x-simplesamlphp:issuer'), |
32 | | - issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')), |
33 | | - id: '_93af655219464fb403b34436cfb0c5cb1d9a5502', |
| 33 | + issuer: new Issuer(SAMLStringValue::fromString('urn:x-simplesamlphp:issuer')), |
| 34 | + issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))), |
| 35 | + id: IDValue::fromString('_93af655219464fb403b34436cfb0c5cb1d9a5502'), |
34 | 36 | subject: new Subject(new NameID( |
35 | | - value: 'some:entity', |
36 | | - Format: C::NAMEID_ENTITY, |
| 37 | + value: SAMLStringValue::fromString('some:entity'), |
| 38 | + Format: SAMLAnyURIValue::fromString(C::NAMEID_ENTITY), |
37 | 39 | )), |
38 | 40 | conditions: new Conditions( |
39 | 41 | condition: [], |
40 | 42 | audienceRestriction: [ |
41 | 43 | new AudienceRestriction([ |
42 | | - new Audience('https://simplesamlphp.org/idp/metadata'), |
43 | | - new Audience('urn:x-simplesamlphp:phpunit:entity'), |
| 44 | + new Audience(SAMLAnyURIValue::fromString('https://simplesamlphp.org/idp/metadata')), |
| 45 | + new Audience(SAMLAnyURIValue::fromString('urn:x-simplesamlphp:phpunit:entity')), |
44 | 46 | ]), |
45 | 47 | ], |
46 | 48 | ), |
47 | 49 | statements: [new AttributeStatement([ |
48 | 50 | new Attribute( |
49 | | - name: 'urn:mace:dir:attribute-def:uid', |
50 | | - nameFormat: C::NAMEFORMAT_URI, |
51 | | - attributeValue: [new AttributeValue('student2')], |
| 51 | + name: SAMLStringValue::fromString('urn:mace:dir:attribute-def:uid'), |
| 52 | + nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI), |
| 53 | + attributeValue: [ |
| 54 | + new AttributeValue(SAMLStringValue::fromString('student2')), |
| 55 | + ], |
52 | 56 | ), |
53 | 57 | new Attribute( |
54 | | - name: 'urn:mace:terena.org:attribute-def:schacHomeOrganization', |
55 | | - nameFormat: C::NAMEFORMAT_URI, |
56 | | - attributeValue: [new AttributeValue('university.example.org'), new AttributeValue('bbb.cc')], |
| 58 | + name: SAMLStringValue::fromString('urn:mace:terena.org:attribute-def:schacHomeOrganization'), |
| 59 | + nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI), |
| 60 | + attributeValue: [ |
| 61 | + new AttributeValue(SAMLStringValue::fromString('university.example.org')), |
| 62 | + new AttributeValue(SAMLStringValue::fromString('bbb.cc')), |
| 63 | + ], |
57 | 64 | ), |
58 | 65 | new Attribute( |
59 | | - name: 'urn:schac:attribute-def:schacPersonalUniqueCode', |
60 | | - nameFormat: C::NAMEFORMAT_URI, |
| 66 | + name: SAMLStringValue::fromString('urn:schac:attribute-def:schacPersonalUniqueCode'), |
| 67 | + nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI), |
61 | 68 | attributeValue: [ |
62 | | - new AttributeValue('urn:schac:personalUniqueCode:nl:local:uvt.nl:memberid:524020'), |
63 | | - new AttributeValue('urn:schac:personalUniqueCode:nl:local:surfnet.nl:studentid:12345'), |
| 69 | + new AttributeValue( |
| 70 | + SAMLStringValue::fromString('urn:schac:personalUniqueCode:nl:local:uvt.nl:memberid:524020'), |
| 71 | + ), |
| 72 | + new AttributeValue( |
| 73 | + SAMLStringValue::fromString('urn:schac:personalUniqueCode:nl:local:surfnet.nl:studentid:12345'), |
| 74 | + ), |
64 | 75 | ], |
65 | 76 | ), |
66 | 77 | new Attribute( |
67 | | - name: 'urn:mace:dir:attribute-def:eduPersonAffiliation', |
68 | | - nameFormat: C::NAMEFORMAT_URI, |
69 | | - attributeValue: [new AttributeValue('member'), new AttributeValue('student')], |
| 78 | + name: SAMLStringValue::fromString('urn:mace:dir:attribute-def:eduPersonAffiliation'), |
| 79 | + nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI), |
| 80 | + attributeValue: [ |
| 81 | + new AttributeValue(SAMLStringValue::fromString('member')), |
| 82 | + new AttributeValue(SAMLStringValue::fromString('student')), |
| 83 | + ], |
70 | 84 | ), |
71 | 85 | ])], |
72 | 86 | ); |
73 | 87 | $unsignedAssertion->sign($signer); |
74 | 88 | $signedAssertion = Assertion::fromXML($unsignedAssertion->toXML()); |
75 | 89 | $entityAttributes = new EntityAttributes([ |
76 | 90 | new Attribute( |
77 | | - name: 'attrib1', |
78 | | - nameFormat: C::NAMEFORMAT_BASIC, |
79 | | - attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')], |
| 91 | + name: SAMLStringValue::fromString('attrib1'), |
| 92 | + nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_BASIC), |
| 93 | + attributeValue: [ |
| 94 | + new AttributeValue(SAMLStringValue::fromString('is')), |
| 95 | + new AttributeValue(SAMLStringValue::fromString('really')), |
| 96 | + new AttributeValue(SAMLStringValue::fromString('cool')), |
| 97 | + ], |
80 | 98 | ), |
81 | 99 | $signedAssertion, |
82 | 100 | new Attribute( |
83 | | - name: 'foo', |
84 | | - nameFormat: 'urn:simplesamlphp:v1:simplesamlphp', |
85 | | - attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')], |
| 101 | + name: SAMLStringValue::fromString('foo'), |
| 102 | + nameFormat: SAMLAnyURIValue::fromString('urn:simplesamlphp:v1:simplesamlphp'), |
| 103 | + attributeValue: [ |
| 104 | + new AttributeValue(SAMLStringValue::fromString('is')), |
| 105 | + new AttributeValue(SAMLStringValue::fromString('really')), |
| 106 | + new AttributeValue(SAMLStringValue::fromString('cool')), |
| 107 | + ], |
86 | 108 | ), |
87 | 109 | ]); |
88 | 110 |
|
|
0 commit comments