Skip to content

Commit

Permalink
Получение сертификатов
Browse files Browse the repository at this point in the history
  • Loading branch information
bankrot committed Sep 21, 2015
1 parent bd5151b commit f01fc53
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/alt_cadesplugin_api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ AltCadesPlugin = class

return deferred

###*
Создает объект плагина по названию
@method createObject
@param name {String} Название объекта
@return {jQuery.Deferred} Deferred объект с разультатом выполнения в качестве аргумента колбэка
###
createObject: (name)=>
deferred = $.Deferred()
@pluginObject.CreateObjectAsync name
Expand Down
8 changes: 8 additions & 0 deletions src/alt_cadesplugin_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ AltCadesPlugin = (function() {
return deferred;
};


/**
Создает объект плагина по названию
@method createObject
@param name {String} Название объекта
@return {jQuery.Deferred} Deferred объект с разультатом выполнения в качестве аргумента колбэка
*/

_Class.prototype.createObject = function(name) {
var deferred;
deferred = $.Deferred();
Expand Down
19 changes: 19 additions & 0 deletions test/coffee/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ init = =>
deferred = $.Deferred ->
@reject 'Браузер не поддерживается'

# проверка версии плагина
deferred.then ->
$logBlock.append '<p>Плагин подключен<p>'
$.when(
Expand All @@ -22,6 +23,7 @@ init = =>
$.get '/sites/default/files/products/cades/latest_2_0.txt'
)

# проверка версии CSP
.then (majorVersion, minorVersion, buildVersion, currentVersion)->
installedVersion = majorVersion + '.' + minorVersion + '.' + buildVersion
if installedVersion is currentVersion[0]?.trim()
Expand All @@ -35,9 +37,26 @@ init = =>
altCadesPlugin.get 'CAdESCOM.About', {paramName: 'CSPVersion', options: ['', 75]}, 'BuildVersion'
)

# получение списка сертификатов
.then (majorVersion, minorVersion, buildVersion)->
installedCspVersion = majorVersion + '.' + minorVersion + '.' + buildVersion
$logBlock.append '<p>Версия CSP (' + installedCspVersion + ')<p>'

store = null
certificates = null
altCadesPlugin.createObject 'CAdESCOM.Store'
.then (_store)->
store = _store
altCadesPlugin.get store, {paramName: 'Open', options: []}
.then ->
altCadesPlugin.get store, 'Certificates'
.then (_certificates)->
certificates = _certificates
altCadesPlugin.get certificates, 'Count'
.then (count)->
$logBlock.append '<p>Количество сертификатов ' + +count + '<p>'

.then ->
$signBlock.show()

.fail (message)->
Expand Down
8 changes: 8 additions & 0 deletions test/js/alt_cadesplugin_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ AltCadesPlugin = (function() {
return deferred;
};


/**
Создает объект плагина по названию
@method createObject
@param name {String} Название объекта
@return {jQuery.Deferred} Deferred объект с разультатом выполнения в качестве аргумента колбэка
*/

_Class.prototype.createObject = function(name) {
var deferred;
deferred = $.Deferred();
Expand Down
19 changes: 18 additions & 1 deletion test/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,26 @@ init = (function(_this) {
options: ['', 75]
}, 'BuildVersion'));
}).then(function(majorVersion, minorVersion, buildVersion) {
var installedCspVersion;
var certificates, installedCspVersion, store;
installedCspVersion = majorVersion + '.' + minorVersion + '.' + buildVersion;
$logBlock.append('<p>Версия CSP (' + installedCspVersion + ')<p>');
store = null;
certificates = null;
return altCadesPlugin.createObject('CAdESCOM.Store').then(function(_store) {
store = _store;
return altCadesPlugin.get(store, {
paramName: 'Open',
options: []
});
}).then(function() {
return altCadesPlugin.get(store, 'Certificates');
}).then(function(_certificates) {
certificates = _certificates;
return altCadesPlugin.get(certificates, 'Count');
}).then(function(count) {
return $logBlock.append('<p>Количество сертификатов ' + +count + '<p>');
});
}).then(function() {
return $signBlock.show();
}).fail(function(message) {
return $logBlock.append('<p style="color: #E23131">' + message + '<p>');
Expand Down

0 comments on commit f01fc53

Please sign in to comment.