Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
encounters
EncounterBasedCommunication
Commits
994d9be5
Commit
994d9be5
authored
Jul 19, 2018
by
Lily Tsai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change to cbc
parent
bc610edd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
10 deletions
+20
-10
ebc_enclave_messaging
ebc_enclave_messaging
+1
-1
ebclibrary/src/main/java/org/mpisws/encounters/dbplatform/ContentProviderBase.java
...org/mpisws/encounters/dbplatform/ContentProviderBase.java
+1
-1
ebcutils/src/main/java/org/mpisws/embeddedsocial/TestBatchClient.java
.../main/java/org/mpisws/embeddedsocial/TestBatchClient.java
+10
-1
ebcutils/src/main/java/org/mpisws/helpers/Coder.java
ebcutils/src/main/java/org/mpisws/helpers/Coder.java
+8
-7
No files found.
ebc_enclave_messaging
@
c5cdbe90
Compare
eb462f82
...
c5cdbe90
Subproject commit
eb462f82708dc82b5c57333b5d5d608a9bc15bc5
Subproject commit
c5cdbe909381455f0dfec7ff287e96bf59b49a24
ebclibrary/src/main/java/org/mpisws/encounters/dbplatform/ContentProviderBase.java
View file @
994d9be5
...
@@ -95,7 +95,7 @@ public abstract class ContentProviderBase extends ContentProvider {
...
@@ -95,7 +95,7 @@ public abstract class ContentProviderBase extends ContentProvider {
final
Uri
insertedRowURI
=
ContentUris
.
withAppendedId
(
EncounterHistoryAPM
.
getContentURI
(
dmb
),
rowID
);
final
Uri
insertedRowURI
=
ContentUris
.
withAppendedId
(
EncounterHistoryAPM
.
getContentURI
(
dmb
),
rowID
);
getContext
().
getContentResolver
().
notifyChange
(
insertedRowURI
,
null
);
getContext
().
getContentResolver
().
notifyChange
(
insertedRowURI
,
null
);
return
insertedRowURI
;
return
insertedRowURI
;
}
catch
(
Exception
e
)
{
}
catch
(
SQL
Exception
e
)
{
Log
.
e
(
TAG
,
e
.
getMessage
());
Log
.
e
(
TAG
,
e
.
getMessage
());
}
}
return
null
;
return
null
;
...
...
ebcutils/src/main/java/org/mpisws/embeddedsocial/TestBatchClient.java
View file @
994d9be5
package
org.mpisws.embeddedsocial
;
package
org.mpisws.embeddedsocial
;
import
com.microsoft.embeddedsocial.autorest.EmbeddedSocialClientImpl
;
import
com.microsoft.embeddedsocial.autorest.models.PostTopicRequest
;
import
com.microsoft.embeddedsocial.autorest.models.TopicView
;
import
com.microsoft.embeddedsocial.autorest.models.TopicView
;
import
org.apache.commons.lang3.tuple.ImmutablePair
;
import
org.apache.commons.lang3.tuple.ImmutablePair
;
...
@@ -31,12 +33,19 @@ import static org.mpisws.helpers.Utils.hexStringToByteArray;
...
@@ -31,12 +33,19 @@ import static org.mpisws.helpers.Utils.hexStringToByteArray;
public
class
TestBatchClient
{
public
class
TestBatchClient
{
static
final
String
auth
=
"SocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNjZHFzN0paYVxuR29vZ2xlXG4xMTAyMDM3NjQyMDI5ODI4NDk3NTYiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ3Mzg1NTA0fQ.DhURO4E5-BEFz_dWMdHZHQLq-E_fZf62_si-UlqF3Ko"
;
static
final
String
auth
=
"SocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNjZHFzN0paYVxuR29vZ2xlXG4xMTAyMDM3NjQyMDI5ODI4NDk3NTYiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ3Mzg1NTA0fQ.DhURO4E5-BEFz_dWMdHZHQLq-E_fZf62_si-UlqF3Ko"
;
static
final
String
topicHandle
=
"3g
cpdys3KfY
"
;
static
final
String
topicHandle
=
"3g
_nGuswN8z
"
;
static
final
String
ss
=
"0E31177095EE530101D89573C8261C14F51A3877D4676F74478F5CAF"
;
static
final
String
ss
=
"0E31177095EE530101D89573C8261C14F51A3877D4676F74478F5CAF"
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
ESClient
.
getInstance
().
setESCredentials
(
"user"
,
auth
);
ESClient
.
getInstance
().
setESCredentials
(
"user"
,
auth
);
ESClient
.
getInstance
().
setESAPIKey
(
"2e5a1cc8-5eab-4dbd-8d6d-6a84eab23374"
);
ESClient
.
getInstance
().
setESAPIKey
(
"2e5a1cc8-5eab-4dbd-8d6d-6a84eab23374"
);
/*new Thread( () -> {
String topicHandle = ESClient.getInstance().createOneTopic(
new ImmutablePair<>(
new Identifier("hello".getBytes()),
new Identifier("hello".getBytes())));
System.out.println(topicHandle);
}).start();*/
new
Thread
(
()
->
{
new
Thread
(
()
->
{
System
.
out
.
println
(
"Starting!"
);
System
.
out
.
println
(
"Starting!"
);
...
...
ebcutils/src/main/java/org/mpisws/helpers/Coder.java
View file @
994d9be5
...
@@ -6,6 +6,7 @@ import java.util.Arrays;
...
@@ -6,6 +6,7 @@ import java.util.Arrays;
import
java.util.Base64
;
import
java.util.Base64
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
/**
/**
...
@@ -36,14 +37,14 @@ public class Coder {
...
@@ -36,14 +37,14 @@ public class Coder {
try
try
{
{
SecretKeySpec
secretKey
;
SecretKeySpec
secretKey
;
MessageDigest
sha
=
null
;
MessageDigest
sha
;
sha
=
MessageDigest
.
getInstance
(
"SHA-1"
);
sha
=
MessageDigest
.
getInstance
(
"SHA-1"
);
key
=
sha
.
digest
(
key
);
key
=
sha
.
digest
(
key
);
key
=
Arrays
.
copyOf
(
key
,
16
);
key
=
Arrays
.
copyOf
(
key
,
16
);
secretKey
=
new
SecretKeySpec
(
key
,
"AES"
);
secretKey
=
new
SecretKeySpec
(
key
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/
E
CB/PKCS5Padding"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CB
C
/PKCS5Padding"
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
,
new
IvParameterSpec
(
new
byte
[
16
])
);
String
result
=
Base64
.
getEncoder
().
encodeToString
(
cipher
.
doFinal
(
strToEncrypt
.
getBytes
(
"UTF-8"
)));
String
result
=
Base64
.
getEncoder
().
encodeToString
(
cipher
.
doFinal
(
strToEncrypt
.
getBytes
(
"UTF-8"
)));
System
.
out
.
println
(
"CODER: Encrypting message \n"
System
.
out
.
println
(
"CODER: Encrypting message \n"
+
strToEncrypt
+
strToEncrypt
...
@@ -64,16 +65,16 @@ public class Coder {
...
@@ -64,16 +65,16 @@ public class Coder {
return
strToDecrypt
;
return
strToDecrypt
;
try
try
{
{
System
.
out
.
println
(
"CODER: Decrypting message "
+
strToDecrypt
+
" \nwith secret "
+
new
Identifier
(
secret
).
toString
());
SecretKeySpec
secretKey
;
SecretKeySpec
secretKey
;
MessageDigest
sha
=
null
;
MessageDigest
sha
;
sha
=
MessageDigest
.
getInstance
(
"SHA-1"
);
sha
=
MessageDigest
.
getInstance
(
"SHA-1"
);
secret
=
sha
.
digest
(
secret
);
secret
=
sha
.
digest
(
secret
);
secret
=
Arrays
.
copyOf
(
secret
,
16
);
secret
=
Arrays
.
copyOf
(
secret
,
16
);
System
.
out
.
println
(
"CODER: Decrypting message "
+
strToDecrypt
+
" \nwith secret "
+
new
Identifier
(
secret
).
toString
());
secretKey
=
new
SecretKeySpec
(
secret
,
"AES"
);
secretKey
=
new
SecretKeySpec
(
secret
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/
E
CB/PKCS5PADDING"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CB
C
/PKCS5PADDING"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
new
IvParameterSpec
(
new
byte
[
16
])
);
return
new
String
(
cipher
.
doFinal
(
Base64
.
getDecoder
().
decode
(
strToDecrypt
)));
return
new
String
(
cipher
.
doFinal
(
Base64
.
getDecoder
().
decode
(
strToDecrypt
)));
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment