Initial commit from SVN.

This commit is contained in:
wcrisman
2014-05-30 10:31:51 -07:00
commit b45e56b890
1968 changed files with 370949 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
package com.foundation.orb;
import com.common.debug.Debug;
import com.common.orb.Orb;
import com.common.security.IHashAlgorithm;
import com.common.security.ISignatureAlgorithm;
import com.common.security.RsaAlgorithm;
import com.common.security.Sha1;
import com.common.security.Sha512;
import com.common.util.StringSupport;
import com.de22.orb.Address;
import com.de22.orb.IVersionChangeHandler;
import com.de22.orb.development.OrbClassLoader;
import com.de22.orb.optional.CommonOrbWrapper;
import com.de22.orb.optional.SocketOptions;
public class Client implements ITest {
/**
* @param args
*/
public static void main(String[] args) {
Orb.setOrbWrapper(new CommonOrbWrapper(new OrbClassLoader(), null, null));
Address address = new Address("localhost", port);
try {
Object socketId = Orb.openSocket("Socket", new SocketOptions(1, new Address[] {address}, null, null, null, new IVersionChangeHandler() {
public void newVersionAvailable(String[] uris, boolean isRequired) {
//TODO:
Debug.log("New Version Found...");
}//newVersionAvailable()//
}, null) {
IHashAlgorithm hash = new Sha1();
ISignatureAlgorithm signature = new RsaAlgorithm(StringSupport.fromHexString("000001000000020100AE2F1B25EE59D90C86EE395F2BE15A05DA20523047150AA57A6AA37D39BDD956744C2CE3443033E30181DC541B50BEC879679B6D855415267438C67F12C5829CAA9BBE70885942878AD761DA61A2CCEEA83C48554B68A4CA46E220FF619321A048A2D946709F86E5826D25B5CD8A0379FF78430AB8E1C5522C814DACEEBC4FBF875E43FF3BE38DC67A445132329CE150128CB543C4260185FCBCD1CE9D46798CC4C21C27EFE65ABDB4358DB28131B6AA313E599A278FFA7EDE4ECC6AC18550A81244A70CF5D5529A6854FAEF764388424BBD95B0185AADF13AC6C03F27D608F969DAFF303EDE9B5A80E35882A658FECBAAC4969E15078F072C7C68FCE50C93C0E0679705B397B2B0E6CD6B9C4868AD8C5F39BAEE590B05DBE1ADE6F71D99AB14BC7C94099FF1BE62C0CBC35982BCE238444578FBA3117AE454CCAFDBB7D125204157C4D6009982B94DAC4A62B4B76F2ED485278BFCD5AD1CE549BE19DD4D778D0C23CAF8A6D4DBE42D9FA782CE0468875EE6CBC684CC7504B1C18D59D4D463CBB1F96AD707F9D36A7A17BC936CA97B30730498185C849FF8C9D76E3C2DA51E860959D038563A7B989A4DFCE557874EAE4C970E2C2A7D6FE59E61FF1338ACFF2EAA4C0C997BDDB233402D6756890AF592323F598D5C054D913E63694A1DE29076BFFAC6427F64F457A6E63A5690EC290E9071790F257EB3F3C85968C68B9AC31D00856D1F27E547FABD5356C57150D191D3EE219CB04D9876B6030A3EE0207C119D04B58AD50299303919E37DCA621AC963FB3C4434B0C994D17327EBB5895D62DF779F38E7F51B4C4F017D5B5F8D6F2DC099DF0174717BA91D3E36C2534598C92D7B891AB7FAB8AAA7340D92D51ABB7ABD822EC201C2BE7FCA53CB195682854956405BF1F817CEFAFAD1AE264F3FD1D4F07C3452A16128FCF9A4A6184060173E09C05A2D660A8A2A017ED93ED802BBCDB526857534A674BDD40FE1D9E2146AE6E3D179E707544FED8B532D2175558A9756CD9BB00FD5ABC82D20474F43C8BBF2536672D32DCB2CDA33343CBCF518DB618B21CDE942E0485DED628759061EA8A269A68185057D02B7029F7891523457A9CA6E49D2F0F3F39E3D1BB68469E9A6244FB0B12F91099F7EAC0006DD94BD2E2077B9EA54DB6A964B33B93834EFA07629DF429893A8703020777804010AB79B23EBE8C8570FD0F5B0B06F80CBAC0FDB03AD1E10CAEFF82FA4736F7AA3E61D21EA2C5431ABF6645B163836CC24F9FE8BA3EDED75D83EFC4D94E4D318A60732054A89770EB240FD4C47338D83C9FC09C53CC18453419575607EFD34BF4081532BB339BB3CFE510A187DACFEB00E59D6E1D9F330D434754F38CB46A8F7DDFB9EF08833C4ADA4291FB73E9D91CBD9349C098EFC2F90865410495BC3320B0B419BFD476196EFAF7821BD7293BB680040F6B73E5B"), true);
public IHashAlgorithm getHashAlgorithm() {
return hash;
}//getHashAlgorithm()//
public int getSignatureSize() {
return signature.getSignedSize(hash.getHashSize());
}//getSignatureSize()//
public boolean isValidSignature(byte[] data, byte[] signedData) {
byte[] unsignedData = signature.verify(signedData);
boolean result = unsignedData != null && unsignedData.length == data.length;
for(int index = 0; result && index < unsignedData.length; index++) {
result = unsignedData[index] == data[index];
}//for//
return result;
}//isValidSignature()//
});
if(socketId == null) {
Debug.log("Failed to create a connection to the server.");
System.exit(0);
}//if//
ITestService service = (ITestService) Orb.lookup(ITestService.ID, socketId);
String result = service.performAction("Wynne Crisman");
Debug.log(result);
Orb.closeSocket(socketId);
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//main()//
}//Client//

View File

@@ -0,0 +1,5 @@
package com.foundation.orb;
public interface ITest {
public static final int port = 10224;
}

View File

@@ -0,0 +1,6 @@
package com.foundation.orb;
public interface ITestService extends ITest {
public static final String ID = "testId";
public String performAction(String input);
}

View File

@@ -0,0 +1,92 @@
package com.foundation.orb;
import java.security.KeyStore;
import com.common.debug.Debug;
import com.common.security.Sha512;
import com.common.util.StreamBuffer;
import com.de22.orb.SecurityMessageFilter;
import com.de22.orb.security.AbstractSecuritySystem;
import com.de22.orb.security.SslSecurityProvider;
import com.de22.orb.security.SslSecuritySystem;
import com.de22.orb.AbstractConnection.IMessageFilterInputHandler;
import com.de22.orb.AbstractConnection.IMessageFilterOutputHandler;
public class SecurityTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
Sha512 hash = new Sha512();
for(int i = 0; i < 2000; i++) {
hash.add((byte) i);
}//for//
hash.hash();
}//try//
catch(Throwable e) {
Debug.log(e);
}
try {
SslSecurityProvider provider = new SslSecurityProvider("TLS"/*SSLv3*/, "./test.key", "kspassword", "kpassword");
AbstractSecuritySystem serverSystem = provider.createSecuritySystem();
AbstractSecuritySystem clientSystem = (AbstractSecuritySystem) Class.forName(provider.getSecuritySystemClientClassName()).newInstance();
clientSystem.initialize(provider.getSecuritySystemClientMetadata());
final SecurityMessageFilter serverFilter = new SecurityMessageFilter(serverSystem);
final SecurityMessageFilter clientFilter = new SecurityMessageFilter(clientSystem);
serverFilter.setHandlers(new IMessageFilterInputHandler() {
public void startIncommingMessage(StreamBuffer input) {
//TODO: Take the input and pass it to the client.
Debug.log("Receiving data from the client orb.");
}
public void initializeFilter() {
Debug.log("Server filter initialization completed.");
}
public void closeConnection(boolean force) {
Debug.log("Server connection closed: " + force);
}
}, new IMessageFilterOutputHandler() {
public void startOutgoingMessage(StreamBuffer input) {
//TODO: Output should be handled by the orb.
// Debug.log("Sending data to the server orb.");
clientFilter.startIncommingMessage(input);
}
});
clientFilter.setHandlers(new IMessageFilterInputHandler() {
public void startIncommingMessage(StreamBuffer input) {
//TODO: Take the input and pass it to the server.
Debug.log("Receiving data from the server orb.");
}
public void initializeFilter() {
Debug.log("Client filter initialization completed.");
StreamBuffer content = new StreamBuffer();
for(int index = 0; index < 100; index++) {
content.writeByte((byte) index);
}//if//
clientFilter.startOutgoingMessage(content);
}
public void closeConnection(boolean force) {
Debug.log("Client connection closed: " + force);
}
}, new IMessageFilterOutputHandler() {
public void startOutgoingMessage(StreamBuffer input) {
//TODO: Output should be handled by the orb.
//Debug.log("Sending data to the client orb.");
serverFilter.startIncommingMessage(input);
}
});
clientFilter.beginInitialization();
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}
}

File diff suppressed because one or more lines are too long