openfl
Version:
A fast, productive library for 2D cross-platform development.
113 lines (96 loc) • 4.78 kB
JavaScript
// Class: openfl.net.SecureSocket
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../hxClasses_stub").default;
var $hxEnums = require("./../../hxEnums_stub").default;
var $import = require("./../../import_stub").default;
var $bind = require("./../../bind_stub").default;
var $extend = require("./../../extend_stub").default;
function openfl_net_Socket() {return require("./../../openfl/net/Socket");}
function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");}
function openfl_errors_IOError() {return require("./../../openfl/errors/IOError");}
function openfl_security_X509Certificate() {return require("./../../openfl/security/X509Certificate");}
function openfl_security_X500DistinguishedName() {return require("./../../openfl/security/X500DistinguishedName");}
function openfl_errors_ArgumentError() {return require("./../../openfl/errors/ArgumentError");}
function openfl_errors_SecurityError() {return require("./../../openfl/errors/SecurityError");}
function openfl_utils_ByteArrayData() {return require("./../../openfl/utils/ByteArrayData");}
function openfl_Lib() {return require("./../../openfl/Lib");}
function openfl_errors_IllegalOperationError() {return require("./../../openfl/errors/IllegalOperationError");}
// Constructor
var SecureSocket = function() {
this.__serverCertificateStatus = "unknown";
(openfl_net_Socket().default).call(this);
throw new (js__$Boot_HaxeError().default)(new (openfl_errors_IllegalOperationError().default)("Not supported"));
}
// Meta
SecureSocket.__name__ = "openfl.net.SecureSocket";
SecureSocket.__isInterface__ = false;
SecureSocket.__super__ = (openfl_net_Socket().default);
SecureSocket.prototype = $extend((openfl_net_Socket().default).prototype, {
get_serverCertificate: function() {
if(this.__socket == null) {
throw new (js__$Boot_HaxeError().default)(new (openfl_errors_IOError().default)("Operation attempted on invalid socket."));
}
if(this.__peerCertificate == null) {
return null;
}
var result = new (openfl_security_X509Certificate().default)();
var subject = new (openfl_security_X500DistinguishedName().default)();
subject.commonName = this.__peerCertificate.subject("CN");
subject.countryName = this.__peerCertificate.subject("C");
subject.localityName = this.__peerCertificate.subject("L");
subject.organizationName = this.__peerCertificate.subject("O");
subject.organizationalUnitName = this.__peerCertificate.subject("OU");
subject.stateOrProvinceName = this.__peerCertificate.subject("S");
result.subject = subject;
var issuer = new (openfl_security_X500DistinguishedName().default)();
issuer.commonName = this.__peerCertificate.issuer("CN");
issuer.countryName = this.__peerCertificate.issuer("C");
issuer.localityName = this.__peerCertificate.issuer("L");
issuer.organizationName = this.__peerCertificate.issuer("O");
issuer.organizationalUnitName = this.__peerCertificate.issuer("OU");
issuer.stateOrProvinceName = this.__peerCertificate.issuer("S");
result.issuer = issuer;
result.validNotBefore = this.__peerCertificate.notBefore;
result.validNotAfter = this.__peerCertificate.notAfter;
return result;
},
get_serverCertificateStatus: function() {
return this.__serverCertificateStatus;
},
addBinaryChainBuildingCertificate: function(certificate,trusted) {
throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Not supported"));
},
connect: function(host,port) {
this.__serverCertificateStatus = "unknown";
this.__peerCertificate = null;
if(this.__socket != null) {
this.close();
}
if(port < 0 || port > 65535) {
throw new (js__$Boot_HaxeError().default)(new (openfl_errors_SecurityError().default)("Invalid socket port number specified."));
}
this.__host = host;
this.__port = port;
var this1 = new (openfl_utils_ByteArrayData().default)(0);
this.__output = this1;
this.__output.set_endian(this.__endian);
var this2 = new (openfl_utils_ByteArrayData().default)(0);
this.__input = this2;
this.__input.set_endian(this.__endian);
(openfl_Lib().default).get_current().addEventListener("enterFrame",$bind(this,this.this_onEnterFrame));
},
this_onEnterFrame: function(event) {
(openfl_net_Socket().default).prototype.this_onEnterFrame.call(this,event);
}
});
SecureSocket.prototype.__class__ = SecureSocket.prototype.constructor = $hxClasses["openfl.net.SecureSocket"] = SecureSocket;
// Init
// Statics
SecureSocket.get_isSupported = function() {
return false;
}
// Export
exports.default = SecureSocket;