Name
CatalystX::Usul::TraitFor::ConnectInfo - Provides the DBIC connect info array ref
Version
0.1.$Rev: 0 $
Synopsis
package YourApp::Model::YourModel;
use CatalystX::Usul::Moose;
extends qw(CatalystX::Usul::Model::Schema);
__PACKAGE__->config( database => q(your_database_name),
schema_class => q(YourApp::Schema::YourSchema) );
sub COMPONENT {
my ($class, $app, $cfg) = @_;
$cfg->{connect_info} ||= $class->get_connect_info( $app, $cfg );
return $class->next::method( $app, $cfg );
}
Description
Provides the DBIC connect info array ref
Configuration and Environment
The XML data looks like this:
<credentials>
<name>database_we_want_to_connect_to.optional_subspace</name>
<driver>mysql</driver>
<host>localhost</host>
<password>{Twofish}0QqX325DLs18I8T/wU4/ZQQ=</password>
<port>3306</port>
<print_error>0</print_error>
<raise_error>1</raise_error>
<user>root</user>
</credentials>
Subroutines/Methods
decrypt_from_cfg
$plain_text = $self->decrypt_from_cfg( $app_config, $password );
Strips the {Twofish2}
prefix and then decrypts the password
dump_cfg_data
$dumped_data = $self->dump_cfg_data( $app_config, $db, $cfg_data );
Call the dump method to write the configuration file back to disk
encrypt_for_cfg
$encrypted_value = $self->encrypt_for_cfg( $app_config, $plain_text );
Returns the encrypted value of the plain value prefixed with {Twofish2}
for storage in a configuration file
extract_creds_from_cfg
$creds = $self->extract_creds_from_cfg( $app_config, $db, $cfg_data );
Returns the credential info for the specified database and (optional) subspace. The subspace attribute of $app_config
is appended to the database name to create a unique cache key
get_cipher_list
@list_of_ciphers = $self->get_cipher_list;
Returns the list of ciphers supported by Crypt::CBC. These may not all be installed
get_connect_info
$db_info_arr = $self->get_connect_info( $app_config, $db );
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 configuration file in the config ctrldir
. Multiple sets of data can be stored in the same file, keyed by the $db
argument. The password is decrypted if required
load_cfg_data
$cfg_data = $self->load_cfg_data( $app_config, $db );
Returns a hash ref of configuration file data. The path to the file can be specified in $app_config->{ctlfile}
or it will default to the $db.$extension
file in the $app_config->{ctrldir}
directory. The $extension
is either $app_config->{extension}
or $self->config->{extension}
or the default extension given by the CONFIG_EXTN
constant
Diagnostics
None
Dependencies
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
Acknowledgements
Larry Wall - For the Perl programming language
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
License and Copyright
Copyright (c) 2013 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