@@ -56,6 +56,9 @@ |
||
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | + /** |
|
| 60 | + * @param string $data |
|
| 61 | + */ |
|
| 59 | 62 | private function write($data) |
| 60 | 63 | { |
| 61 | 64 | if (false === @fwrite($this->socket, $data)) { |
@@ -57,6 +57,9 @@ discard block |
||
| 57 | 57 | /** @var array */ |
| 58 | 58 | private $instances; |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param integer $poolNumber |
|
| 62 | + */ |
|
| 60 | 63 | public function __construct($poolNumber, array $poolData) |
| 61 | 64 | { |
| 62 | 65 | $this->setId(self::validate($poolData, 'id')); |
@@ -248,6 +251,7 @@ discard block |
||
| 248 | 251 | * |
| 249 | 252 | * A /24 or 'bigger' will be split in 4 networks, everything 'smaller' |
| 250 | 253 | * will be either be split in 2 networks or remain 1 network. |
| 254 | + * @param integer $prefix |
|
| 251 | 255 | */ |
| 252 | 256 | private static function getNetCount($prefix) |
| 253 | 257 | { |
@@ -302,6 +306,9 @@ discard block |
||
| 302 | 306 | ]; |
| 303 | 307 | } |
| 304 | 308 | |
| 309 | + /** |
|
| 310 | + * @param string $configName |
|
| 311 | + */ |
|
| 305 | 312 | private static function validate(array $configData, $configName, $requiredField = true, $defaultValue = false) |
| 306 | 313 | { |
| 307 | 314 | if (!array_key_exists($configName, $configData)) { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | { |
| 34 | 34 | $service->get( |
| 35 | 35 | '/log/:showDate', |
| 36 | - function (Request $request, TokenInfo $tokenInfo, $showDate) { |
|
| 36 | + function(Request $request, TokenInfo $tokenInfo, $showDate) { |
|
| 37 | 37 | self::requireScope($tokenInfo, 'log_get'); |
| 38 | 38 | |
| 39 | 39 | InputValidation::date($showDate); |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $service->post( |
| 45 | 45 | '/ca/crl/fetch', |
| 46 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 46 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 47 | 47 | self::requireScope($tokenInfo, 'ca_crl_fetch'); |
| 48 | 48 | |
| 49 | 49 | $this->logger->info('fetching CRL'); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $service->get( |
| 46 | 46 | '/common_names/disabled', |
| 47 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 47 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 48 | 48 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 49 | 49 | |
| 50 | 50 | return new ApiResponse('common_names', $this->commonNames->getDisabled()); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $service->get( |
| 55 | 55 | '/common_names/disabled/:commonName', |
| 56 | - function ($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 56 | + function($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 57 | 57 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 58 | 58 | InputValidation::commonName($commonName); |
| 59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $service->post( |
| 65 | 65 | '/common_names/disabled/:commonName', |
| 66 | - function ($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 66 | + function($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 67 | 67 | $tokenInfo->getScope()->requireScope(['admin']); |
| 68 | 68 | InputValidation::commonName($commonName); |
| 69 | 69 | $this->logger->info(sprintf('disabling common_name "%s"', $commonName)); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $service->delete( |
| 77 | 77 | '/common_names/disabled/:commonName', |
| 78 | - function ($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 78 | + function($commonName, Request $request, TokenInfo $tokenInfo) { |
|
| 79 | 79 | $tokenInfo->getScope()->requireScope(['admin']); |
| 80 | 80 | InputValidation::commonName($commonName); |
| 81 | 81 | $this->logger->info(sprintf('enabling common_name "%s"', $commonName)); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $service->get( |
| 40 | 40 | '/openvpn/connections', |
| 41 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 41 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 42 | 42 | $tokenInfo->getScope()->requireScope(['admin']); |
| 43 | 43 | |
| 44 | 44 | $response = new JsonResponse(); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $service->post( |
| 52 | 52 | '/openvpn/kill', |
| 53 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 53 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 54 | 54 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 55 | 55 | |
| 56 | 56 | $commonName = $request->getPostParameter('common_name'); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | // |
| 63 | 63 | $service->get( |
| 64 | 64 | '/users/disabled', |
| 65 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 65 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 66 | 66 | $tokenInfo->getScope()->requireScope(['admin']); |
| 67 | 67 | |
| 68 | 68 | return new ApiResponse('users', $this->users->getDisabled()); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $service->get( |
| 73 | 73 | '/users/disabled/:userId', |
| 74 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 74 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 75 | 75 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 76 | 76 | InputValidation::userId($userId); |
| 77 | 77 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $service->post( |
| 83 | 83 | '/users/disabled/:userId', |
| 84 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 84 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 85 | 85 | $tokenInfo->getScope()->requireScope(['admin']); |
| 86 | 86 | InputValidation::userId($userId); |
| 87 | 87 | $this->logger->info(sprintf('disabling user "%s"', $userId)); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $service->delete( |
| 94 | 94 | '/users/disabled/:userId', |
| 95 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 95 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 96 | 96 | $tokenInfo->getScope()->requireScope(['admin']); |
| 97 | 97 | InputValidation::userId($userId); |
| 98 | 98 | $this->logger->info(sprintf('enabling user "%s"', $userId)); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | // |
| 107 | 107 | $service->get( |
| 108 | 108 | '/users/otp_secrets', |
| 109 | - function (Request $request, TokenInfo $tokenInfo) { |
|
| 109 | + function(Request $request, TokenInfo $tokenInfo) { |
|
| 110 | 110 | $tokenInfo->getScope()->requireScope(['admin']); |
| 111 | 111 | |
| 112 | 112 | return new ApiResponse('users', $this->otpSecret->getOtpSecrets()); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $service->get( |
| 117 | 117 | '/users/otp_secrets/:userId', |
| 118 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 118 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 119 | 119 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 120 | 120 | InputValidation::userId($userId); |
| 121 | 121 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $service->post( |
| 129 | 129 | '/users/otp_secrets/:userId', |
| 130 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 130 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 131 | 131 | $tokenInfo->getScope()->requireScope(['portal']); |
| 132 | 132 | InputValidation::userId($userId); |
| 133 | 133 | $otpSecret = $request->getPostParameter('otp_secret'); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $service->delete( |
| 141 | 141 | '/users/otp_secrets/:userId', |
| 142 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 142 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 143 | 143 | $tokenInfo->getScope()->requireScope(['admin']); |
| 144 | 144 | InputValidation::userId($userId); |
| 145 | 145 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // |
| 153 | 153 | $service->get( |
| 154 | 154 | '/users/groups/:userId', |
| 155 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 155 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 156 | 156 | $tokenInfo->getScope()->requireScope(['admin', 'portal']); |
| 157 | 157 | InputValidation::userId($userId); |
| 158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | // |
| 166 | 166 | $service->get( |
| 167 | 167 | '/users/voot_tokens/:userId', |
| 168 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 168 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 169 | 169 | $tokenInfo->getScope()->requireScope(['portal']); |
| 170 | 170 | InputValidation::userId($userId); |
| 171 | 171 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $service->post( |
| 179 | 179 | '/users/voot_tokens/:userId', |
| 180 | - function ($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 180 | + function($userId, Request $request, TokenInfo $tokenInfo) { |
|
| 181 | 181 | $tokenInfo->getScope()->requireScope(['portal']); |
| 182 | 182 | InputValidation::userId($userId); |
| 183 | 183 | $vootToken = $request->getPostParameter('voot_token'); |
@@ -54,6 +54,9 @@ |
||
| 54 | 54 | return $this->io->isFile($commonNameFile); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + /** |
|
| 58 | + * @param boolean $isDisabled |
|
| 59 | + */ |
|
| 57 | 60 | public function setDisable($commonName, $isDisabled) |
| 58 | 61 | { |
| 59 | 62 | if ($isDisabled === $this->getDisable($commonName)) { |