Namespace support for `KeyStringUtil`
Opened this issue · 8 comments
What needs to be done
When using KeyStringUtil
to extract data from a String fullKeyName
, it does not detect for namespaces.
Having trouble finding namespace from keys like:
shared_key.denise@smoothalligator
assume no namespace?
atconnections.misstremendous3.smoothalligator.at_contact.mospherepro@smoothalligator
assume namespace mospherepro
public:name.wavi@smoothalligator
assume namespace wavi
@JeremyTubongbanua is it for grabs under Hacktoberfest ?
Hey @kaggrwal, it isn't under hacktoberfest, but you are still welcome to tackle this issue! It's a unique problem related to key naming in the atProtocol. If you could just write a simple string parsing algorithm pasted in this issue (no PR), that would be amazing =)
["35d713a0-3ab6-11ed-a103-c996629303ed.at_contact.mospherepro@smoothalligator","@abbcservicesinc:shared_key@smoothalligator","@barbaras🐕🐕:shared_key@smoothalligator","@colin:shared_key@smoothalligator","@denise:shared_key@smoothalligator","@er_nobile_14:shared_key@smoothalligator","@fascinatingsnow:shared_key@smoothalligator","@hacktheleague:shared_key@smoothalligator","@hakeem💙:shared_key@smoothalligator","@k:shared_key@smoothalligator","@misstremendous3:shared_key@smoothalligator","@smoothalligator:signing_privatekey@smoothalligator","@tastelessacarajecoffee:shared_key@smoothalligator","@the50:shared_key@smoothalligator","@ultrablueexcessive:shared_key@smoothalligator","@wildgreen:shared_key@smoothalligator","atconnections.abbcservicesinc.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.barbaras🐕🐕.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.colin.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.denise.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.groupslist.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.hacktheleague.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.hakeem💙.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.k.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.misstremendous3.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.tastelessacarajecoffee.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.the50.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.ultrablueexcessive.smoothalligator.at_contact.mospherepro@smoothalligator","atconnections.wildgreen.smoothalligator.at_contact.mospherepro@smoothalligator","cached:@smoothalligator:createevent-1663880348887794.rrive@wonderfulpelican","cached:@smoothalligator:file_transfer_0f0cb9af-832e-4d9d-b011-2eed3a489dd9.mospherepro@colin","cached:@smoothalligator:file_transfer_45f25017-c119-4a0b-acf8-26e5085120c4.mospherepro@barbaras🐕🐕","cached:@smoothalligator:file_transfer_5e30af6d-e066-42cc-9517-4bd1dd8eedcc.mospherepro@colin","cached:@smoothalligator:file_transfer_a011b1b0-aa82-4d49-a6d0-97b3bc8333d0.mospherepro@k","cached:@smoothalligator:file_transfer_a81ac00e-2c4a-4c78-ada3-06e74550ef25.mospherepro@ultrablueexcessive","cached:@smoothalligator:file_transfer_c9466a56-ca6c-4f58-9ea3-03873e5d90e9.mospherepro@barbaras🐕🐕","cached:@smoothalligator:location-notify-smoothalligator.rrive@adorabledinosaur","cached:@smoothalligator:location-notify-smoothalligator.rrive@colin","cached:@smoothalligator:location-notify-smoothalligator.rrive@k","cached:@smoothalligator:location-notify-smoothalligator.rrive@wonderfulpelican","cached:@smoothalligator:shared_key@abbcservicesinc","cached:@smoothalligator:shared_key@adorabledinosaur","cached:@smoothalligator:shared_key@colin","cached:@smoothalligator:shared_key@denise","cached:@smoothalligator:shared_key@fascinatingsnow","cached:@smoothalligator:shared_key@hacktheleague","cached:@smoothalligator:shared_key@k","cached:@smoothalligator:shared_key@misstremendous3","cached:@smoothalligator:shared_key@tastelessacarajecoffee","cached:@smoothalligator:shared_key@the50","cached:@smoothalligator:shared_key@ultrablueexcessive","cached:@smoothalligator:shared_key@wildgreen","cached:@smoothalligator:shared_key@wonderfulpelican","cached:public:firstname.wavi@abbcservicesinc","cached:public:firstname.wavi@barbaras🐕🐕","cached:public:firstname.wavi@colin","cached:public:firstname.wavi@er_nobile_14","cached:public:firstname.wavi@hakeem💙","cached:public:firstname.wavi@k","cached:public:firstname.wavi@tastelessacarajecoffee","cached:public:firstname.wavi@wildgreen","cached:public:image.wavi@abbcservicesinc","cached:public:image.wavi@barbaras🐕🐕","cached:public:image.wavi@colin","cached:public:image.wavi@denise","cached:public:image.wavi@er_nobile_14","cached:public:image.wavi@hakeem💙","cached:public:image.wavi@k","cached:public:image.wavi@tastelessacarajecoffee","cached:public:image.wavi@wildgreen","cached:public:lastname.wavi@abbcservicesinc","cached:public:lastname.wavi@barbaras🐕🐕","cached:public:lastname.wavi@colin","cached:public:lastname.wavi@er_nobile_14","cached:public:lastname.wavi@hakeem💙","cached:public:lastname.wavi@k","cached:public:lastname.wavi@tastelessacarajecoffee","cached:public:lastname.wavi@wildgreen","cached:public:publickey@abbcservicesinc","cached:public:publickey@barbaras🐕🐕","cached:public:publickey@colin","cached:public:publickey@denise","cached:public:publickey@er_nobile_14","cached:public:publickey@fascinatingsnow","cached:public:publickey@hacktheleague","cached:public:publickey@hakeem💙","cached:public:publickey@k","cached:public:publickey@misstremendous3","cached:public:publickey@tastelessacarajecoffee","cached:public:publickey@the50","cached:public:publickey@ultrablueexcessive","cached:public:publickey@wildgreen","file_transfer_01c71dea-cbe6-4615-aa37-0b570bd74a63.mospherepro@smoothalligator","file_transfer_4e2fa85f-2fe3-40c8-97f7-4dafc3b06b6b.mospherepro@smoothalligator","file_transfer_72f55102-f3da-40c5-abbd-bb047f7beb29.mospherepro@smoothalligator","file_transfer_91242b4e-4c83-4cbe-9b4a-d0c3cb30789d.mospherepro@smoothalligator","file_transfer_ed3d53c2-2097-4e7b-9858-9bf92191db2f.mospherepro@smoothalligator","file_transfer_f57df455-4e89-4cdf-a227-3deaa0653dcc.mospherepro@smoothalligator","my_files_5e30af6d-e066-42cc-9517-4bd1dd8eedcc.mospherepro@smoothalligator","my_files_a011b1b0-aa82-4d49-a6d0-97b3bc8333d0.mospherepro@smoothalligator","my_files_a81ac00e-2c4a-4c78-ada3-06e74550ef25.mospherepro@smoothalligator","my_files_c9466a56-ca6c-4f58-9ea3-03873e5d90e9.mospherepro@smoothalligator","public:about.wavi@smoothalligator","public:email.wavi@smoothalligator","public:field_order_of_self.wavi@smoothalligator","public:firstname.wavi@smoothalligator","public:following_by_self.at_follows.wavi@smoothalligator","public:lastname.wavi@smoothalligator","public:linkedin.wavi@smoothalligator","public:privateaccount.wavi@smoothalligator","public:pronoun.wavi@smoothalligator","public:publickey@smoothalligator","public:signing_publickey@smoothalligator","public:theme.wavi@smoothalligator","public:theme_color.wavi@smoothalligator","public:twitter.wavi@smoothalligator","publickey.fascinatingsnow@smoothalligator","publickey.the50@smoothalligator","senthistory_v2.mospherepro@smoothalligator","shared_key.abbcservicesinc@smoothalligator","shared_key.barbaras🐕🐕@smoothalligator","shared_key.colin@smoothalligator","shared_key.denise@smoothalligator","shared_key.er_nobile_14@smoothalligator","shared_key.fascinatingsnow@smoothalligator","shared_key.hacktheleague@smoothalligator","shared_key.hakeem💙@smoothalligator","shared_key.k@smoothalligator","shared_key.misstremendous3@smoothalligator","shared_key.tastelessacarajecoffee@smoothalligator","shared_key.the50@smoothalligator","shared_key.ultrablueexcessive@smoothalligator","shared_key.wildgreen@smoothalligator","trustedcontactskey.mospherepro@smoothalligator"]
There's a copy of my own keystore in my secondary for more values you can work with :). See cli/Scan.java
, I have some string parsing code to change that String into a List, IIRC.
@JeremyTubongbanua Sure, i would take a look at this weekend.
@JeremyTubongbanua Sure, i would take a look at this weekend.
👍🏼 https://docs.atsign.com/reference/namespace/ <- There's some documentation on namespaces. Let me know if that piece of documentation makes sense (or not at all, because chances are, it may not make sense for the next readers; so feedback is always welcome).
@JeremyTubongbanua I'm having some doubts with namespace.
shared_key.denise@smoothalligator assume no namespace?
In the above example, is denise is the namespace, if not then what constitutes the namespace ?
@JeremyTubongbanua I'm having some doubts with namespace.
shared_key.denise@smoothalligator assume no namespace?
In the above example, is denise is the namespace, if not then what constitutes the namespace ?
That's a great question @kaggrwal, sorry for not mentioning this.
shared_key.atsign@creator
is a special case. If it begins with shared_key
, then assume no namespace. With the KeyStringUtil.java
class, you can just do a check like this:!getKeyName().equals("shared_key")
This is a standard of our SDKs; where we assume that no app or person will create a key with the name shared_key.
Hi @JeremyTubongbanua, you can use the following snippet for detecting namespace. Also, it is using commons-lang3, so i'm assuming it is already there in project.
public static String getNameSpace(String key){
KeyStringUtil keyStringUtil = new KeyStringUtil(key);
if(!keyStringUtil.getKeyName().equals("shared_key")){
int atRateIndex = StringUtils.lastIndexOf(key,'@');
if(atRateIndex != -1) {
int dotIndex = key.lastIndexOf('.', atRateIndex);
if(dotIndex != -1){
return key.substring(dotIndex,atRateIndex);
}
}
}
return StringUtils.EMPTY;
}
Let me know if you want anything else.
Thanks @kaggrwal I'll use this code when I tackle this issue later on :)