Skip to content

Commit 179da51

Browse files
committed
ready to start debugging sn channels - towards a working version
1 parent 71211d1 commit 179da51

File tree

10 files changed

+38
-25
lines changed

10 files changed

+38
-25
lines changed

app/libs/ASAPCertificate_0.1.0.jar

105 Bytes
Binary file not shown.

app/src/main/java/net/sharksystem/asap/sharknet/android/SNChannelsComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public BasicKeyStore getBasicKeyStore() {
9898
public ASAPPKI getAsapPKI() { return this.asapPKI; }
9999

100100
public CharSequence getOwnerID() {
101-
return this.ownerFactory.getOwner().getUUID();
101+
return this.ownerFactory.getOwnerData().getUUID();
102102
}
103103

104104
////////////////////////////////////////////////////////////////////////////////////

app/src/main/java/net/sharksystem/persons/android/OwnerActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import net.sharksystem.asap.util.DateTimeHelper;
1515
import net.sharksystem.asap.android.Util;
1616
import net.sharksystem.crypto.SharkCryptoException;
17-
import net.sharksystem.sharknet.android.AndroidASAPKeyStorage;
1817
import net.sharksystem.sharknet.android.Owner;
1918
import net.sharksystem.sharknet.android.SharkNetApp;
2019

@@ -83,7 +82,7 @@ public void onSaveClick(View view) throws SharkException {
8382
} else {
8483
Log.d(this.getLogStart(), "set new user name: " + userNameString);
8584
Owner identityStorage = null;
86-
SharkNetApp.getSharkNetApp().getOwner().setDisplayName(userNameString);
85+
SharkNetApp.getSharkNetApp().getOwnerData().setDisplayName(userNameString);
8786

8887
// re-launch
8988
this.finish();

app/src/main/java/net/sharksystem/persons/android/OwnerCredentialSendActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
3232

3333
// set user name in layout
3434
TextView tv = this.findViewById(R.id.ownerDisplayName);
35-
tv.setText(SharkNetApp.getSharkNetApp().getOwner().getDisplayName());
35+
tv.setText(SharkNetApp.getSharkNetApp().getOwnerData().getDisplayName());
3636

3737
// set control number
3838
tv = this.findViewById(R.id.credentialsControlNumber);

app/src/main/java/net/sharksystem/persons/android/PersonAppActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ Context getContext() throws ASAPException {
1616
}
1717

1818
Owner getOwnerStorage() {
19-
return PersonsStorageAndroidComponent.getPersonsStorage().getOwner();
19+
return PersonsStorageAndroidComponent.getPersonsStorage().getOwnerData();
2020
}
2121
}

app/src/main/java/net/sharksystem/persons/android/PersonsStorageAndroidComponent.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import net.sharksystem.crypto.ASAPKeyStorage;
2020
import net.sharksystem.persons.ASAPPKIImpl;
2121
import net.sharksystem.persons.CredentialMessage;
22+
import net.sharksystem.persons.FullAsapPKIStorage;
2223
import net.sharksystem.persons.TestHelperPersonStorage;
2324
import net.sharksystem.sharknet.android.AndroidASAPKeyStorage;
2425
import net.sharksystem.sharknet.android.Owner;
@@ -37,8 +38,8 @@
3738
import java.util.HashSet;
3839
import java.util.Set;
3940

40-
public class PersonsStorageAndroidComponent extends ASAPPKIImpl
41-
implements ASAPApplicationComponent, PersonsStorage /*InMemoPersonsStorageImpl*/ {
41+
public class PersonsStorageAndroidComponent extends FullAsapPKIStorage //ASAPPKIImpl
42+
implements ASAPApplicationComponent, PersonsStorage, OwnerFactory /*InMemoPersonsStorageImpl*/ {
4243

4344
public static final String SN_ANDROID_DEFAULT_SIGNING_ALGORITHM = "SHA256withRSA/PSS";
4445
private static final String PERSONS_STORAGE_FILE_NAME = "sn2_personsStorageFile";
@@ -85,11 +86,14 @@ private PersonsStorageAndroidComponent(ASAPApplication asapApplication,
8586
// Log.d(this.getLogStart(), "there is no persons storage persistence file - ok. Start empty");
8687
Log.d(this.getLogStart(), "there is no persons storage persistence file - fill with EXAMPLE DATA");
8788
TestHelperPersonStorage.fillWithExampleData(this);
89+
this.save();
8890
}
8991
}
9092

91-
public static void initialize(ASAPApplication asapApplication,
92-
OwnerFactory ownerFactory, AndroidASAPKeyStorage asapKeyStorage) {
93+
public static PersonsStorageAndroidComponent initialize(
94+
ASAPApplication asapApplication, OwnerFactory ownerFactory,
95+
AndroidASAPKeyStorage asapKeyStorage) {
96+
9397
try {
9498
/*
9599
File personsStorageFile =
@@ -110,11 +114,12 @@ public static void initialize(ASAPApplication asapApplication,
110114
asapKeyStorage
111115
);
112116

113-
//instance.fillWithExampleData();
117+
return PersonsStorageAndroidComponent.instance;
114118
} catch (Exception e) {
115119
Log.e(net.sharksystem.asap.util.Log.startLog(ASAPPKIImpl.class).toString(),
116120
"problems when creating ASAP Storage:" + e.getLocalizedMessage());
117121
}
122+
return null;
118123
}
119124

120125
public static synchronized PersonsStorageAndroidComponent getPersonsStorage()
@@ -126,8 +131,8 @@ public static synchronized PersonsStorageAndroidComponent getPersonsStorage()
126131
return PersonsStorageAndroidComponent.instance;
127132
}
128133

129-
Owner getOwner() {
130-
return this.ownerFactory.getOwner();
134+
public Owner getOwnerData() {
135+
return this.ownerFactory.getOwnerData();
131136
}
132137

133138
/*

app/src/main/java/net/sharksystem/sharknet/android/AndroidASAPKeyStorage.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.sharksystem.crypto.ASAPCertificateImpl;
1515
import net.sharksystem.crypto.ASAPKeyStorage;
1616
import net.sharksystem.crypto.BasicKeyStore;
17+
import net.sharksystem.crypto.InMemoASAPKeyStorage;
1718
import net.sharksystem.crypto.SharkCryptoException;
1819
import net.sharksystem.persons.ASAPKeyStoreWithWriteAccess;
1920
import net.sharksystem.persons.ASAPPKI;
@@ -37,8 +38,10 @@
3738
/**
3839
* Overwrites key creation and add kex persistence to the more general super class
3940
*/
40-
public class AndroidASAPKeyStorage extends SampleFullAsapPKIStorage
41-
implements ASAPKeyStoreWithWriteAccess, ASAPPKI, BasicKeyStore {
41+
public class AndroidASAPKeyStorage extends InMemoASAPKeyStorage
42+
// SampleFullAsapPKIStorage
43+
// implements ASAPKeyStoreWithWriteAccess, ASAPPKI, BasicKeyStore
44+
{
4245

4346
private static final String KEYPAIR_CREATION_TIME = "ASAPCertificatesKeyPairCreationTime";
4447
public static final String KEYSTORE_NAME = "AndroidKeyStore";
@@ -58,7 +61,7 @@ public AndroidASAPKeyStorage(Context initialContext,
5861
CharSequence ownerID, CharSequence ownerName)
5962
throws ASAPSecurityException {
6063

61-
super(ownerID, ownerName);
64+
//super(ownerID, ownerName);
6265
this.initialContext = initialContext;
6366
}
6467

app/src/main/java/net/sharksystem/sharknet/android/InitActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import net.sharksystem.R;
1212
import net.sharksystem.asap.sharknet.android.SNChannelsListActivity;
13-
import net.sharksystem.makan.android.MakanListActivity;
1413
import net.sharksystem.persons.android.OwnerActivity;
1514

1615
public class InitActivity extends AppCompatActivity {
@@ -22,7 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
2221
if(!SharkNetApp.isStarted()) {
2322
Log.d(this.getLogStart(), "Startup SharkNetApplication");
2423
SharkNetApp sharkNetApp = SharkNetApp.initializeSharkNetApp(this);
25-
Owner owner = sharkNetApp.getOwner();
24+
Owner owner = sharkNetApp.getOwnerData();
2625
if (!owner.isOwnerSet()) launchFirstActivity = false;
2726
}
2827

@@ -45,7 +44,7 @@ public void onSaveClick(View view) {
4544
Toast.makeText(this, "you must define another name",
4645
Toast.LENGTH_SHORT).show();
4746
} else {
48-
SharkNetApp.getSharkNetApp().getOwner().setDisplayName(ownerName);
47+
SharkNetApp.getSharkNetApp().getOwnerData().setDisplayName(ownerName);
4948
this.finish();
5049
Intent intent = new Intent(this, OwnerActivity.class);
5150
this.startActivity(intent);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package net.sharksystem.sharknet.android;
22

33
public interface OwnerFactory {
4-
Owner getOwner();
4+
Owner getOwnerData();
55
}

app/src/main/java/net/sharksystem/sharknet/android/SharkNetApp.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,36 +64,43 @@ static SharkNetApp initializeSharkNetApp(Activity initActivity) {
6464
appFormats.add(ASAPCertificateStorage.CERTIFICATE_APP_NAME);
6565

6666
///////////////// initialize application object ///////////////////////////////////
67+
Log.d(getLogStart(), "create SharkNetApp object");
6768
SharkNetApp.singleton = new SharkNetApp(appFormats, initActivity);
6869

6970
// read owner information from preference or somewhere else
71+
Log.d(getLogStart(), "get owner from shared preferences");
7072
Owner owner = SharkNetApp.singleton.getOwner(initActivity);
7173

7274
///////////////// initialize application components //////////////////////////////
7375
// key storage
76+
Log.d(getLogStart(), "init AndroidASAPKeyStorage");
7477
AndroidASAPKeyStorage asapKeyStorage =
7578
AndroidASAPKeyStorage.initializeASAPKeyStorage(
7679
initActivity,
7780
owner.getUUID(),
7881
owner.getDisplayName());
7982

8083
// persons / contacts
81-
PersonsStorageAndroidComponent.initialize(
84+
Log.d(getLogStart(), "init PersonsStorageAndroidComponent");
85+
86+
PersonsStorageAndroidComponent asapPKI = PersonsStorageAndroidComponent.initialize(
8287
SharkNetApp.singleton, // ASAPApplication
8388
SharkNetApp.singleton, // OwnerFactory
8489
asapKeyStorage
8590
);
8691

8792
// snChannels
93+
Log.d(getLogStart(), "init SNChannelsComponent");
8894
SNChannelsComponent.initialize(
8995
SharkNetApp.singleton, // ASAPApplication
90-
asapKeyStorage, // BasicKeyStore
91-
asapKeyStorage, // ASAPPKI
96+
asapPKI, // BasicKeyStore
97+
asapPKI, // ASAPPKI
9298
SharkNetApp.singleton, // OwnerFactory
9399
PersonsStorageAndroidComponent.getPersonsStorage() // PersonStorage
94100
);
95101

96102
// all components put together - launch the system
103+
Log.d(getLogStart(), "launch SN2 application");
97104
SharkNetApp.singleton.startASAPApplication();
98105
}
99106

@@ -138,12 +145,12 @@ public Owner getOwner(Activity activity) {
138145
}
139146

140147
@Override
141-
public Owner getOwner() {
148+
public Owner getOwnerData() {
142149
return this.getOwner(this.getActivity());
143150
}
144151

145-
public CharSequence getOwnerID() { return this.getOwner().getUUID(); }
152+
public CharSequence getOwnerID() { return this.getOwnerData().getUUID(); }
146153
public CharSequence getOwnerName() {
147-
return this.getOwner().getDisplayName();
154+
return this.getOwnerData().getDisplayName();
148155
}
149156
}

0 commit comments

Comments
 (0)