Commit 097b56c3 authored by Matt Strum's avatar Matt Strum
Browse files

Added support for caching authorities and fixed client cert chain

parent 4cb1b427
......@@ -243,6 +243,7 @@ else if(typeof(module) !== 'undefined' && module.exports) {
aes: require('./aes'),
asn1: require('./asn1'),
hmac: require('./hmac'),
log: require('./log'),
md: require('./md'),
pki: require('./pki'),
random: require('./random'),
......@@ -3076,7 +3077,8 @@ tls.createCertificate = function(c) {
}
var asn1 = null;
for(var i = 0; i < cert.length; ++i) {
var der = forge.pki.pemToDer(cert);
var der = forge.pki.pemToDer(cert[i]);
if(asn1 === null) {
asn1 = forge.asn1.fromDer(der.bytes());
}
......
......@@ -29,8 +29,11 @@
package com.flack.geni
{
import com.flack.geni.resources.sites.GeniAuthority;
import com.flack.geni.resources.sites.GeniAuthorityCollection;
import com.flack.geni.resources.sites.GeniManager;
import com.flack.geni.resources.sites.GeniManagerCollection;
import com.flack.geni.resources.sites.authorities.ProtogeniSliceAuthority;
import com.flack.shared.SharedCache;
import com.flack.shared.SharedMain;
......@@ -188,6 +191,85 @@ package com.flack.geni
}
}
// Manual authorities
public static function wasAuthorityManuallyAdded(authority:GeniAuthority):Boolean
{
if(SharedCache._sharedObject == null || SharedCache._sharedObject.data.manual_authorities == null)
return false;
for each(var authorityObject:Object in SharedCache._sharedObject.data.manual_authorities)
{
if(authorityObject.id == authority.id.full)
return true;
}
return false;
}
public static function removeManuallyAddedAuthority(authority:GeniAuthority):void
{
if(SharedCache._sharedObject == null || SharedCache._sharedObject.data.manual_authorities == null)
return;
for(var i:int = 0; i < SharedCache._sharedObject.data.manual_authorities.length; i++)
{
if(SharedCache._sharedObject.data.manual_authorities[i].id == authority.id.full)
{
SharedCache._sharedObject.data.manual_authorities.splice(i, 1);
return;
}
}
return;
}
public static function addAuthorityManually(authority:ProtogeniSliceAuthority, authorityCert:String):void
{
if(SharedCache._sharedObject == null || !SharedCache.UsableCache())
return;
if(SharedCache._sharedObject.data.manual_authorities == null)
SharedCache._sharedObject.data.manual_authorities = [];
SharedCache._sharedObject.data.manual_authorities.push(
{
id:authority.id.full,
url:authority.url,
working_cert_get:authority.workingCertGet,
cert:authorityCert
}
);
}
public static function getManualAuthorities():GeniAuthorityCollection
{
var results:GeniAuthorityCollection = new GeniAuthorityCollection();
if(SharedCache._sharedObject != null && SharedCache._sharedObject.data.manual_authorities != null)
{
var authorityCerts:String = "";
for each(var authorityObject:Object in SharedCache._sharedObject.data.manual_authorities)
{
// Skip older cached managers.
var newAuthority:ProtogeniSliceAuthority = new ProtogeniSliceAuthority(
authorityObject.id,
authorityObject.url,
authorityObject.working_cert_get);
var newCert:String = authorityObject.cert;
if(newCert.length > 0 && SharedMain.Bundle.indexOf(newCert) == -1)
authorityCerts += newCert;
results.add(newAuthority);
}
if(authorityCerts.length > 0)
SharedMain.Bundle += authorityCerts;
}
return results;
}
public static function clearManualAuthorities():void
{
if(SharedCache._sharedObject != null)
{
delete SharedCache._sharedObject.data.manual_authorities;
}
}
// Manual managers
public static function wasManagerManuallyAdded(manager:GeniManager):Boolean
{
......
......@@ -100,7 +100,7 @@ package com.flack.geni
plugins = new Vector.<Plugin>();
plugins.push(new Gemini());
plugins.push(new Stitching());
plugins.push(new Instools());
//plugins.push(new Instools());
plugins.push(new Emulab());
plugins.push(new Planetlab());
plugins.push(new Openflow());
......
......@@ -35,12 +35,13 @@ IN THE WORK.
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.flack.shared.display.components.*"
title="Add Authority" xmlns:windows="com.flack.shared.display.windows.*">
title="Add Authority" xmlns:windows="com.flack.shared.display.windows.*" xmlns:layout="org.osmf.layout.*">
<windows:layout>
<s:VerticalLayout paddingBottom="4" paddingTop="4" paddingLeft="4" paddingRight="4" />
</windows:layout>
<fx:Script>
<![CDATA[
import com.flack.geni.GeniCache;
import com.flack.geni.GeniMain;
import com.flack.geni.resources.sites.authorities.ProtogeniSliceAuthority;
import com.flack.shared.FlackEvent;
......@@ -50,8 +51,16 @@ IN THE WORK.
import com.flack.shared.tasks.file.FileTask;
import com.flack.shared.utils.ImageUtil;
import mx.controls.Alert;
public function addAndClose():void
{
if(urlTextinput.text.length == 0)
{
Alert.show("You must give a URL for the authority");
return;
}
var newAuthority:ProtogeniSliceAuthority =
new ProtogeniSliceAuthority(
idTextinput.text,
......@@ -62,6 +71,9 @@ IN THE WORK.
if(certTextarea.text.length > 0)
SharedMain.Bundle += "\n" + certTextarea.text;
if(cacheCheckbox.selected)
GeniCache.addAuthorityManually(newAuthority, certTextarea.text);
GeniMain.geniUniverse.authorities.add(newAuthority);
SharedMain.sharedDispatcher.dispatchChanged(
FlackEvent.CHANGED_AUTHORITIES,
......@@ -117,11 +129,19 @@ IN THE WORK.
</s:HGroup>
<s:TextArea width="100%" height="100%" id="certTextarea" />
<windows:controlBarLayout>
<s:HorizontalLayout paddingBottom="4"
paddingTop="4"
paddingLeft="4"
paddingRight="4"
verticalAlign="middle" />
</windows:controlBarLayout>
<windows:controlBarContent>
<s:Button id="okButton"
icon="{ImageUtil.availableIcon}"
label="OK"
click="addAndClose()" />
<s:CheckBox id="cacheCheckbox" label="Keep in cache" />
<s:Button label="Cancel"
icon="{ImageUtil.cancelIcon}"
click="closeWindow()" />
......
......@@ -29,7 +29,12 @@
package com.flack.geni.tasks.http
{
import com.flack.geni.GeniCache;
import com.flack.geni.GeniMain;
import com.flack.geni.resources.sites.GeniAuthority;
import com.flack.geni.resources.sites.GeniAuthorityCollection;
import com.flack.geni.resources.sites.GeniManager;
import com.flack.geni.resources.sites.GeniManagerCollection;
import com.flack.geni.resources.sites.authorities.ProtogeniSliceAuthority;
import com.flack.shared.FlackEvent;
import com.flack.shared.SharedMain;
......@@ -72,14 +77,27 @@ package com.flack.geni.tasks.http
if(GeniMain.geniUniverse.authorities.getByUrl(sliceAuthority.url) == null)
GeniMain.geniUniverse.authorities.add(sliceAuthority);
addMessage(
"Added authority: " +sliceAuthority.name,
"Added authority: " + sliceAuthority.name,
sliceAuthority.toString()
);
}
var manuallyAddedAuthorities:GeniAuthorityCollection = GeniCache.getManualAuthorities();
for each(var cachedAuthority:GeniAuthority in manuallyAddedAuthorities.collection)
{
if(GeniMain.geniUniverse.authorities.getByUrl(cachedAuthority.url) == null)
{
GeniMain.geniUniverse.authorities.add(cachedAuthority);
addMessage(
"Added cached authority: " + sliceAuthority.name,
sliceAuthority.toString()
);
}
}
addMessage(
"Added "+GeniMain.geniUniverse.authorities.length+" authorities",
"Added "+GeniMain.geniUniverse.authorities.length+" authorities",
GeniMain.geniUniverse.authorities.length+" authorities loaded",
GeniMain.geniUniverse.authorities.length+" authorities loaded",
LogMessage.LEVEL_INFO,
LogMessage.IMPORTANCE_HIGH
);
......
......@@ -51,7 +51,7 @@ package com.flack.shared
/**
* Flack version
*/
public static const version:String = "v17.0";
public static const version:String = "v17.3";
public static const MODE_GENI:int = 0;
public static const MODE_EMULAB:int = 1;
......
......@@ -184,6 +184,8 @@ IN THE WORK.
click="SharedCache.clearCertBundle(); Alert.show('Deleted certificate bundle cache', 'Deleted');" />
<s:Button label="Delete user cache"
click="SharedCache.clearUser(); Alert.show('Deleted user cache', 'Deleted');" />
<s:Button label="Delete manually added authorities"
click="GeniCache.clearManualAuthorities(); Alert.show('Deleted manually added authorities', 'Deleted');" />
<s:Button label="Delete manually added managers"
click="GeniCache.clearManualManagers(); Alert.show('Deleted manually added managers', 'Deleted');" />
<s:Button label="Delete default managers to list"
......
......@@ -40,7 +40,7 @@ package com.mattism.http.xmlrpc
{
var lines : Array = pem.split(/[\r\n]+/);
var key : String = "";
var cert : String = "";
var certs : Array = [];
var inKey : Boolean = false;
var inCert : Boolean = false;
for each (var line : String in lines)
......@@ -49,9 +49,10 @@ package com.mattism.http.xmlrpc
{
inKey = true;
}
else if (line == "-----BEGIN CERTIFICATE-----" && cert == "")
else if (line == "-----BEGIN CERTIFICATE-----")
{
inCert = true;
certs.push("");
}
if (inKey)
......@@ -60,7 +61,7 @@ package com.mattism.http.xmlrpc
}
if (inCert)
{
cert += line + "\n";
certs[certs.length-1] += line + "\n";
}
if (line == "-----END RSA PRIVATE KEY-----")
......@@ -75,7 +76,7 @@ package com.mattism.http.xmlrpc
if(key.length == 0) {
throw new Error("No RSA private key found");
}
if(cert.length == 0) {
if(certs.length == 0) {
throw new Error("No certificate found");
}
var iv : ByteArray = generateIv(key);
......@@ -92,7 +93,7 @@ package com.mattism.http.xmlrpc
ExternalInterface.call("setClientKey", key);
//throw new Error("Invalid Key: " + key);
}
ExternalInterface.call("setClientCert", cert);
ExternalInterface.call("setClientCert", certs);
}
private static function generateIv(key : String) : ByteArray
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment