Name

CatalystX::Usul::Schema - Support for database schemas

Version

0.3.$Revision: 622 $

Synopsis

package CatalystX::Usul::Model::Schema;

use parent qw(Catalyst::Model::DBIC::Schema
              CatalystX::Usul::Model
              CatalystX::Usul::Schema);

package YourApp::Model::YourModel;

use base qw(CatalystX::Usul::Model::Schema);

__PACKAGE__->config( connect_info => [], schema_class => undef );

sub new {
   my ($self, $app, @rest) = @_;

   $self->config( connect_info =>
                   $self->connect_info( $app, $rest[0]->{database} ) );
   $self->config( schema_class => $rest[0]->{schema_class} );

   return $self->next::method( $app, @rest );
}

Description

Provides utility methods to classes inheriting from DBIx::Class::Schema

The encryption/decryption methods only obscure the database password from casual viewing, they do not in any way secure it

Configuration and Environment

The XML data looks like this:

<credentials>
  <name>database_we_want_to_connect_to</name>
  <driver>mysql</driver>
  <host>localhost</host>
  <password>encrypt=0QqX325DLs18I8T/wU4/ZQQ=</password>
  <port>3306</port>
  <print_error>0</print_error>
  <raise_error>1</raise_error>
  <user>root</user>
</credentials>

Subroutines/Methods

connect_info

my $info_arr = $self->connect_info( $path, $database, $seed );

Returns an array ref containing the information needed to make a connection to a database; DSN, user id, password, and options hash ref. The data is read from the XML file $path. Multiple sets of data can be stored in the same file, keyed by the $database argument. The password is decrypted if required. The $seed argument is an application dependant constant string that is used to perturb the key generator

create_ddl

Dump the database schema definition

decrypt

my $plain = $self->decrypt( $seed, $encoded );

Decodes and decrypts the $encoded argument and returns the plain text result. See the encrypt method

deploy_and_populate

Create database tables and populate them with initial data. Called as part of the application install

encrypt

my $encrypted = $self->encrypt( $seed, $plain );

Encrypts the plain text passed in the $plain argument and returns it Base64 encoded. Crypt::Twofish_PP is used to do the encryption. The $seed argument is passed to the keygen method

keygen

Generates the key used by the encrypt and decrypt methods. Calls _inflate to create the salt. Note that the salt is eval'd in string context

_inflate

Lifted from Acme::Bleach this recovers the default salt for the key generator

Diagnostics

None

Dependencies

CatalystX::Usul
Crypt::CBC
Crypt::Twofish
XML::Simple

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Copyright (c) 2008 Peter Flanigan. All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE