[wip]
This commit is contained in:
parent
7d9548a495
commit
6cf8f4c8ca
32 changed files with 862 additions and 170 deletions
7
bin/clean-all
Executable file
7
bin/clean-all
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
BINDIR=$(dirname $(realpath $0));
|
||||
BASEDIR=$(realpath "$BINDIR/../");
|
||||
cd $BASEDIR;
|
||||
rm -rf ./storage/ca/*;
|
||||
mkdir ./storage/ca/certs;
|
||||
touch ./storage/ca/{,certs/}.gitkeep;
|
16
bin/create-ca
Executable file
16
bin/create-ca
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
BASEDIR=$(realpath $(dirname $0));
|
||||
KEYDIR=$(realpath "$BASEDIR/../storage/ca/");
|
||||
|
||||
if [ -f $KEYDIR/ca.key ]; then
|
||||
echo "CA key already exists. not overwriting it."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
CN="ob.ae-cn";
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
CN=$1;
|
||||
fi;
|
||||
|
||||
openssl req -days 3650 -nodes -new -x509 -keyout $KEYDIR/ca.key -out $KEYDIR/ca.crt -subj "/CN=$CN" -extensions ca_ext -config "$BASEDIR/../etc/openssl.conf";
|
4
bin/create-crl
Executable file
4
bin/create-crl
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
DIR=$(dirname $(realpath $0));
|
||||
openssl ca -config "$DIR/../etc/openssl.conf" -gencrl -keyfile "$DIR/../storage/ca/ca.key" -cert "$DIR/../storage/ca/ca.crt" -out "$DIR/../storage/ca/crl.pem";
|
||||
openssl crl -inform PEM -in "$DIR/../storage/ca/crl.pem" -outform DER -out "$DIR/../storage/ca/crl.der";
|
7
bin/create-csr
Executable file
7
bin/create-csr
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
if [ -z "$3" ]; then
|
||||
echo "Usage: $0 [commonname] [csr path] [key path]";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
openssl req -sha256 -keyout $3 -nodes -newkey rsa:2048 -out $2 -subj "/CN=$1"
|
|
@ -1,14 +1,12 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
namespace Zerobae\Panel;
|
||||
|
||||
include __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$baseDir = realpath(__DIR__ . '/../');
|
||||
|
||||
$core = new \Eater\Glim\Core();
|
||||
$core->boot($baseDir);
|
||||
$config = new Config();
|
||||
$controller = new Controller($config);
|
||||
|
||||
$newInvite = new \Eater\Glim\Model\Invite();
|
||||
$newInvite->setInvite(md5(rand(0, PHP_INT_MAX)));
|
||||
$newInvite->save();
|
||||
|
||||
echo $newInvite->getInvite() . "\n";
|
||||
echo $controller->createInvite() . "\n";
|
||||
|
|
4
bin/dev-server
Executable file
4
bin/dev-server
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
DIR=$(dirname $0);
|
||||
cd $DIR/../public;
|
||||
php -S 0:8888;
|
3
bin/revoke-cert
Executable file
3
bin/revoke-cert
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
DIR=$(dirname $(realpath $0));
|
||||
openssl ca -config "$DIR/../etc/openssl.conf" -revoke "$1";
|
15
bin/setup
Executable file
15
bin/setup
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
BASEDIR="$(dirname $(realpath $0))/../";
|
||||
cd $BASEDIR;
|
||||
STORAGE=$(realpath "$BASEDIR/storage/ca");
|
||||
|
||||
mkdir -p $STORAGE;
|
||||
mkdir -p $STORAGE/certs;
|
||||
|
||||
echo 01 > $STORAGE/serial;
|
||||
echo 01 > $STORAGE/crl_serial;
|
||||
touch $STORAGE/database;
|
||||
touch $STORAGE/database.attr;
|
||||
|
||||
$BASEDIR/bin/create-ca $1;
|
||||
$BASEDIR/bin/create-crl;
|
6
bin/sign-client-csr
Executable file
6
bin/sign-client-csr
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
DIR=$(dirname $(realpath $0));
|
||||
CSR=$(realpath $1);
|
||||
CRT=$(realpath $2);
|
||||
cd $DIR/../;
|
||||
openssl ca -in $CSR -out $CRT -config $DIR/../etc/openssl.conf -md sha256 -days 3650 -extensions client_ext -batch -notext;
|
6
bin/sign-server-csr
Executable file
6
bin/sign-server-csr
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
DIR=$(dirname $(realpath $0));
|
||||
CSR=$(realpath $1);
|
||||
CRT=$(realpath $2);
|
||||
cd $DIR/../;
|
||||
openssl ca -in $CSR -out $CRT -config $DIR/../etc/openssl.conf -md sha256 -days 3650 -extensions server_ext;
|
|
@ -11,4 +11,5 @@ core:
|
|||
user: Eater\Glim\Service\User
|
||||
session: Eater\Glim\Service\Session
|
||||
twig: Eater\Glim\Service\Twig
|
||||
twig-vars: Eater\Glim\Service\TwigVars
|
||||
twig-vars: Eater\Glim\Service\TwigVars
|
||||
ca: Eater\Glim\Service\CA
|
|
@ -12,4 +12,6 @@ routes:
|
|||
get: Panel
|
||||
/certificates:
|
||||
/new:
|
||||
get: Panel\Certificates\_New\Show
|
||||
get: Panel\Certificates\_New\Show
|
||||
post: Panel\Certificates\_New\Action
|
||||
/download/{name}: Panel\Certificates\Download
|
|
@ -5,7 +5,7 @@
|
|||
>
|
||||
<table name="User">
|
||||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" />
|
||||
<column name="maxKeys" type="integer" default="5" />
|
||||
<column name="max_keys" type="integer" default="5" />
|
||||
<column name="username" type="varchar" size="64" />
|
||||
<column name="password" type="varchar" size="64" />
|
||||
<column name="superuser" type="boolean" default="false" />
|
||||
|
@ -17,17 +17,28 @@
|
|||
|
||||
<table name="Certificate">
|
||||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" />
|
||||
<column name="userId" type="integer" />
|
||||
<column name="user_id" type="integer" />
|
||||
<column name="name" type="varchar" size="64" />
|
||||
<column name="certificate" type="longvarchar" />
|
||||
<column name="expires_on" type="timestamp" />
|
||||
<column name="revoked" type="boolean" default="false" />
|
||||
<column name="serial" type="varchar" size="64" />
|
||||
|
||||
<index>
|
||||
<index-column name="userId" />
|
||||
<index-column name="user_id" />
|
||||
</index>
|
||||
|
||||
<index>
|
||||
<index-column name="serial" />
|
||||
</index>
|
||||
|
||||
<unique>
|
||||
<unique-column name="name" />
|
||||
<unique-column name="user_id" />
|
||||
</unique>
|
||||
|
||||
<foreign-key foreignTable="User">
|
||||
<reference local="userId" foreign="id" />
|
||||
<reference local="user_id" foreign="id" />
|
||||
</foreign-key>
|
||||
</table>
|
||||
|
||||
|
|
44
etc/openssl.conf
Normal file
44
etc/openssl.conf
Normal file
|
@ -0,0 +1,44 @@
|
|||
distinguished_name = req_distinguished_name
|
||||
[ca]
|
||||
default_ca=ca_default
|
||||
[req_distinguished_name]
|
||||
[v3_req]
|
||||
[v3_ca]
|
||||
[ca_default]
|
||||
crl_extensions=crl_ext
|
||||
private_key=storage/ca/ca.key
|
||||
certificate=storage/ca/ca.crt
|
||||
new_certs_dir=storage/ca/certs/
|
||||
database=storage/ca/database
|
||||
default_md=sha256
|
||||
policy=policy_only_commonname
|
||||
serial=storage/ca/serial
|
||||
crlnumber=storage/ca/crl_serial
|
||||
default_crl_days=1
|
||||
[policy_only_commonname]
|
||||
countryName = optional
|
||||
stateOrProvinceName = optional
|
||||
localityName = optional
|
||||
organizationName = optional
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
[req]
|
||||
x509_extensions = client_ext
|
||||
[server_ext]
|
||||
basicConstraints = CA:FALSE
|
||||
subjectKeyIdentifier=hash
|
||||
authorityKeyIdentifier = keyid,issuer:always
|
||||
extendedKeyUsage = serverAuth
|
||||
keyUsage = digitalSignature,keyEncipherment
|
||||
crlDistributionPoints = URI:http://0b.ae/crl
|
||||
[client_ext]
|
||||
subjectKeyIdentifier=hash
|
||||
basicConstraints = CA:FALSE
|
||||
crlDistributionPoints = URI:http://localhost:8888/crl
|
||||
[ca_ext]
|
||||
basicConstraints = CA:TRUE
|
||||
subjectKeyIdentifier=hash
|
||||
crlDistributionPoints = URI:http://localhost:8888/crl
|
||||
[crl_ext]
|
||||
authorityKeyIdentifier=keyid:always
|
45
etc/openssl.conf.twig
Normal file
45
etc/openssl.conf.twig
Normal file
|
@ -0,0 +1,45 @@
|
|||
distinguished_name = req_distinguished_name
|
||||
[ca]
|
||||
default_ca=ca_default
|
||||
[req_distinguished_name]
|
||||
[v3_req]
|
||||
[v3_ca]
|
||||
[ca_default]
|
||||
crl_extensions=crl_ext
|
||||
unique_subject=no
|
||||
private_key=storage/ca.key
|
||||
certificate=storage/ca.crt
|
||||
new_certs_dir=storage/certs/
|
||||
database=storage/database
|
||||
default_md=sha256
|
||||
policy=policy_only_commonname
|
||||
serial=storage/serial
|
||||
crlnumber=storage/crl_serial
|
||||
default_crl_days=1
|
||||
[policy_only_commonname]
|
||||
countryName = optional
|
||||
stateOrProvinceName = optional
|
||||
localityName = optional
|
||||
organizationName = optional
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
[req]
|
||||
x509_extensions = client_ext
|
||||
[server_ext]
|
||||
basicConstraints = CA:FALSE
|
||||
subjectKeyIdentifier=hash
|
||||
authorityKeyIdentifier = keyid,issuer:always
|
||||
extendedKeyUsage = serverAuth
|
||||
keyUsage = digitalSignature,keyEncipherment
|
||||
crlDistributionPoints = URI:http://{{ hostname }}/crl
|
||||
[client_ext]
|
||||
subjectKeyIdentifier=hash
|
||||
basicConstraints = CA:FALSE
|
||||
crlDistributionPoints = URI:http://{{ hostname }}/crl
|
||||
[ca_ext]
|
||||
basicConstraints = CA:TRUE
|
||||
subjectKeyIdentifier=hash
|
||||
crlDistributionPoints = URI:http://{{ hostname }}/crl
|
||||
[crl_ext]
|
||||
authorityKeyIdentifier=keyid:always
|
2
public/js/FileSaver.min.js
vendored
Normal file
2
public/js/FileSaver.min.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),c=e.webkitRequestFileSystem,f=e.requestFileSystem||c||e.mozRequestFileSystem,u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=0,l=4e4,v=function(e){var t=function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()};setTimeout(t,l)},p=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(i){u(i)}}},w=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},y=function(t,u,l){l||(t=w(t));var y,m,S,h=this,R=t.type,O=!1,g=function(){p(h,"writestart progress write writeend".split(" "))},b=function(){if(m&&a&&"undefined"!=typeof FileReader){var o=new FileReader;return o.onloadend=function(){var e=o.result;m.location.href="data:attachment/file"+e.slice(e.search(/[,;]/)),h.readyState=h.DONE,g()},o.readAsDataURL(t),void(h.readyState=h.INIT)}if((O||!y)&&(y=n().createObjectURL(t)),m)m.location.href=y;else{var r=e.open(y,"_blank");void 0===r&&a&&(e.location.href=y)}h.readyState=h.DONE,g(),v(y)},E=function(e){return function(){return h.readyState!==h.DONE?e.apply(this,arguments):void 0}},N={create:!0,exclusive:!1};return h.readyState=h.INIT,u||(u="download"),r?(y=n().createObjectURL(t),void setTimeout(function(){o.href=y,o.download=u,i(o),g(),v(y),h.readyState=h.DONE})):(e.chrome&&R&&R!==d&&(S=t.slice||t.webkitSlice,t=S.call(t,0,t.size,d),O=!0),c&&"download"!==u&&(u+=".download"),(R===d||c)&&(m=e),f?(s+=t.size,void f(e.TEMPORARY,s,E(function(e){e.root.getDirectory("saved",N,E(function(e){var n=function(){e.getFile(u,N,E(function(e){e.createWriter(E(function(n){n.onwriteend=function(t){m.location.href=e.toURL(),h.readyState=h.DONE,p(h,"writeend",t),v(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&b()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=h["on"+e]}),n.write(t),h.abort=function(){n.abort(),h.readyState=h.DONE},h.readyState=h.WRITING}),b)}),b)};e.getFile(u,{create:!1},E(function(e){e.remove(),n()}),E(function(e){e.code===e.NOT_FOUND_ERR?n():b()}))}),b)}),b)):void b())},m=y.prototype,S=function(e,t,n){return new y(e,t,n)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return n||(e=w(e)),navigator.msSaveOrOpenBlob(e,t||"download")}:(m.abort=function(){var e=this;e.readyState=e.DONE,p(e,"abort")},m.readyState=m.INIT=0,m.WRITING=1,m.DONE=2,m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null,S)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define([],function(){return saveAs});
|
14
public/js/jszip.min.js
vendored
Normal file
14
public/js/jszip.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,20 +1,39 @@
|
|||
$(function () {
|
||||
var error = $('<div class="alert alert-danger" role="alert"></div>');
|
||||
|
||||
$('.magic-csr').click(function () {
|
||||
var name = $('#name').val();
|
||||
var user = $('.user').text();
|
||||
|
||||
var keys = forge.pki.rsa.generateKeyPair(1024);
|
||||
var csr = forge.pki.createCertificationRequest();
|
||||
var commonName = name + '.' + user;
|
||||
|
||||
csr.publicKey = keys.publicKey;
|
||||
csr.setSubject([{
|
||||
name: 'commonName',
|
||||
value: 'eater-' + +Date.now()
|
||||
value: commonName
|
||||
}]);
|
||||
csr.sign(keys.privateKey);
|
||||
var pem = forge.pki.certificationRequestToPem(csr);
|
||||
|
||||
$.post('/panel/certificates/new', {
|
||||
csr: pem
|
||||
csr: pem,
|
||||
name: name
|
||||
}, function (data) {
|
||||
var config = data.config;
|
||||
config = config.replace('<PUT PRIVATE KEY HERE>', forge.pki.privateKeyToPem(keys.privateKey));
|
||||
if (data.success) {
|
||||
var zip = new JSZip();
|
||||
zip.file(commonName + '.key', pem);
|
||||
|
||||
for(var file in data.zip) {
|
||||
zip.file(file, data.zip[file]);
|
||||
}
|
||||
var content = zip.generate({type:"blob"});
|
||||
saveAs(content, commonName + '-vpn.zip');
|
||||
location.href = '/panel';
|
||||
} else {
|
||||
$('h2').after(error.text(data.error));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -136,4 +136,25 @@ abstract class Main implements ContainerInterface
|
|||
$response = $this->getResponse();
|
||||
return $response->withRedirect($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @return Response
|
||||
*/
|
||||
public function json($array)
|
||||
{
|
||||
return $this->getResponse()
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->write(json_encode($array));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function attr($name)
|
||||
{
|
||||
return $this->getRequest()->getAttribute($name);
|
||||
}
|
||||
}
|
37
src/Handler/Panel/Certificates/Download.php
Normal file
37
src/Handler/Panel/Certificates/Download.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: eater
|
||||
* Date: 4/5/16
|
||||
* Time: 2:03 AM
|
||||
*/
|
||||
|
||||
namespace Eater\Glim\Handler\Panel\Certificates;
|
||||
|
||||
|
||||
use Eater\Glim\Handler\Session;
|
||||
use Eater\Glim\Model\CertificateQuery;
|
||||
|
||||
class Download extends Session
|
||||
{
|
||||
protected $shouldHaveUser = true;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$name = $this->attr('name');
|
||||
|
||||
$cert = CertificateQuery::create()
|
||||
->filterByName($name)
|
||||
->filterByUser($this->getUser())
|
||||
->findOne();
|
||||
|
||||
if ($cert === null) {
|
||||
return $this->getResponse()->withStatus(404)->write("Couldn't find your Certificate with the name '{$name}'");
|
||||
}
|
||||
|
||||
return $this->getResponse()
|
||||
->withHeader('Content-Type', 'plain/text')
|
||||
->withHeader('Content-Disposition', 'attachment; filename="' . $name . '.' . $this->getUser()->getUsername() .'.crt"')
|
||||
->write($cert->getCertificate());
|
||||
}
|
||||
}
|
85
src/Handler/Panel/Certificates/_New/Action.php
Normal file
85
src/Handler/Panel/Certificates/_New/Action.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: eater
|
||||
* Date: 4/4/16
|
||||
* Time: 9:23 PM
|
||||
*/
|
||||
|
||||
namespace Eater\Glim\Handler\Panel\Certificates\_New;
|
||||
|
||||
|
||||
use Eater\Glim\Handler\Session;
|
||||
use Eater\Glim\Model\Certificate;
|
||||
use Eater\Glim\Model\CertificateQuery;
|
||||
use Eater\Glim\Service\CA;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class Action extends Session
|
||||
{
|
||||
protected $shouldHaveUser = true;
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$core = $this->getCore();
|
||||
/** @var CA $ca */
|
||||
$ca = $this->get('ca');
|
||||
|
||||
$name = $this->post('name');
|
||||
$csr = $this->post('csr');
|
||||
|
||||
$amount = CertificateQuery::create()
|
||||
->filterByName($name)
|
||||
->filterByUser($user)
|
||||
->count();
|
||||
if ($amount > 0) {
|
||||
return $this->json([
|
||||
"error" => "You already have an Certificate with the name '$name'",
|
||||
"success" => false
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$commonName = $ca->getCommonNameFromCsr($csr);
|
||||
}catch (\Exception $e) {
|
||||
return $this->json([
|
||||
"error" => $e->getMessage(),
|
||||
"success" => false
|
||||
]);
|
||||
}
|
||||
|
||||
$designatedCommonName = $name . '.' . $user->getUsername();
|
||||
|
||||
if ($commonName !== $name . '.' . $user->getUsername()) {
|
||||
return $this->json([
|
||||
"error" => "CommonName of CSR isn't '$designatedCommonName'",
|
||||
"success" => false
|
||||
]);
|
||||
}
|
||||
|
||||
$crt = $ca->signClientCsr($csr);
|
||||
|
||||
$details = openssl_x509_parse($crt);
|
||||
|
||||
$certificate = new Certificate();
|
||||
$certificate->setName($name);
|
||||
$certificate->setCertificate($crt);
|
||||
$certificate->setExpiresOn(new \DateTime('@' . $details['validTo_time_t']));
|
||||
$certificate->setSerial($details['serialNumber']);
|
||||
|
||||
$user->addCertificate($certificate);
|
||||
$user->save();
|
||||
|
||||
return $this->json([
|
||||
"success" => true,
|
||||
"zip" => [
|
||||
"ca.crt" => file_get_contents($core->getBaseDir() . '/storage/ca/ca.crt'),
|
||||
$designatedCommonName . '.crt' => $crt
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,32 @@ use Eater\Glim\Service\TwigVars;
|
|||
|
||||
class Session extends Main
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $shouldHaveUser = false;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
|
||||
public function beforeHandle()
|
||||
{
|
||||
|
@ -28,6 +53,8 @@ class Session extends Main
|
|||
$user = $segment->get('user');
|
||||
$twigVar->def('user', $user);
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
if ($user === null && $this->shouldHaveUser) {
|
||||
return $this->redirect('/login');
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Eater\Glim\Model\Base;
|
||||
|
||||
use \DateTime;
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Eater\Glim\Model\CertificateQuery as ChildCertificateQuery;
|
||||
|
@ -19,6 +20,7 @@ use Propel\Runtime\Exception\LogicException;
|
|||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'Certificate' table.
|
||||
|
@ -68,10 +70,10 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the userid field.
|
||||
* The value for the user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $userid;
|
||||
protected $user_id;
|
||||
|
||||
/**
|
||||
* The value for the name field.
|
||||
|
@ -85,6 +87,12 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
*/
|
||||
protected $certificate;
|
||||
|
||||
/**
|
||||
* The value for the expires_on field.
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $expires_on;
|
||||
|
||||
/**
|
||||
* The value for the revoked field.
|
||||
* Note: this column has a database default value of: false
|
||||
|
@ -92,6 +100,12 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
*/
|
||||
protected $revoked;
|
||||
|
||||
/**
|
||||
* The value for the serial field.
|
||||
* @var string
|
||||
*/
|
||||
protected $serial;
|
||||
|
||||
/**
|
||||
* @var ChildUser
|
||||
*/
|
||||
|
@ -346,13 +360,13 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the [userid] column value.
|
||||
* Get the [user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserid()
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->userid;
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,6 +389,26 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this->certificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [expires_on] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
*
|
||||
* @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
*
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getExpiresOn($format = NULL)
|
||||
{
|
||||
if ($format === null) {
|
||||
return $this->expires_on;
|
||||
} else {
|
||||
return $this->expires_on instanceof \DateTime ? $this->expires_on->format($format) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [revoked] column value.
|
||||
*
|
||||
|
@ -395,6 +429,16 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this->getRevoked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [serial] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSerial()
|
||||
{
|
||||
return $this->serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
|
@ -416,20 +460,20 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [userid] column.
|
||||
* Set the value of [user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return $this|\Eater\Glim\Model\Certificate The current object (for fluent API support)
|
||||
*/
|
||||
public function setUserid($v)
|
||||
public function setUserId($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->userid !== $v) {
|
||||
$this->userid = $v;
|
||||
$this->modifiedColumns[CertificateTableMap::COL_USERID] = true;
|
||||
if ($this->user_id !== $v) {
|
||||
$this->user_id = $v;
|
||||
$this->modifiedColumns[CertificateTableMap::COL_USER_ID] = true;
|
||||
}
|
||||
|
||||
if ($this->aUser !== null && $this->aUser->getId() !== $v) {
|
||||
|
@ -437,7 +481,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
}
|
||||
|
||||
return $this;
|
||||
} // setUserid()
|
||||
} // setUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [name] column.
|
||||
|
@ -479,6 +523,26 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this;
|
||||
} // setCertificate()
|
||||
|
||||
/**
|
||||
* Sets the value of [expires_on] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
* @param mixed $v string, integer (timestamp), or \DateTime value.
|
||||
* Empty strings are treated as NULL.
|
||||
* @return $this|\Eater\Glim\Model\Certificate The current object (for fluent API support)
|
||||
*/
|
||||
public function setExpiresOn($v)
|
||||
{
|
||||
$dt = PropelDateTime::newInstance($v, null, 'DateTime');
|
||||
if ($this->expires_on !== null || $dt !== null) {
|
||||
if ($this->expires_on === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->expires_on->format("Y-m-d H:i:s")) {
|
||||
$this->expires_on = $dt === null ? null : clone $dt;
|
||||
$this->modifiedColumns[CertificateTableMap::COL_EXPIRES_ON] = true;
|
||||
}
|
||||
} // if either are not null
|
||||
|
||||
return $this;
|
||||
} // setExpiresOn()
|
||||
|
||||
/**
|
||||
* Sets the value of the [revoked] column.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
|
@ -507,6 +571,26 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this;
|
||||
} // setRevoked()
|
||||
|
||||
/**
|
||||
* Set the value of [serial] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return $this|\Eater\Glim\Model\Certificate The current object (for fluent API support)
|
||||
*/
|
||||
public function setSerial($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->serial !== $v) {
|
||||
$this->serial = $v;
|
||||
$this->modifiedColumns[CertificateTableMap::COL_SERIAL] = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setSerial()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
|
@ -550,8 +634,8 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CertificateTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CertificateTableMap::translateFieldName('Userid', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->userid = (null !== $col) ? (int) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CertificateTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->user_id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CertificateTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->name = (null !== $col) ? (string) $col : null;
|
||||
|
@ -559,8 +643,14 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CertificateTableMap::translateFieldName('Certificate', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->certificate = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CertificateTableMap::translateFieldName('Revoked', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CertificateTableMap::translateFieldName('ExpiresOn', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->expires_on = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CertificateTableMap::translateFieldName('Revoked', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->revoked = (null !== $col) ? (boolean) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CertificateTableMap::translateFieldName('Serial', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->serial = (null !== $col) ? (string) $col : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -569,7 +659,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 5; // 5 = CertificateTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 7; // 7 = CertificateTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException(sprintf('Error populating %s object', '\\Eater\\Glim\\Model\\Certificate'), 0, $e);
|
||||
|
@ -591,7 +681,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
*/
|
||||
public function ensureConsistency()
|
||||
{
|
||||
if ($this->aUser !== null && $this->userid !== $this->aUser->getId()) {
|
||||
if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) {
|
||||
$this->aUser = null;
|
||||
}
|
||||
} // ensureConsistency
|
||||
|
@ -785,8 +875,8 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(CertificateTableMap::COL_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'id';
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_USERID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'userId';
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_USER_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'user_id';
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_NAME)) {
|
||||
$modifiedColumns[':p' . $index++] = 'name';
|
||||
|
@ -794,9 +884,15 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(CertificateTableMap::COL_CERTIFICATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'certificate';
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_EXPIRES_ON)) {
|
||||
$modifiedColumns[':p' . $index++] = 'expires_on';
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_REVOKED)) {
|
||||
$modifiedColumns[':p' . $index++] = 'revoked';
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_SERIAL)) {
|
||||
$modifiedColumns[':p' . $index++] = 'serial';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO Certificate (%s) VALUES (%s)',
|
||||
|
@ -811,8 +907,8 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
case 'id':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'userId':
|
||||
$stmt->bindValue($identifier, $this->userid, PDO::PARAM_INT);
|
||||
case 'user_id':
|
||||
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'name':
|
||||
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
|
||||
|
@ -820,9 +916,15 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
case 'certificate':
|
||||
$stmt->bindValue($identifier, $this->certificate, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'expires_on':
|
||||
$stmt->bindValue($identifier, $this->expires_on ? $this->expires_on->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'revoked':
|
||||
$stmt->bindValue($identifier, $this->revoked, PDO::PARAM_BOOL);
|
||||
break;
|
||||
case 'serial':
|
||||
$stmt->bindValue($identifier, $this->serial, PDO::PARAM_STR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
|
@ -889,7 +991,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getUserid();
|
||||
return $this->getUserId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getName();
|
||||
|
@ -898,8 +1000,14 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
return $this->getCertificate();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getExpiresOn();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getRevoked();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getSerial();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
|
@ -931,11 +1039,21 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$keys = CertificateTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getUserid(),
|
||||
$keys[1] => $this->getUserId(),
|
||||
$keys[2] => $this->getName(),
|
||||
$keys[3] => $this->getCertificate(),
|
||||
$keys[4] => $this->getRevoked(),
|
||||
$keys[4] => $this->getExpiresOn(),
|
||||
$keys[5] => $this->getRevoked(),
|
||||
$keys[6] => $this->getSerial(),
|
||||
);
|
||||
|
||||
$utc = new \DateTimeZone('utc');
|
||||
if ($result[$keys[4]] instanceof \DateTime) {
|
||||
// When changing timezone we don't want to change existing instances
|
||||
$dateTime = clone $result[$keys[4]];
|
||||
$result[$keys[4]] = $dateTime->setTimezone($utc)->format('Y-m-d\TH:i:s\Z');
|
||||
}
|
||||
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||
$result[$key] = $virtualColumn;
|
||||
|
@ -995,7 +1113,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setUserid($value);
|
||||
$this->setUserId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setName($value);
|
||||
|
@ -1004,8 +1122,14 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->setCertificate($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setExpiresOn($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setRevoked($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setSerial($value);
|
||||
break;
|
||||
} // switch()
|
||||
|
||||
return $this;
|
||||
|
@ -1036,7 +1160,7 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->setId($arr[$keys[0]]);
|
||||
}
|
||||
if (array_key_exists($keys[1], $arr)) {
|
||||
$this->setUserid($arr[$keys[1]]);
|
||||
$this->setUserId($arr[$keys[1]]);
|
||||
}
|
||||
if (array_key_exists($keys[2], $arr)) {
|
||||
$this->setName($arr[$keys[2]]);
|
||||
|
@ -1045,7 +1169,13 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->setCertificate($arr[$keys[3]]);
|
||||
}
|
||||
if (array_key_exists($keys[4], $arr)) {
|
||||
$this->setRevoked($arr[$keys[4]]);
|
||||
$this->setExpiresOn($arr[$keys[4]]);
|
||||
}
|
||||
if (array_key_exists($keys[5], $arr)) {
|
||||
$this->setRevoked($arr[$keys[5]]);
|
||||
}
|
||||
if (array_key_exists($keys[6], $arr)) {
|
||||
$this->setSerial($arr[$keys[6]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,8 +1221,8 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(CertificateTableMap::COL_ID)) {
|
||||
$criteria->add(CertificateTableMap::COL_ID, $this->id);
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_USERID)) {
|
||||
$criteria->add(CertificateTableMap::COL_USERID, $this->userid);
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_USER_ID)) {
|
||||
$criteria->add(CertificateTableMap::COL_USER_ID, $this->user_id);
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_NAME)) {
|
||||
$criteria->add(CertificateTableMap::COL_NAME, $this->name);
|
||||
|
@ -1100,9 +1230,15 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(CertificateTableMap::COL_CERTIFICATE)) {
|
||||
$criteria->add(CertificateTableMap::COL_CERTIFICATE, $this->certificate);
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_EXPIRES_ON)) {
|
||||
$criteria->add(CertificateTableMap::COL_EXPIRES_ON, $this->expires_on);
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_REVOKED)) {
|
||||
$criteria->add(CertificateTableMap::COL_REVOKED, $this->revoked);
|
||||
}
|
||||
if ($this->isColumnModified(CertificateTableMap::COL_SERIAL)) {
|
||||
$criteria->add(CertificateTableMap::COL_SERIAL, $this->serial);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
@ -1189,10 +1325,12 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setUserid($this->getUserid());
|
||||
$copyObj->setUserId($this->getUserId());
|
||||
$copyObj->setName($this->getName());
|
||||
$copyObj->setCertificate($this->getCertificate());
|
||||
$copyObj->setExpiresOn($this->getExpiresOn());
|
||||
$copyObj->setRevoked($this->getRevoked());
|
||||
$copyObj->setSerial($this->getSerial());
|
||||
if ($makeNew) {
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
|
@ -1231,9 +1369,9 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
public function setUser(ChildUser $v = null)
|
||||
{
|
||||
if ($v === null) {
|
||||
$this->setUserid(NULL);
|
||||
$this->setUserId(NULL);
|
||||
} else {
|
||||
$this->setUserid($v->getId());
|
||||
$this->setUserId($v->getId());
|
||||
}
|
||||
|
||||
$this->aUser = $v;
|
||||
|
@ -1258,8 +1396,8 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
*/
|
||||
public function getUser(ConnectionInterface $con = null)
|
||||
{
|
||||
if ($this->aUser === null && ($this->userid !== null)) {
|
||||
$this->aUser = ChildUserQuery::create()->findPk($this->userid, $con);
|
||||
if ($this->aUser === null && ($this->user_id !== null)) {
|
||||
$this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con);
|
||||
/* The following can be used additionally to
|
||||
guarantee the related object contains a reference
|
||||
to this object. This level of coupling may, however, be
|
||||
|
@ -1283,10 +1421,12 @@ abstract class Certificate implements ActiveRecordInterface
|
|||
$this->aUser->removeCertificate($this);
|
||||
}
|
||||
$this->id = null;
|
||||
$this->userid = null;
|
||||
$this->user_id = null;
|
||||
$this->name = null;
|
||||
$this->certificate = null;
|
||||
$this->expires_on = null;
|
||||
$this->revoked = null;
|
||||
$this->serial = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->clearAllReferences();
|
||||
$this->applyDefaultValues();
|
||||
|
|
|
@ -21,16 +21,20 @@ use Propel\Runtime\Exception\PropelException;
|
|||
*
|
||||
*
|
||||
* @method ChildCertificateQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildCertificateQuery orderByUserid($order = Criteria::ASC) Order by the userId column
|
||||
* @method ChildCertificateQuery orderByUserId($order = Criteria::ASC) Order by the user_id column
|
||||
* @method ChildCertificateQuery orderByName($order = Criteria::ASC) Order by the name column
|
||||
* @method ChildCertificateQuery orderByCertificate($order = Criteria::ASC) Order by the certificate column
|
||||
* @method ChildCertificateQuery orderByExpiresOn($order = Criteria::ASC) Order by the expires_on column
|
||||
* @method ChildCertificateQuery orderByRevoked($order = Criteria::ASC) Order by the revoked column
|
||||
* @method ChildCertificateQuery orderBySerial($order = Criteria::ASC) Order by the serial column
|
||||
*
|
||||
* @method ChildCertificateQuery groupById() Group by the id column
|
||||
* @method ChildCertificateQuery groupByUserid() Group by the userId column
|
||||
* @method ChildCertificateQuery groupByUserId() Group by the user_id column
|
||||
* @method ChildCertificateQuery groupByName() Group by the name column
|
||||
* @method ChildCertificateQuery groupByCertificate() Group by the certificate column
|
||||
* @method ChildCertificateQuery groupByExpiresOn() Group by the expires_on column
|
||||
* @method ChildCertificateQuery groupByRevoked() Group by the revoked column
|
||||
* @method ChildCertificateQuery groupBySerial() Group by the serial column
|
||||
*
|
||||
* @method ChildCertificateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCertificateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
|
@ -46,26 +50,32 @@ use Propel\Runtime\Exception\PropelException;
|
|||
* @method ChildCertificate findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCertificate matching the query, or a new ChildCertificate object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCertificate findOneById(int $id) Return the first ChildCertificate filtered by the id column
|
||||
* @method ChildCertificate findOneByUserid(int $userId) Return the first ChildCertificate filtered by the userId column
|
||||
* @method ChildCertificate findOneByUserId(int $user_id) Return the first ChildCertificate filtered by the user_id column
|
||||
* @method ChildCertificate findOneByName(string $name) Return the first ChildCertificate filtered by the name column
|
||||
* @method ChildCertificate findOneByCertificate(string $certificate) Return the first ChildCertificate filtered by the certificate column
|
||||
* @method ChildCertificate findOneByRevoked(boolean $revoked) Return the first ChildCertificate filtered by the revoked column *
|
||||
* @method ChildCertificate findOneByExpiresOn(string $expires_on) Return the first ChildCertificate filtered by the expires_on column
|
||||
* @method ChildCertificate findOneByRevoked(boolean $revoked) Return the first ChildCertificate filtered by the revoked column
|
||||
* @method ChildCertificate findOneBySerial(string $serial) Return the first ChildCertificate filtered by the serial column *
|
||||
|
||||
* @method ChildCertificate requirePk($key, ConnectionInterface $con = null) Return the ChildCertificate by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOne(ConnectionInterface $con = null) Return the first ChildCertificate matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
*
|
||||
* @method ChildCertificate requireOneById(int $id) Return the first ChildCertificate filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByUserid(int $userId) Return the first ChildCertificate filtered by the userId column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByUserId(int $user_id) Return the first ChildCertificate filtered by the user_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByName(string $name) Return the first ChildCertificate filtered by the name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByCertificate(string $certificate) Return the first ChildCertificate filtered by the certificate column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByExpiresOn(string $expires_on) Return the first ChildCertificate filtered by the expires_on column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneByRevoked(boolean $revoked) Return the first ChildCertificate filtered by the revoked column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildCertificate requireOneBySerial(string $serial) Return the first ChildCertificate filtered by the serial column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
*
|
||||
* @method ChildCertificate[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildCertificate objects based on current ModelCriteria
|
||||
* @method ChildCertificate[]|ObjectCollection findById(int $id) Return ChildCertificate objects filtered by the id column
|
||||
* @method ChildCertificate[]|ObjectCollection findByUserid(int $userId) Return ChildCertificate objects filtered by the userId column
|
||||
* @method ChildCertificate[]|ObjectCollection findByUserId(int $user_id) Return ChildCertificate objects filtered by the user_id column
|
||||
* @method ChildCertificate[]|ObjectCollection findByName(string $name) Return ChildCertificate objects filtered by the name column
|
||||
* @method ChildCertificate[]|ObjectCollection findByCertificate(string $certificate) Return ChildCertificate objects filtered by the certificate column
|
||||
* @method ChildCertificate[]|ObjectCollection findByExpiresOn(string $expires_on) Return ChildCertificate objects filtered by the expires_on column
|
||||
* @method ChildCertificate[]|ObjectCollection findByRevoked(boolean $revoked) Return ChildCertificate objects filtered by the revoked column
|
||||
* @method ChildCertificate[]|ObjectCollection findBySerial(string $serial) Return ChildCertificate objects filtered by the serial column
|
||||
* @method ChildCertificate[]|\Propel\Runtime\Util\PropelModelPager paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null) Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit
|
||||
*
|
||||
*/
|
||||
|
@ -158,7 +168,7 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
*/
|
||||
protected function findPkSimple($key, ConnectionInterface $con)
|
||||
{
|
||||
$sql = 'SELECT id, userId, name, certificate, revoked FROM Certificate WHERE id = :p0';
|
||||
$sql = 'SELECT id, user_id, name, certificate, expires_on, revoked, serial FROM Certificate WHERE id = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
|
@ -290,18 +300,18 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the userId column
|
||||
* Filter the query on the user_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByUserid(1234); // WHERE userId = 1234
|
||||
* $query->filterByUserid(array(12, 34)); // WHERE userId IN (12, 34)
|
||||
* $query->filterByUserid(array('min' => 12)); // WHERE userId > 12
|
||||
* $query->filterByUserId(1234); // WHERE user_id = 1234
|
||||
* $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34)
|
||||
* $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByUser()
|
||||
*
|
||||
* @param mixed $userid The value to use as filter.
|
||||
* @param mixed $userId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
|
@ -309,16 +319,16 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
*
|
||||
* @return $this|ChildCertificateQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByUserid($userid = null, $comparison = null)
|
||||
public function filterByUserId($userId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($userid)) {
|
||||
if (is_array($userId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($userid['min'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_USERID, $userid['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($userId['min'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($userid['max'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_USERID, $userid['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($userId['max'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
|
@ -329,7 +339,7 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CertificateTableMap::COL_USERID, $userid, $comparison);
|
||||
return $this->addUsingAlias(CertificateTableMap::COL_USER_ID, $userId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,6 +400,49 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CertificateTableMap::COL_CERTIFICATE, $certificate, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the expires_on column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByExpiresOn('2011-03-14'); // WHERE expires_on = '2011-03-14'
|
||||
* $query->filterByExpiresOn('now'); // WHERE expires_on = '2011-03-14'
|
||||
* $query->filterByExpiresOn(array('max' => 'yesterday')); // WHERE expires_on > '2011-03-13'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $expiresOn The value to use as filter.
|
||||
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||
* Empty strings are treated as NULL.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return $this|ChildCertificateQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByExpiresOn($expiresOn = null, $comparison = null)
|
||||
{
|
||||
if (is_array($expiresOn)) {
|
||||
$useMinMax = false;
|
||||
if (isset($expiresOn['min'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_EXPIRES_ON, $expiresOn['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($expiresOn['max'])) {
|
||||
$this->addUsingAlias(CertificateTableMap::COL_EXPIRES_ON, $expiresOn['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CertificateTableMap::COL_EXPIRES_ON, $expiresOn, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the revoked column
|
||||
*
|
||||
|
@ -417,6 +470,35 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CertificateTableMap::COL_REVOKED, $revoked, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the serial column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterBySerial('fooValue'); // WHERE serial = 'fooValue'
|
||||
* $query->filterBySerial('%fooValue%'); // WHERE serial LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $serial The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return $this|ChildCertificateQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterBySerial($serial = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($serial)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $serial)) {
|
||||
$serial = str_replace('*', '%', $serial);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CertificateTableMap::COL_SERIAL, $serial, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Eater\Glim\Model\User object
|
||||
*
|
||||
|
@ -431,14 +513,14 @@ abstract class CertificateQuery extends ModelCriteria
|
|||
{
|
||||
if ($user instanceof \Eater\Glim\Model\User) {
|
||||
return $this
|
||||
->addUsingAlias(CertificateTableMap::COL_USERID, $user->getId(), $comparison);
|
||||
->addUsingAlias(CertificateTableMap::COL_USER_ID, $user->getId(), $comparison);
|
||||
} elseif ($user instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CertificateTableMap::COL_USERID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
->addUsingAlias(CertificateTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByUser() only accepts arguments of type \Eater\Glim\Model\User or Collection');
|
||||
}
|
||||
|
|
|
@ -70,11 +70,11 @@ abstract class User implements ActiveRecordInterface
|
|||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the maxkeys field.
|
||||
* The value for the max_keys field.
|
||||
* Note: this column has a database default value of: 5
|
||||
* @var int
|
||||
*/
|
||||
protected $maxkeys;
|
||||
protected $max_keys;
|
||||
|
||||
/**
|
||||
* The value for the username field.
|
||||
|
@ -123,7 +123,7 @@ abstract class User implements ActiveRecordInterface
|
|||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->maxkeys = 5;
|
||||
$this->max_keys = 5;
|
||||
$this->superuser = false;
|
||||
}
|
||||
|
||||
|
@ -357,13 +357,13 @@ abstract class User implements ActiveRecordInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the [maxkeys] column value.
|
||||
* Get the [max_keys] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxkeys()
|
||||
public function getMaxKeys()
|
||||
{
|
||||
return $this->maxkeys;
|
||||
return $this->max_keys;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,24 +427,24 @@ abstract class User implements ActiveRecordInterface
|
|||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [maxkeys] column.
|
||||
* Set the value of [max_keys] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return $this|\Eater\Glim\Model\User The current object (for fluent API support)
|
||||
*/
|
||||
public function setMaxkeys($v)
|
||||
public function setMaxKeys($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->maxkeys !== $v) {
|
||||
$this->maxkeys = $v;
|
||||
$this->modifiedColumns[UserTableMap::COL_MAXKEYS] = true;
|
||||
if ($this->max_keys !== $v) {
|
||||
$this->max_keys = $v;
|
||||
$this->modifiedColumns[UserTableMap::COL_MAX_KEYS] = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setMaxkeys()
|
||||
} // setMaxKeys()
|
||||
|
||||
/**
|
||||
* Set the value of [username] column.
|
||||
|
@ -524,7 +524,7 @@ abstract class User implements ActiveRecordInterface
|
|||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->maxkeys !== 5) {
|
||||
if ($this->max_keys !== 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -561,8 +561,8 @@ abstract class User implements ActiveRecordInterface
|
|||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : UserTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('Maxkeys', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->maxkeys = (null !== $col) ? (int) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('MaxKeys', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->max_keys = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Username', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->username = (null !== $col) ? (string) $col : null;
|
||||
|
@ -800,8 +800,8 @@ abstract class User implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(UserTableMap::COL_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'id';
|
||||
}
|
||||
if ($this->isColumnModified(UserTableMap::COL_MAXKEYS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'maxKeys';
|
||||
if ($this->isColumnModified(UserTableMap::COL_MAX_KEYS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'max_keys';
|
||||
}
|
||||
if ($this->isColumnModified(UserTableMap::COL_USERNAME)) {
|
||||
$modifiedColumns[':p' . $index++] = 'username';
|
||||
|
@ -826,8 +826,8 @@ abstract class User implements ActiveRecordInterface
|
|||
case 'id':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'maxKeys':
|
||||
$stmt->bindValue($identifier, $this->maxkeys, PDO::PARAM_INT);
|
||||
case 'max_keys':
|
||||
$stmt->bindValue($identifier, $this->max_keys, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'username':
|
||||
$stmt->bindValue($identifier, $this->username, PDO::PARAM_STR);
|
||||
|
@ -904,7 +904,7 @@ abstract class User implements ActiveRecordInterface
|
|||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getMaxkeys();
|
||||
return $this->getMaxKeys();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getUsername();
|
||||
|
@ -946,7 +946,7 @@ abstract class User implements ActiveRecordInterface
|
|||
$keys = UserTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getMaxkeys(),
|
||||
$keys[1] => $this->getMaxKeys(),
|
||||
$keys[2] => $this->getUsername(),
|
||||
$keys[3] => $this->getPassword(),
|
||||
$keys[4] => $this->getSuperuser(),
|
||||
|
@ -1010,7 +1010,7 @@ abstract class User implements ActiveRecordInterface
|
|||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setMaxkeys($value);
|
||||
$this->setMaxKeys($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setUsername($value);
|
||||
|
@ -1051,7 +1051,7 @@ abstract class User implements ActiveRecordInterface
|
|||
$this->setId($arr[$keys[0]]);
|
||||
}
|
||||
if (array_key_exists($keys[1], $arr)) {
|
||||
$this->setMaxkeys($arr[$keys[1]]);
|
||||
$this->setMaxKeys($arr[$keys[1]]);
|
||||
}
|
||||
if (array_key_exists($keys[2], $arr)) {
|
||||
$this->setUsername($arr[$keys[2]]);
|
||||
|
@ -1106,8 +1106,8 @@ abstract class User implements ActiveRecordInterface
|
|||
if ($this->isColumnModified(UserTableMap::COL_ID)) {
|
||||
$criteria->add(UserTableMap::COL_ID, $this->id);
|
||||
}
|
||||
if ($this->isColumnModified(UserTableMap::COL_MAXKEYS)) {
|
||||
$criteria->add(UserTableMap::COL_MAXKEYS, $this->maxkeys);
|
||||
if ($this->isColumnModified(UserTableMap::COL_MAX_KEYS)) {
|
||||
$criteria->add(UserTableMap::COL_MAX_KEYS, $this->max_keys);
|
||||
}
|
||||
if ($this->isColumnModified(UserTableMap::COL_USERNAME)) {
|
||||
$criteria->add(UserTableMap::COL_USERNAME, $this->username);
|
||||
|
@ -1204,7 +1204,7 @@ abstract class User implements ActiveRecordInterface
|
|||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setMaxkeys($this->getMaxkeys());
|
||||
$copyObj->setMaxKeys($this->getMaxKeys());
|
||||
$copyObj->setUsername($this->getUsername());
|
||||
$copyObj->setPassword($this->getPassword());
|
||||
$copyObj->setSuperuser($this->getSuperuser());
|
||||
|
@ -1492,7 +1492,7 @@ abstract class User implements ActiveRecordInterface
|
|||
public function clear()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->maxkeys = null;
|
||||
$this->max_keys = null;
|
||||
$this->username = null;
|
||||
$this->password = null;
|
||||
$this->superuser = null;
|
||||
|
|
|
@ -21,13 +21,13 @@ use Propel\Runtime\Exception\PropelException;
|
|||
*
|
||||
*
|
||||
* @method ChildUserQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildUserQuery orderByMaxkeys($order = Criteria::ASC) Order by the maxKeys column
|
||||
* @method ChildUserQuery orderByMaxKeys($order = Criteria::ASC) Order by the max_keys column
|
||||
* @method ChildUserQuery orderByUsername($order = Criteria::ASC) Order by the username column
|
||||
* @method ChildUserQuery orderByPassword($order = Criteria::ASC) Order by the password column
|
||||
* @method ChildUserQuery orderBySuperuser($order = Criteria::ASC) Order by the superuser column
|
||||
*
|
||||
* @method ChildUserQuery groupById() Group by the id column
|
||||
* @method ChildUserQuery groupByMaxkeys() Group by the maxKeys column
|
||||
* @method ChildUserQuery groupByMaxKeys() Group by the max_keys column
|
||||
* @method ChildUserQuery groupByUsername() Group by the username column
|
||||
* @method ChildUserQuery groupByPassword() Group by the password column
|
||||
* @method ChildUserQuery groupBySuperuser() Group by the superuser column
|
||||
|
@ -46,7 +46,7 @@ use Propel\Runtime\Exception\PropelException;
|
|||
* @method ChildUser findOneOrCreate(ConnectionInterface $con = null) Return the first ChildUser matching the query, or a new ChildUser object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildUser findOneById(int $id) Return the first ChildUser filtered by the id column
|
||||
* @method ChildUser findOneByMaxkeys(int $maxKeys) Return the first ChildUser filtered by the maxKeys column
|
||||
* @method ChildUser findOneByMaxKeys(int $max_keys) Return the first ChildUser filtered by the max_keys column
|
||||
* @method ChildUser findOneByUsername(string $username) Return the first ChildUser filtered by the username column
|
||||
* @method ChildUser findOneByPassword(string $password) Return the first ChildUser filtered by the password column
|
||||
* @method ChildUser findOneBySuperuser(boolean $superuser) Return the first ChildUser filtered by the superuser column *
|
||||
|
@ -55,14 +55,14 @@ use Propel\Runtime\Exception\PropelException;
|
|||
* @method ChildUser requireOne(ConnectionInterface $con = null) Return the first ChildUser matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
*
|
||||
* @method ChildUser requireOneById(int $id) Return the first ChildUser filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildUser requireOneByMaxkeys(int $maxKeys) Return the first ChildUser filtered by the maxKeys column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildUser requireOneByMaxKeys(int $max_keys) Return the first ChildUser filtered by the max_keys column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildUser requireOneByUsername(string $username) Return the first ChildUser filtered by the username column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildUser requireOneByPassword(string $password) Return the first ChildUser filtered by the password column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
* @method ChildUser requireOneBySuperuser(boolean $superuser) Return the first ChildUser filtered by the superuser column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
|
||||
*
|
||||
* @method ChildUser[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildUser objects based on current ModelCriteria
|
||||
* @method ChildUser[]|ObjectCollection findById(int $id) Return ChildUser objects filtered by the id column
|
||||
* @method ChildUser[]|ObjectCollection findByMaxkeys(int $maxKeys) Return ChildUser objects filtered by the maxKeys column
|
||||
* @method ChildUser[]|ObjectCollection findByMaxKeys(int $max_keys) Return ChildUser objects filtered by the max_keys column
|
||||
* @method ChildUser[]|ObjectCollection findByUsername(string $username) Return ChildUser objects filtered by the username column
|
||||
* @method ChildUser[]|ObjectCollection findByPassword(string $password) Return ChildUser objects filtered by the password column
|
||||
* @method ChildUser[]|ObjectCollection findBySuperuser(boolean $superuser) Return ChildUser objects filtered by the superuser column
|
||||
|
@ -158,7 +158,7 @@ abstract class UserQuery extends ModelCriteria
|
|||
*/
|
||||
protected function findPkSimple($key, ConnectionInterface $con)
|
||||
{
|
||||
$sql = 'SELECT id, maxKeys, username, password, superuser FROM User WHERE id = :p0';
|
||||
$sql = 'SELECT id, max_keys, username, password, superuser FROM User WHERE id = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
|
@ -290,16 +290,16 @@ abstract class UserQuery extends ModelCriteria
|
|||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the maxKeys column
|
||||
* Filter the query on the max_keys column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByMaxkeys(1234); // WHERE maxKeys = 1234
|
||||
* $query->filterByMaxkeys(array(12, 34)); // WHERE maxKeys IN (12, 34)
|
||||
* $query->filterByMaxkeys(array('min' => 12)); // WHERE maxKeys > 12
|
||||
* $query->filterByMaxKeys(1234); // WHERE max_keys = 1234
|
||||
* $query->filterByMaxKeys(array(12, 34)); // WHERE max_keys IN (12, 34)
|
||||
* $query->filterByMaxKeys(array('min' => 12)); // WHERE max_keys > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $maxkeys The value to use as filter.
|
||||
* @param mixed $maxKeys The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
|
@ -307,16 +307,16 @@ abstract class UserQuery extends ModelCriteria
|
|||
*
|
||||
* @return $this|ChildUserQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByMaxkeys($maxkeys = null, $comparison = null)
|
||||
public function filterByMaxKeys($maxKeys = null, $comparison = null)
|
||||
{
|
||||
if (is_array($maxkeys)) {
|
||||
if (is_array($maxKeys)) {
|
||||
$useMinMax = false;
|
||||
if (isset($maxkeys['min'])) {
|
||||
$this->addUsingAlias(UserTableMap::COL_MAXKEYS, $maxkeys['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($maxKeys['min'])) {
|
||||
$this->addUsingAlias(UserTableMap::COL_MAX_KEYS, $maxKeys['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($maxkeys['max'])) {
|
||||
$this->addUsingAlias(UserTableMap::COL_MAXKEYS, $maxkeys['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($maxKeys['max'])) {
|
||||
$this->addUsingAlias(UserTableMap::COL_MAX_KEYS, $maxKeys['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
|
@ -327,7 +327,7 @@ abstract class UserQuery extends ModelCriteria
|
|||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(UserTableMap::COL_MAXKEYS, $maxkeys, $comparison);
|
||||
return $this->addUsingAlias(UserTableMap::COL_MAX_KEYS, $maxKeys, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,7 +427,7 @@ abstract class UserQuery extends ModelCriteria
|
|||
{
|
||||
if ($certificate instanceof \Eater\Glim\Model\Certificate) {
|
||||
return $this
|
||||
->addUsingAlias(UserTableMap::COL_ID, $certificate->getUserid(), $comparison);
|
||||
->addUsingAlias(UserTableMap::COL_ID, $certificate->getUserId(), $comparison);
|
||||
} elseif ($certificate instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCertificateQuery()
|
||||
|
|
|
@ -59,7 +59,7 @@ class CertificateTableMap extends TableMap
|
|||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 5;
|
||||
const NUM_COLUMNS = 7;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
|
@ -69,7 +69,7 @@ class CertificateTableMap extends TableMap
|
|||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 5;
|
||||
const NUM_HYDRATE_COLUMNS = 7;
|
||||
|
||||
/**
|
||||
* the column name for the id field
|
||||
|
@ -77,9 +77,9 @@ class CertificateTableMap extends TableMap
|
|||
const COL_ID = 'Certificate.id';
|
||||
|
||||
/**
|
||||
* the column name for the userId field
|
||||
* the column name for the user_id field
|
||||
*/
|
||||
const COL_USERID = 'Certificate.userId';
|
||||
const COL_USER_ID = 'Certificate.user_id';
|
||||
|
||||
/**
|
||||
* the column name for the name field
|
||||
|
@ -91,11 +91,21 @@ class CertificateTableMap extends TableMap
|
|||
*/
|
||||
const COL_CERTIFICATE = 'Certificate.certificate';
|
||||
|
||||
/**
|
||||
* the column name for the expires_on field
|
||||
*/
|
||||
const COL_EXPIRES_ON = 'Certificate.expires_on';
|
||||
|
||||
/**
|
||||
* the column name for the revoked field
|
||||
*/
|
||||
const COL_REVOKED = 'Certificate.revoked';
|
||||
|
||||
/**
|
||||
* the column name for the serial field
|
||||
*/
|
||||
const COL_SERIAL = 'Certificate.serial';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
|
@ -108,11 +118,11 @@ class CertificateTableMap extends TableMap
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Userid', 'Name', 'Certificate', 'Revoked', ),
|
||||
self::TYPE_CAMELNAME => array('id', 'userid', 'name', 'certificate', 'revoked', ),
|
||||
self::TYPE_COLNAME => array(CertificateTableMap::COL_ID, CertificateTableMap::COL_USERID, CertificateTableMap::COL_NAME, CertificateTableMap::COL_CERTIFICATE, CertificateTableMap::COL_REVOKED, ),
|
||||
self::TYPE_FIELDNAME => array('id', 'userId', 'name', 'certificate', 'revoked', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
self::TYPE_PHPNAME => array('Id', 'UserId', 'Name', 'Certificate', 'ExpiresOn', 'Revoked', 'Serial', ),
|
||||
self::TYPE_CAMELNAME => array('id', 'userId', 'name', 'certificate', 'expiresOn', 'revoked', 'serial', ),
|
||||
self::TYPE_COLNAME => array(CertificateTableMap::COL_ID, CertificateTableMap::COL_USER_ID, CertificateTableMap::COL_NAME, CertificateTableMap::COL_CERTIFICATE, CertificateTableMap::COL_EXPIRES_ON, CertificateTableMap::COL_REVOKED, CertificateTableMap::COL_SERIAL, ),
|
||||
self::TYPE_FIELDNAME => array('id', 'user_id', 'name', 'certificate', 'expires_on', 'revoked', 'serial', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -122,11 +132,11 @@ class CertificateTableMap extends TableMap
|
|||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Userid' => 1, 'Name' => 2, 'Certificate' => 3, 'Revoked' => 4, ),
|
||||
self::TYPE_CAMELNAME => array('id' => 0, 'userid' => 1, 'name' => 2, 'certificate' => 3, 'revoked' => 4, ),
|
||||
self::TYPE_COLNAME => array(CertificateTableMap::COL_ID => 0, CertificateTableMap::COL_USERID => 1, CertificateTableMap::COL_NAME => 2, CertificateTableMap::COL_CERTIFICATE => 3, CertificateTableMap::COL_REVOKED => 4, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'userId' => 1, 'name' => 2, 'certificate' => 3, 'revoked' => 4, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'UserId' => 1, 'Name' => 2, 'Certificate' => 3, 'ExpiresOn' => 4, 'Revoked' => 5, 'Serial' => 6, ),
|
||||
self::TYPE_CAMELNAME => array('id' => 0, 'userId' => 1, 'name' => 2, 'certificate' => 3, 'expiresOn' => 4, 'revoked' => 5, 'serial' => 6, ),
|
||||
self::TYPE_COLNAME => array(CertificateTableMap::COL_ID => 0, CertificateTableMap::COL_USER_ID => 1, CertificateTableMap::COL_NAME => 2, CertificateTableMap::COL_CERTIFICATE => 3, CertificateTableMap::COL_EXPIRES_ON => 4, CertificateTableMap::COL_REVOKED => 5, CertificateTableMap::COL_SERIAL => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'user_id' => 1, 'name' => 2, 'certificate' => 3, 'expires_on' => 4, 'revoked' => 5, 'serial' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -147,10 +157,12 @@ class CertificateTableMap extends TableMap
|
|||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('userId', 'Userid', 'INTEGER', 'User', 'id', false, null, null);
|
||||
$this->addForeignKey('user_id', 'UserId', 'INTEGER', 'User', 'id', false, null, null);
|
||||
$this->addColumn('name', 'Name', 'VARCHAR', false, 64, null);
|
||||
$this->addColumn('certificate', 'Certificate', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('expires_on', 'ExpiresOn', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('revoked', 'Revoked', 'BOOLEAN', false, null, false);
|
||||
$this->addColumn('serial', 'Serial', 'VARCHAR', false, 64, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
|
@ -161,7 +173,7 @@ class CertificateTableMap extends TableMap
|
|||
$this->addRelation('User', '\\Eater\\Glim\\Model\\User', RelationMap::MANY_TO_ONE, array (
|
||||
0 =>
|
||||
array (
|
||||
0 => ':userId',
|
||||
0 => ':user_id',
|
||||
1 => ':id',
|
||||
),
|
||||
), null, null, null, false);
|
||||
|
@ -309,16 +321,20 @@ class CertificateTableMap extends TableMap
|
|||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_ID);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_USERID);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_USER_ID);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_NAME);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_CERTIFICATE);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_EXPIRES_ON);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_REVOKED);
|
||||
$criteria->addSelectColumn(CertificateTableMap::COL_SERIAL);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.id');
|
||||
$criteria->addSelectColumn($alias . '.userId');
|
||||
$criteria->addSelectColumn($alias . '.user_id');
|
||||
$criteria->addSelectColumn($alias . '.name');
|
||||
$criteria->addSelectColumn($alias . '.certificate');
|
||||
$criteria->addSelectColumn($alias . '.expires_on');
|
||||
$criteria->addSelectColumn($alias . '.revoked');
|
||||
$criteria->addSelectColumn($alias . '.serial');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ class UserTableMap extends TableMap
|
|||
const COL_ID = 'User.id';
|
||||
|
||||
/**
|
||||
* the column name for the maxKeys field
|
||||
* the column name for the max_keys field
|
||||
*/
|
||||
const COL_MAXKEYS = 'User.maxKeys';
|
||||
const COL_MAX_KEYS = 'User.max_keys';
|
||||
|
||||
/**
|
||||
* the column name for the username field
|
||||
|
@ -108,10 +108,10 @@ class UserTableMap extends TableMap
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Maxkeys', 'Username', 'Password', 'Superuser', ),
|
||||
self::TYPE_CAMELNAME => array('id', 'maxkeys', 'username', 'password', 'superuser', ),
|
||||
self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_MAXKEYS, UserTableMap::COL_USERNAME, UserTableMap::COL_PASSWORD, UserTableMap::COL_SUPERUSER, ),
|
||||
self::TYPE_FIELDNAME => array('id', 'maxKeys', 'username', 'password', 'superuser', ),
|
||||
self::TYPE_PHPNAME => array('Id', 'MaxKeys', 'Username', 'Password', 'Superuser', ),
|
||||
self::TYPE_CAMELNAME => array('id', 'maxKeys', 'username', 'password', 'superuser', ),
|
||||
self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_MAX_KEYS, UserTableMap::COL_USERNAME, UserTableMap::COL_PASSWORD, UserTableMap::COL_SUPERUSER, ),
|
||||
self::TYPE_FIELDNAME => array('id', 'max_keys', 'username', 'password', 'superuser', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
|
@ -122,10 +122,10 @@ class UserTableMap extends TableMap
|
|||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Maxkeys' => 1, 'Username' => 2, 'Password' => 3, 'Superuser' => 4, ),
|
||||
self::TYPE_CAMELNAME => array('id' => 0, 'maxkeys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, ),
|
||||
self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_MAXKEYS => 1, UserTableMap::COL_USERNAME => 2, UserTableMap::COL_PASSWORD => 3, UserTableMap::COL_SUPERUSER => 4, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'maxKeys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, ),
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'MaxKeys' => 1, 'Username' => 2, 'Password' => 3, 'Superuser' => 4, ),
|
||||
self::TYPE_CAMELNAME => array('id' => 0, 'maxKeys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, ),
|
||||
self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_MAX_KEYS => 1, UserTableMap::COL_USERNAME => 2, UserTableMap::COL_PASSWORD => 3, UserTableMap::COL_SUPERUSER => 4, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'max_keys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
|
@ -147,7 +147,7 @@ class UserTableMap extends TableMap
|
|||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('maxKeys', 'Maxkeys', 'INTEGER', false, null, 5);
|
||||
$this->addColumn('max_keys', 'MaxKeys', 'INTEGER', false, null, 5);
|
||||
$this->addColumn('username', 'Username', 'VARCHAR', false, 64, null);
|
||||
$this->addColumn('password', 'Password', 'VARCHAR', false, 64, null);
|
||||
$this->addColumn('superuser', 'Superuser', 'BOOLEAN', false, null, false);
|
||||
|
@ -161,7 +161,7 @@ class UserTableMap extends TableMap
|
|||
$this->addRelation('Certificate', '\\Eater\\Glim\\Model\\Certificate', RelationMap::ONE_TO_MANY, array (
|
||||
0 =>
|
||||
array (
|
||||
0 => ':userId',
|
||||
0 => ':user_id',
|
||||
1 => ':id',
|
||||
),
|
||||
), null, null, 'Certificates', false);
|
||||
|
@ -309,13 +309,13 @@ class UserTableMap extends TableMap
|
|||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(UserTableMap::COL_ID);
|
||||
$criteria->addSelectColumn(UserTableMap::COL_MAXKEYS);
|
||||
$criteria->addSelectColumn(UserTableMap::COL_MAX_KEYS);
|
||||
$criteria->addSelectColumn(UserTableMap::COL_USERNAME);
|
||||
$criteria->addSelectColumn(UserTableMap::COL_PASSWORD);
|
||||
$criteria->addSelectColumn(UserTableMap::COL_SUPERUSER);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.id');
|
||||
$criteria->addSelectColumn($alias . '.maxKeys');
|
||||
$criteria->addSelectColumn($alias . '.max_keys');
|
||||
$criteria->addSelectColumn($alias . '.username');
|
||||
$criteria->addSelectColumn($alias . '.password');
|
||||
$criteria->addSelectColumn($alias . '.superuser');
|
||||
|
|
73
src/Service/CA.php
Normal file
73
src/Service/CA.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: eater
|
||||
* Date: 4/4/16
|
||||
* Time: 9:25 PM
|
||||
*/
|
||||
|
||||
namespace Eater\Glim\Service;
|
||||
|
||||
|
||||
use Eater\Glim\Core;
|
||||
|
||||
class CA extends Main
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOpenSslError()
|
||||
{
|
||||
$error = "";
|
||||
while ($msg = openssl_error_string()) {
|
||||
$error .= $msg . "\n";
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a client certificate and returns the signed certificate
|
||||
* @param string $csr
|
||||
* @return string
|
||||
*/
|
||||
public function signClientCsr($csr)
|
||||
{
|
||||
/** @var Core $core */
|
||||
$core = $this->get('core');
|
||||
|
||||
$csrPath = tempnam(sys_get_temp_dir(), '0.');
|
||||
$crtPath = tempnam(sys_get_temp_dir(), '0.');
|
||||
|
||||
file_put_contents($csrPath, $csr);
|
||||
|
||||
exec(escapeshellcmd($core->getBaseDir() . '/bin/sign-client-csr') . ' ' . escapeshellarg($csrPath) . ' ' . escapeshellarg($crtPath) . ' 2>&1', $output, $exitCode);
|
||||
|
||||
if ($exitCode !== 0) {
|
||||
throw new \Exception("Failed signing CSR: " . implode("\n", $output));
|
||||
}
|
||||
|
||||
$crt = file_get_contents($crtPath);
|
||||
|
||||
unlink($crtPath);
|
||||
unlink($csrPath);
|
||||
|
||||
return $crt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $csr
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCommonNameFromCsr($csr)
|
||||
{
|
||||
$subject = openssl_csr_get_subject($csr);
|
||||
|
||||
if ($subject === false) {
|
||||
throw new \Exception("Failed to read CSR: " . $this->getOpenSslError());
|
||||
}
|
||||
|
||||
return $subject["CN"];
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<div class="pull-right">
|
||||
{% if user %}
|
||||
<a href="/panel" class="navbar-brand">{{ user.username }}</a>
|
||||
<a href="/panel" class="user navbar-brand">{{ user.username }}</a>
|
||||
<a href="/logout" class="navbar-brand">Logout</a>
|
||||
{% else %}
|
||||
<a class="navbar-brand" href="/login">Login</a>
|
||||
|
|
|
@ -25,10 +25,13 @@
|
|||
{{ certificate.getName() }}
|
||||
</td>
|
||||
<td>
|
||||
{{ certificate.getExpiriationDate() }}
|
||||
{{ certificate.getExpiresOn().format('Y-m-d H:i:s') }}
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<div class="div pull-right">
|
||||
<button class="revoke btn btn-warning">Revoke</button>
|
||||
<a target="_blank" href="/panel/certificates/download/{{ certificate.getName() }}" class="download btn btn-default">Download certificate</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
|
|
@ -3,28 +3,32 @@
|
|||
{% block head %}
|
||||
{{ parent() }}
|
||||
<script src="/js/forge.min.js"></script>
|
||||
<script src="/js/jszip.min.js"></script>
|
||||
<script src="/js/FileSaver.min.js"></script>
|
||||
<script src="/js/main.js"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container"></div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h2>New Certificate</h2>
|
||||
</div>
|
||||
<form action="/panel/certificates/new">
|
||||
<div class="row">
|
||||
<button class="magic-csr">Create certificate automatically</button>
|
||||
<button class="own-csr">Enter CSR</button>
|
||||
</div>
|
||||
<div class="row hidden">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-2" for="csr">CSR</label>
|
||||
<div class="col-md-10">
|
||||
<textarea class="form-control" name="csr" rows="20" id="csr"></textarea>
|
||||
</div>
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<div class="row">
|
||||
<h2>New Certificate</h2>
|
||||
</div>
|
||||
<form class="form-horizontal" action="/panel/certificates/new">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-2" for="name">Name</label>
|
||||
<div class="col-md-10">
|
||||
<input name="name" id="name" type="text" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-12">
|
||||
<button type="button" class="magic-csr btn btn-primary pull-right">Create certificate</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue