-
Notifications
You must be signed in to change notification settings - Fork 1
SNComponents
Topics
SN2 is a showcase, test platform and playground to implement new application components. Here are some SN2 component rules:
- No circular dependencies. Components can use others but vice-versa. There is a component hierarchy. Components with no further dependencies are called root compoments
- Components implement the ASAPApplicationComponent interface.
- There is an example that shows how it can be integrated with SharkNetApp.
- Each Component uses its own ASAPEngine and can be distinguished from other by its format.
This components manages contacts, their names and certificates. It provides public keys and offers methods to manage the local private/public key pair. It includes an Android Key Storage.
It uses ASAP to spread certificates within a peer group. You do not have to deal with user management and anything about a public key infrastructure (PKI). This component does not offer methods for ASAP encryption and digital signing. It provides methods to get public keys and the local private key, though.
Have a look at the ASAP Certificate Component Wiki for concepts and some details. (The considerations about identity assurance are quite unique and special to this kind of decentralized networks.)
Contact and certificate management is implemented in package net.sharksystem.persons. The PersonsStorage facade gives access to all relevant methods in this component.
This section is no required reading if you only want to use this component. Read it if you plan to implement your own sub component or if you like to discuss software architectural issues. If not, go ahead with next sub section (get access)
This component must be initialized as any other component in SN2. The following considerations can be read a blueprint for your own implementation if you plan to do some.
SN2 is based on the ASAPAndroid library. In SN2, SharkNetApp implements the ASAPApplication. Each application has to be initialized and so are their components.
Here is nearly the complete initialization process of SharkNetApp:
List<CharSequence> appFormats = new ArrayList<>();
// add component persons
for(CharSequence f : PersonsStorageAndroidComponent.geRequiredFormats()) {
appFormats.add(f);
}
...
// now we can create the initialize / construct the SharkNetApp singleton.
SharkNetApp.singleton = new SharkNetApp(appFormats, initActivity);
// finally we can initialize sub components like person
PersonsStorageAndroidComponent.initialize(
SharkNetApp.singleton, // ASAPApplication
SharkNetApp.singleton // OwnerFactory
);
...
// launch the system
SharkNetApp.singleton.startASAPApplication();
}
Setting up an ASAPApplication os a two step process. An object with required format must be created and finally it can be started. An application with sub components must first get all required formats prior to its creation. Each sub component must provide a static method. It is called before the actual component is created.
The application can be constructed with those information (new SharkNetApp(appFormats, initActivity)
. Sub components can be initialized with this object: PersonsStorageAndroidComponent.initialize
in this case. Finally, the app itself is started and so all required ASAPEngines, see ASAPAndroid library for details.
It is not a big deal, though. Here is the implementation.
Here is the code that provides SharkNetApp with the format information. Not a big deal:
public static Collection<CharSequence> geRequiredFormats() {
Collection<CharSequence> formats = new ArrayList<>();
formats.add(PersonsStorageAndroidComponent.CREDENTIAL_APP_NAME);
return formats;
}
PersonsStorageAndroidComponent.initialize
creates a singleton. After initialization, you get access to this singleton by calling somewhere in your code:
PersonsStorageAndroidComponent.getPersonsStorage();
Now you have access to components' methods. See ASAP Certificate Component Wiki for concepts and some details.
[TODO]
First: It is not that difficult. Promised! Maybe a bit strange.
- Read about other components before you design your own. It takes some time to implement one. It could speed up your work. Take your time. If you find a component that can be used - fork this project now. If not, create you own repository.
- You work with the ASAPAndroid library. Get familiar with it. Read example code.
- Write you application according with Android library. Even create an ASAPApplication. Have in mind that this class will no be used once your component is integrated in SN2. It helps to test your app, though.
- Test your application
- Fork this project now if you worked with you own repository so far.
- Implement a singleton that implements ASAPApplicationComponent. Have look at examples, e.g. PersonsStorageAndroidComponent. Integrate your component into the SharkNetApplication initialization process, see Certificates and contacts for advice. You still do not work in the master branch.
- Now, get in contact with me or another SN2 admin. We integrate your work in the master branch and thank you a lot for providing another useful component that helps implement decentralized applications.