Conditions | 5 |
Paths | 16 |
Total Lines | 75 |
Code Lines | 40 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
38 | public function asArray() |
||
39 | { |
||
40 | $conf = array(); |
||
41 | |||
42 | $conf['strict'] = $this->config()->get('strict'); |
||
43 | $conf['debug'] = $this->config()->get('debug'); |
||
44 | |||
45 | // SERVICE PROVIDER SECTION |
||
46 | $sp = $this->config()->get('SP'); |
||
47 | $spCertPath = Director::is_absolute($sp['x509cert']) ? $sp['x509cert'] : sprintf('%s/%s', BASE_PATH, $sp['x509cert']); |
||
48 | $spKeyPath = Director::is_absolute($sp['privateKey']) ? $sp['privateKey'] : sprintf('%s/%s', BASE_PATH, $sp['privateKey']); |
||
49 | $conf['sp']['entityId'] = $sp['entityId']; |
||
50 | $conf['sp']['assertionConsumerService'] = array( |
||
51 | 'url' => $sp['entityId'] . '/saml/acs', |
||
52 | 'binding' => OneLogin_Saml2_Constants::BINDING_HTTP_POST |
||
53 | ); |
||
54 | $conf['sp']['NameIDFormat'] = OneLogin_Saml2_Constants::NAMEID_TRANSIENT; |
||
55 | $conf['sp']['x509cert'] = file_get_contents($spCertPath); |
||
56 | $conf['sp']['privateKey'] = file_get_contents($spKeyPath); |
||
57 | |||
58 | // IDENTITY PROVIDER SECTION |
||
59 | $idp = $this->config()->get('IdP'); |
||
60 | $conf['idp']['entityId'] = $idp['entityId']; |
||
61 | $conf['idp']['singleSignOnService'] = array( |
||
62 | 'url' => $idp['singleSignOnService'], |
||
63 | 'binding' => OneLogin_Saml2_Constants::BINDING_HTTP_REDIRECT, |
||
64 | ); |
||
65 | if (isset($idp['singleLogoutService'])) { |
||
66 | $conf['idp']['singleLogoutService'] = array( |
||
67 | 'url' => $idp['singleLogoutService'], |
||
68 | 'binding' => OneLogin_Saml2_Constants::BINDING_HTTP_REDIRECT, |
||
69 | ); |
||
70 | } |
||
71 | |||
72 | $idpCertPath = Director::is_absolute($idp['x509cert']) ? $idp['x509cert'] : sprintf('%s/%s', BASE_PATH, $idp['x509cert']); |
||
73 | $conf['idp']['x509cert'] = file_get_contents($idpCertPath); |
||
74 | |||
75 | // SECURITY SECTION |
||
76 | $conf['security'] = array( |
||
77 | /** signatures and encryptions offered */ |
||
78 | // Indicates that the nameID of the <samlp:logoutRequest> sent by this SP will be encrypted. |
||
79 | 'nameIdEncrypted' => true, |
||
80 | // Indicates whether the <samlp:AuthnRequest> messages sent by this SP will be signed. [Metadata of the SP will offer this info] |
||
81 | 'authnRequestsSigned' => true, |
||
82 | // Indicates whether the <samlp:logoutRequest> messages sent by this SP will be signed. |
||
83 | 'logoutRequestSigned' => true, |
||
84 | // Indicates whether the <samlp:logoutResponse> messages sent by this SP will be signed. |
||
85 | 'logoutResponseSigned' => true, |
||
86 | 'signMetadata' => false, |
||
87 | /** signatures and encryptions required **/ |
||
88 | // Indicates a requirement for the <samlp:Response>, <samlp:LogoutRequest> |
||
89 | // and <samlp:LogoutResponse> elements received by this SP to be signed. |
||
90 | 'wantMessagesSigned' => false, |
||
91 | // Indicates a requirement for the <saml:Assertion> elements received by |
||
92 | // this SP to be signed. [Metadata of the SP will offer this info] |
||
93 | 'wantAssertionsSigned' => true, |
||
94 | // Indicates a requirement for the NameID received by |
||
95 | // this SP to be encrypted. |
||
96 | 'wantNameIdEncrypted' => false, |
||
97 | // Authentication context. |
||
98 | // Set to false and no AuthContext will be sent in the AuthNRequest, |
||
99 | // Set true or don't present thi parameter and you will get an AuthContext 'exact' 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport' |
||
100 | // Set an array with the possible auth context values: array ('urn:oasis:names:tc:SAML:2.0:ac:classes:Password', 'urn:oasis:names:tc:SAML:2.0:ac:classes:X509'), |
||
101 | 'requestedAuthnContext' => array( |
||
102 | 'urn:federation:authentication:windows', |
||
103 | 'urn:oasis:names:tc:SAML:2.0:ac:classes:Password', |
||
104 | 'urn:oasis:names:tc:SAML:2.0:ac:classes:X509', |
||
105 | ), |
||
106 | // Indicates if the SP will validate all received xmls. |
||
107 | // (In order to validate the xml, 'strict' and 'wantXMLValidation' must be true). |
||
108 | 'wantXMLValidation' => true, |
||
109 | ); |
||
110 | |||
111 | return $conf; |
||
112 | } |
||
113 | } |
||
114 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.