Este fórum foi descontinuado. LEIA AQUI e participe da Comunidade BABOO :)

Ir para conteúdo
Forever

Arquivo danificado

Mensagem Recomendada

Caros amigos, recuperei varias copias de um arquivo .doc, só que todas as copias estão danificadas, dessa maneira aparece,** , será que alguém poderia me ajudar a fazer algo para recuperar???

--------------------------------------

***** // set a label to normal style

function markLabelNormal(spn) {

spn.style.color="#000000";

spn.style.fontWeight=''normal'';

}

//----------------------------------------------------------------

// set a label to error state

function markLabelError(spn) {

spn.style.color=''#FF0000'';

spn.style.fontWeight=''bold'';

}

//----------------------------------------------------------------

// check that the form has data in it

function validateRequest() {

markLabelNormal(spnNameLabel);

markLabelNormal(spnEmailLabel);

markLabelNormal(spnCompanyLabel);

markLabelNormal(spnDepartmentLabel);

markLabelNormal(spnCityLabel);

markLabelNormal(spnStateLabel);

markLabelNormal(spnCountryLabel);

var bOK=true;

<%If "Enterprise"=sServerType Then%>

if (true==isOfflineTemplate()) {

<%End If%>

var fldFocusMe=null;

if (false==isValidCountryField(document.UIForm.tbCountry)) {

bOK=false;

fldFocusMe=document.UIForm.tbCountry;

markLabelError(spnCountryLabel);

}

if (false==isValidX500String(document.UIForm.tbState.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbState;

markLabelError(spnStateLabel);

}

if (false==isValidX500String(document.UIForm.tbLocality.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbLocality;

markLabelError(spnCityLabel);

}

if (false==isValidX500String(document.UIForm.tbOrgUnit.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbOrgUnit;

markLabelError(spnDepartmentLabel);

}

if (false==isValidX500String(document.UIForm.tbOrg.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbOrg;

markLabelError(spnCompanyLabel);

}

if (false==isValidX500String(document.UIForm.tbEmail.value) // false==isValidIA5String(document.UIForm.tbEmail.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbEmail;

markLabelError(spnEmailLabel);

}

if (false==isValidX500String(document.UIForm.tbCommonName.value)) {

bOK=false;

fldFocusMe=document.UIForm.tbCommonName;

markLabelError(spnNameLabel);

}

if (false==bOK) {

spnFixTxt.style.display='''';

window.scrollTo(0,0);

fldFocusMe.focus();

}

<%If "Enterprise"=sServerType Then%>

} // <- End if offline template

<%End If%>

// Check the keysize field

if (true==bOK) {

// get the min and max from the CSP

var bExchange=document.UIForm.rbKeyUsage.checked // document.UIForm.rbKeyUsage.checked;

var nKeyMin=MyGetKeyLen(KEY_LEN_MIN, bExchange);

var nKeyMax=MyGetKeyLen(KEY_LEN_MAX, bExchange);

var nKeySize=parseInt(document.UIForm.tbKeySize.value);

var sMessage;

if (isNaN(nKeySize)) {

sMessage=L_KeySizeNotNumber_ErrorMessage;

bOK=false;

} else if (nKeySizenKeyMax) {

sMessage=eval(L_KeySizeBadNumber_ErrorMessage);

bOK=false;

}

if (false==bOK) {

alert (sMessage);

document.UIForm.tbKeySize.focus();

}

}

// Check the container name

if (true==bOK) {

if (document.UIForm.rbKeyGen<0>.checked) {

// new keyset

if (document.UIForm.cbSetContainer.checked) {

if (""==document.UIForm.tbNewContainerName.value) {

bOK=false;

}

}

} else {

// existing keyset

if (""==document.UIForm.tbOldContainerName.value) {

bOK=false;

}

}

if (false==bOK) {

******L_NoCntnrName_ErrorMessage);

if (document.UIForm.rbKeyGen<0>.checked) {

document.UIForm.tbNewContainerName.focus();

} else {

document.UIForm.tbOldContainerName.focus();

}

}

}

// Check the exported private key file name

if (true==bOK) {

if (document.UIForm.cbMarkKeyExportable.checked && document.UIForm.cbExportKeys.checked) {

if (""==document.UIForm.tbExportKeyFile.value) {

bOK=false;

******L_NoExportFileName_ErrorMessage);

document.UIForm.tbExportKeyFile.focus();

}

}

}

// Check the saved-request file name

if (true==bOK) {

if (document.UIForm.cbSaveRequest.checked) {

if (""==document.UIForm.tbSaveReqFile.value) {

bOK=false;

******L_NoSaveReqFileName_ErrorMessage);

document.UIForm.tbSaveReqFile.focus();

}

}

}

return bOK;

}

//----------------------------------------------------------------

function SubmitRequest() {

// check that the form is filled in

spnErrorTxt.style.display=''none'';

spnFixTxt.style.display=''none'';

if (false==validateRequest()) {

return;

}

// show a nice message since request creation can take a while

ShowTransientMessage(L_Generating_Message);

// Make the message show up on the screen,

// then continue with ''SubmitRequest'':

// Pause 1 mS before executing phase 2,

// so screen will have time to repaint.

setTimeout("SubmitRequestPhase2();",1);

}

function SubmitRequestPhase2() {

// continued from above

<%If "StandAlone"=sServerType Then%>

//

// Stand-Alone Options

//

// set the extended key usage and certificate request ''friendly type''

var nUsageIndex=document.UIForm.lbUsageOID.selectedIndex;

var sCertUsage;

if ("**"==document.UIForm.lbUsageOID.options.value) {

sCertUsage=document.UIForm.tbEKUOther.value;

document.SubmittedData.FriendlyType.value=eval(L_UserEKUCert_Text);

} else {

sCertUsage=document.UIForm.lbUsageOID.options.value;

document.SubmittedData.FriendlyType.value=document.UIForm.lbUsageOID.options.text;

}

DoEkuSpecificSettings(sCertUsage);

<%Else ''Enterprise%>

//

// Enterprise Options

//

// get the selected template

var nTemplateIndex=document.UIForm.lbCertTemplate.selectedIndex;

var sTemplate=document.UIForm.lbCertTemplate.options.value;

// Turn on SMIME capabilities if necessary

if ("Y"==sTemplate.substring(1,2)) {

XEnroll.EnableSMIMECapabilities=true;

}

// extract the template name (skip the first two chars)

sTemplate=sTemplate.slice(2);

// set the cert template

XEnroll.addCertTypeToRequest(sTemplate);

document.SubmittedData.FriendlyType.value=eval(L_TemplateCert_Text);

var sCertUsage=""; // ignored

<%End If ''StandAlone or Enterprise%>

//

// Common

//

// set the identifying info

var sDistinguishedName="";

if (""!=document.UIForm.tbCountry.value) {

sDistinguishedName+="C=""+document.UIForm.tbCountry.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbState.value) {

sDistinguishedName+="S=""+document.UIForm.tbState.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbLocality.value) {

sDistinguishedName+="L=""+document.UIForm.tbLocality.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbOrg.value) {

sDistinguishedName+="O=""+document.UIForm.tbOrg.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbOrgUnit.value) {

sDistinguishedName+="OU=""+document.UIForm.tbOrgUnit.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbEmail.value) {

sDistinguishedName+="E=""+document.UIForm.tbEmail.value.replace(/"/g, """") +"";";

}

if (""!=document.UIForm.tbCommonName.value) {

sDistinguishedName+="CN=""+document.UIForm.tbCommonName.value.replace(/"/g, """")+"";";

}

<%If "Enterprise"=sServerType Then%>

if (false==isOfflineTemplate()) {

sDistinguishedName="";

}

<%End If%>

// append the local date to the type

document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";

//

// Key Options subheading:

//

// set the CSP

var nCSPIndex=document.UIForm.lbCSP.selectedIndex;

XEnroll.ProviderName=document.UIForm.lbCSP.options.text;

XEnroll.ProviderType=document.UIForm.lbCSP.options.value;

// set the key size (the upper 16 bits of GenKeyFlags)

// note: this value has already been validated

var nKeySize=parseInt(document.UIForm.tbKeySize.value);

XEnroll.GenKeyFlags=nKeySize<<16;

// set the KeyUsage

if (document.UIForm.rbKeyUsage[KEY_USAGE_EXCH>.checked) {

XEnroll.KeySpec=AT_KEYEXCHANGE;

XEnroll.LimitExchangeKeyToEncipherment=true;

} else if (document.UIForm.rbKeyUsage.checked) {

XEnroll.KeySpec=AT_SIGNATURE;

XEnroll.LimitExchangeKeyToEncipherment=false;

} else { // KEY_USAGE_BOTH

XEnroll.KeySpec=AT_KEYEXCHANGE;

XEnroll.LimitExchangeKeyToEncipherment=false;

}

// set the ''use existing key set'' flag

if (document.UIForm.rbKeyGen<0>.checked) {

XEnroll.UseExistingKeySet=false;

if (document.UIForm.cbSetContainer.checked) {

XEnroll.ContainerName=document.UIForm.tbNewContainerName.value;

}

} else {

XEnroll.UseExistingKeySet=true;

XEnroll.ContainerName=document.UIForm.tbOldContainerName.value;

}

// set ''Strong private key protection''

// note: upper 16 bits already set as key size

if (document.UIForm.cbStrongKey.checked) {

XEnroll.GenKeyFlags/=CRYPT_USER_PROTECTED;

}

// set the ''SaveCert'' flag to install the cert instead of saving

document.SubmittedData.SaveCert.value="no";

// mark the keys as exportable

if (document.UIForm.cbMarkKeyExportable.checked) {

XEnroll.GenKeyFlags/=CRYPT_EXPORTABLE;

// set the key export file (.pvk) and save the cert instead of installing

if (document.UIForm.cbExportKeys.checked) {

XEnroll.PVKFileName=document.UIForm.tbExportKeyFile.value;

document.SubmittedData.SaveCert.value="yes";

}

}

// place the keys in the local machine store

if (document.UIForm.cbLocalMachineStore.checked) {

// the keys attached to the dummy request cert go in the local machine store

XEnroll.RequestStoreFlags=CERT_SYSTEM_STORE_LOCAL_MACHINE;

// used in CryptAcquireContext

XEnroll.ProviderFlags=CRYPT_MACHINE_KEYSET;

// the keys attached to the final cert also go in the local machine store

document.SubmittedData.TargetStoreFlags.value=CERT_SYSTEM_STORE_LOCAL_MACHINE;

} else {

// the keys attached to the final cert also go in the user store

document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store)

}

//

// Additional Options subheading:

//

// set the hash algorithm

var nHashIndex=document.UIForm.lbHashAlgorithm.selectedIndex;

XEnroll.HashAlgID=document.UIForm.lbHashAlgorithm.options.value;

// set any extra attributes

var sAttrib=document.UIForm.taAttrib.value;

if (sAttrib.lastIndexOf("rn")!=sAttrib.length-2 && sAttrib.length]0) {

sAttrib=sAttrib+"rn";

}

// for interop debug purposes

sAttrib+="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>rn";

document.SubmittedData.CertAttrib.value=sAttrib;

// we are submitting a new request

document.SubmittedData.Mode.value=''newreq'';

//

// Create the request

//

if (document.UIForm.cbSaveRequest.checked) {

// build and save the certificate request

var nResult;

var sSaveReqFile=document.UIForm.tbSaveReqFile.value;

nResult=CreateAndSaveRequest(sDistinguishedName, sCertUsage, sSaveReqFile); // ask VB to do it, since it can handle errors

} else {

// build the certificate request

var nResult=CreateRequest(sDistinguishedName, sCertUsage); // ask VB to do it, since it can handle errors

}

// hide the message box

HideTransientMessage();

// reset XEnroll so the user can select a different CSP, etc.

XEnroll.reset();

// however, make sure it still matches the UI.

XEnroll.ProviderName=document.UIForm.lbCSP.options.text;

XEnroll.ProviderType=document.UIForm.lbCSP.options.value;

// deal with an error if there was one

if (0!=nResult) {

handleError(nResult);

return;

}

// check for special "no submit" case

if (document.UIForm.cbSaveRequest.checked) {

// just inform the user that it went OK, but don''t submit

******L_RequestSaved_Message);

} else {

// put up a new wait message

ShowTransientMessage(L_Waiting_Message);

// Submit the cert request and move forward in the wizard

document.SubmittedData.submit();

}

}

//----------------------------------------------------------------

function handleError(nResult) {

var sSugCause=L_SugCauseNone_ErrorMessage;

var sErrorName=L_ErrNameUnknown_ErrorMessage;

// analyze the error - funny use of XOR (''^'') because obvious choice ''=='' doesn''t work

if (0==(0x80090008^nResult)) {

sErrorName="NTE_BAD_ALGID";

sSugCause=L_SugCauseBadSetting2_ErrorMessage;

} else if (0==(0x80090016^nResult)) {

sErrorName="NTE_BAD_KEYSET";

if (document.UIForm.rbKeyGen<0>.checked) {

sSugCause=L_SugCauseBadCSP_ErrorMessage;

} else {

sSugCause=L_SugCauseBadKeyContainer_ErrorMessage;

}

} else if (0==(0x80090019^nResult)) {

sErrorName="NTE_KEYSET_NOT_DEF";

sSugCause=L_SugCauseBadCSP_ErrorMessage;

} else if (0==(0x80090020^nResult)) {

sErrorName="NTE_FAIL";

sSugCause=L_SugCauseBadCSP_ErrorMessage;

} else if (0==(0x80090009^nResult)) {

sErrorName="NTE_BAD_FLAGS";

sSugCause=L_SugCauseBadSetting2_ErrorMessage;

} else if (0==(0x8009000F^nResult)) {

sErrorName="NTE_EXISTS";

sSugCause=L_SugCauseExistKeyContainer_ErrorMessage;

} else if (0==(0x80092002^nResult)) {

sErrorName="CRYPT_E_BAD_ENCODE";

//sSugCause="";

} else if (0==(0x80092022^nResult)) {

sErrorName="CRYPT_E_INVALID_IA5_STRING";

sSugCause=L_SugCauseBadChar_ErrorMessage;

} else if (0==(0x80092023^nResult)) {

sErrorName="CRYPT_E_INVALID_X500_STRING";

sSugCause=L_SugCauseBadChar_ErrorMessage;

} else if (0==(0x80070003^nResult)) {

sErrorName="ERROR_PATH_NOT_FOUND";

sSugCause=L_SugCauseBadFileName_ErrorMessage;

} else if (0==(0x80070103^nResult)) {

sErrorName="ERROR_NO_MORE_ITEMS";

sSugCause=L_SugCauseBadHash_ErrorMessage;

} else if (0==(0xFFFFFFFF^nResult)) {

sErrorName=L_ErrNameNoFileName_ErrorMessage;

sSugCause=L_SugCauseNoFileName_ErrorMessage;

} else if (0==(0x8000FFFF^nResult)) {

sErrorName="E_UNEXPECTED";

} else if (0==(0x00000046^nResult)) {

sErrorName=L_ErrNamePermissionDenied_ErrorMessage;

sSugCause=L_SugCauseNotAdmin_ErrorMessage;

}

// modify the document text and appearance to show the error message

spnErrorNum.innerText="0x"+toHex(nResult)+" - "+sErrorName;

spnErrorMsg.innerText=sSugCause;

spnFixTxt.style.display=''none'';

spnErrorTxt.style.display='''';

// back to the top so the messages show

window.scrollTo(0,0);

}

''-----------------------------------------------------------------

'' call XEnroll to create a request, since javascript has no error handling

Function CreateRequest(sDistinguishedName, sCertUsage)

On Error Resume Next

document.SubmittedData.CertRequest.value= _

XEnroll.CreatePKCS10(sDistinguishedName, sCertUsage)

CreateRequest=Err.Number

End Function

''-----------------------------------------------------------------

'' call XEnroll to create and save a request, since javascript has no error handling

Function CreateAndSaveRequest(sDistinguishedName, sCertUsage, sSaveReqFile)

On Error Resume Next

XEnroll.CreateFilePKCS10 sDistinguishedName, sCertUsage, sSaveReqFile

CreateAndSaveRequest=Err.Number

End Function

''----------------------------------------------------------------

'' handle a change in the current CSP, since javascript has no error handling

Sub UpdateHashAlgList

On Error Resume Next


Marcio Melin

Compartilhar este post


Link para o post
Compartilhar em outros sites

×
×
  • Criar Novo...