Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [kura-dev] another question

Hi Scott,

As Amit said, you need to use the CryptoService. If you backtrace the logic from the line you referenced, you will see the property map that the private method is using has already decrypted the passwords in the update methods.

Thanks,
--Dave
 
On Nov 9, 2016, at 12:42, Amit Kumar Mondal <admin@xxxxxxxxxxxxxx> wrote:

Hi Scott,

That’s strange. Could you try the following snippet?

    String getPassword() {
        final Object pass = this.properties.get(PASSWORD);
        Password decryptedPassword = null;
        String password = null;
        if (this.properties.containsKey(PASSWORD) && (pass != null)) {
            try {
                decryptedPassword = new Password(this.cryptoService.decryptAes(pass.toString().toCharArray()));
                password = new String(decryptedPassword.getPassword());
            } catch (final KuraException e) {
                s_logger.error(ThrowableUtil.stackTraceAsString(e));
            }
        }
        return password;
    }

This depends on CryptoService to decrypt the AES encoded password field in your Metatype attribute definition.

Hope it helps.

Thanks and Regards,


Amit Kumar Mondal
Phone: +49 176 8081 5427  Email: admin@xxxxxxxxxxxxxx
Skype: arsenalnerk   GitHub: amitjoy
Blog: blog.amitinside.com

Am 9. November 2016 um 6:31:31 PM, Lewis, ScottX (scottx.lewis@xxxxxxxxx) schrieb:

Hi David,

Yes, the MqttDataTransport class is where I got this line of code:

Password password = (Password) properties.get("password");   line 716

But when I try to do the same thing in my own code, the same throws an exception because the type of the "password" value is a String rather than Password, and has the encoded value as described below.

I'm at a loss as to why my properties contains a String rather than a Password.   I'm using the exact same AD definition that's used in the MqttDataTransport metatype.

Thanksinadvance for any info,

Scott





From: kura-dev-bounces@xxxxxxxxxxx [kura-dev-bounces@xxxxxxxxxxx] on behalf of Woodard, David [david.woodard@xxxxxxxxxxxx]
Sent: Wednesday, November 09, 2016 6:34 AM
To: Kura Developers mailing list
Subject: Re: [kura-dev] another question

Hi Scott,

Please see the example of how MqttDataTransport is using the Password class [1]. Just search for “Password” and you can find what you need.


Thanks,
--Dave

On Nov 8, 2016, at 19:05, Lewis, ScottX <scottx.lewis@xxxxxxxxx> wrote:

I'm creating a ConfigurableService and I would like to put a password into the web UI.   I looked at the metatype for the MqttDataTransport...which has a password used to connect to the cloud service...and the acd for that field looks like this:

       <AD id="password"  
           name="password"
           type="Password"
           cardinality="0"
           required="false"
           default="password"
           description="Password to be used when connecting to the MQTT broker."/>


And the code that handles this configuration looks like this:

Password password = (Password) properties.get("password");

The Password class is:  org.eclipse.kura.configuration.Password

Fair enough.   But when I put the exact same AD into my metatype, and try to use the property the following line throws an exception:

Password password = (Password) properties.get("password");

The type of the password property is not Password, but rather it's a String and what looks like a uuencoded value for the String...e.g.:  1LnomW8pXWdXQLVTfyMQ1Q==

Obviously there is something I'm doing differently to not get a Password instance via the Kura Config Admin.   Any idea what that is?

Thanksinadvance for any thoughts,

Scott



_______________________________________________
kura-dev mailing list
kura-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/kura-dev

_______________________________________________ 
kura-dev mailing list 
kura-dev@xxxxxxxxxxx 
To change your delivery options, retrieve your password, or unsubscribe from this list, visit 
https://dev.eclipse.org/mailman/listinfo/kura-dev
_______________________________________________
kura-dev mailing list
kura-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/kura-dev


Back to the top