MT#13919 Move raw perl from dev config to plugin

Change-Id: I7c52c36bbf59b2229b960f977563c0bd089278ac
changes/24/2124/1
Andreas Granig 10 years ago
parent 7616a4cc50
commit b003cea498

@ -1361,7 +1361,7 @@ sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() {
my $data = $dev->profile->config->data;
my $processed_data = "";
my $t = Template->new({
EVAL_PERL => 1,
PLUGIN_BASE => 'NGCP::Panel::Template::Plugin',
});
$t->process(\$data, $vars, \$processed_data) || do {
my $error = $t->error();

@ -0,0 +1,31 @@
package NGCP::Panel::Template::Plugin::DeviceConfig;
use base 'Template::Plugin';
use Crypt::RC4;
sub new {
my ($class, $context) = @_;
# set error via base ::error()
# return $class->error("foo") if($foo)
bless {
_CONTEXT => $context,
}, $class;
}
sub innovaphone_pwdgen {
my ($self, $user, $pass, $plain) = @_;
my $key = $user;
my $pad = 16 - (length $user) % 16;
$key .= "\0" x $pad;
$key .= $pass;
$pad = 16 - (length $pass) % 16;
$key .= "\0" x $pad;
my $rc4 = Crypt::RC4->new($key);
my $cipher = $rc4->RC4($plain);
my $hexcipher = unpack("H*", $cipher);
return $hexcipher;
}
1;
Loading…
Cancel
Save