src/vendor/forge-pki.js
/**
 * Fills in missing fields in attributes.
 *
 * @param attrs the attributes to fill missing fields in.
 */
Fills in missing fields in attributes.
@param attrs the attributes to fill missing fields in.
Fills in missing fields in attributes . @param attrs the attributes to fill missing fields in .
function _fillMissingFields(attrs) {
  var attr;
  for(var i = 0; i < attrs.length; ++i) {
    attr = attrs[i];
    if(typeof attr.name === 'undefined') {
      if(attr.type && attr.type in pki.oids) {
        attr.name = pki.oids[attr.type];
      } else if(attr.shortName && attr.shortName in _shortNames) {
        attr.name = pki.oids[_shortNames[attr.shortName]];
      }
    }
    if(typeof attr.type === 'undefined') {
      if(attr.name && attr.name in pki.oids) {
        attr.type = pki.oids[attr.name];
      } else {
        var error = new Error('Attribute type not specified.');
        error.attribute = attr;
        throw error;
      }
    }
    if(typeof attr.shortName === 'undefined') {
      if(attr.name && attr.name in _shortNames) {
        attr.shortName = _shortNames[attr.name];
      }
    }
    if(attr.type === oids.extensionRequest) {
      attr.valueConstructed = true;
      attr.valueTagClass = asn1.Type.SEQUENCE;
      if(!attr.value && attr.extensions) {
        attr.value = [];
        for(var ei = 0; ei < attr.extensions.length; ++ei) {
          attr.value.push(pki.certificateExtensionToAsn1(
            _fillMissingExtensionFields(attr.extensions[ei])));
        }
      }
    }
    if(typeof attr.value === 'undefined') {
      var error = new Error('Attribute value not specified.');
      error.attribute = attr;
      throw error;
    }
  }
}
function _fillMissingFields ( attrs ) { var attr ; for ( var i = 0 ; i < attrs . length ; ++ i ) { attr = attrs [ i ] ; if ( typeof attr . name === 'undefined' ) { if ( attr . type && attr . type in pki . oids ) { attr . name = pki . oids [ attr . type ] ; } else if ( attr . shortName && attr . shortName in _shortNames ) { attr . name = pki . oids [ _shortNames [ attr . shortName ] ] ; } } if ( typeof attr . type === 'undefined' ) { if ( attr . name && attr . name in pki . oids ) { attr . type = pki . oids [ attr . name ] ; } else { var error = new Error ( 'Attribute type not specified.' ) ; error . attribute = attr ; throw error ; } } if ( typeof attr . shortName === 'undefined' ) { if ( attr . name && attr . name in _shortNames ) { attr . shortName = _shortNames [ attr . name ] ; } } if ( attr . type === oids . extensionRequest ) { attr . valueConstructed = true ; attr . valueTagClass = asn1 . Type . SEQUENCE ; if ( ! attr . value && attr . extensions ) { attr . value = [ ] ; for ( var ei = 0 ; ei < attr . extensions . length ; ++ ei ) { attr . value . push ( pki . certificateExtensionToAsn1 ( _fillMissingExtensionFields ( attr . extensions [ ei ] ) ) ) ; } } } if ( typeof attr . value === 'undefined' ) { var error = new Error ( 'Attribute value not specified.' ) ; error . attribute = attr ; throw error ; } } }
Fills in missing fields in attributes.
Fills in missing fields in attributes .
// populate missing name // populate missing type (OID) // populate missing shortname // convert extensions to value