Skip to content

Reusing CryptoHelper in cq_osgi_config #74

Description

@karoldrazek

I've tried executing following code:

cq_osgi_config 'config' do
  extend Cq::CryptoHelper
  username node['cq']['author']['credentials']['login']
  password node['cq']['author']['credentials']['password']
  instance "http://localhost:#{node['cq']['author']['port']}"
  factory_pid 'org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider'
  unique_fields [
      'provider.name'
  ]
  properties(
      'provider.name' => 'ldap',
      'host.name' => node['webapp']['ldap']['host_name'],
      'host.port' => node['webapp']['ldap']['host_port'],
      'bind.dn' => "dn_path",
      'bind.password' => encrypt(
        "http://localhost:#{node['cq']['author']['port']}",
        node['cq']['author']['credentials']['login'],
        node['cq']['author']['credentials']['password'],
        node['webapp']['ldap']['service_user']['password']
        ),
      'user.baseDN' => 'base_ou_path',
      'user.idAttribute' => 'sAMAccountName',
      'user.extraFilter' => "filters",
  )

  action :create
end

Unfortunately it seems that variable and method share the same name:
Method: https://github.com/jwadolowski/cookbook-cq/blob/master/libraries/_crypto_helper.rb#L309
Variable: https://github.com/jwadolowski/cookbook-cq/blob/master/libraries/resource_cq_osgi_config.rb#L55

which results in following error:

==> default:     ArgumentError
==> default:     -------------
==> default:     wrong number of arguments (given 0, expected 1)
==> default:
==> default:     Cookbook Trace:
==> default:     ---------------
==> default:     /var/chef/cache/cookbooks/cq/libraries/_crypto_helper.rb:309:in `sleep_time'
==> default:
==> default: /var/chef/cache/cookbooks/cq/libraries/provider_cq_osgi_config.rb:42:in `load_current_resource'
==> default:

Note: The above use of extension works fine for cq_jcr resource.

Please kindly consider enabling encrypted_fields for other resources, externalizing the CryptoHelper or at least changing the naming a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions