• otbuild
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies

Hi,

 

How do we generate authentication token using HMACSHA1 in Apex?

 

Thanks,

Prasad

Hi,

 

How do we convert String to Byte?

 

Thanks,

Prasad

Hi,

 

We are using following C# code to generate authentication token. We with to migrate following code to Apex:

 

private static string GenerateAuthToken(string sInputName)
              {
                     try
                     {
                           // Concat SecretKey and AccountName which are the encryption parameters
                           string sEncryptionParameters = m_sSecretKey + sInputName;

                           // set the hashing key as the partner key
                           string sHashingKey = m_sPartnerKey;

                           // choose ASCII encoding
                           Encoding oCurrentEncoding = Encoding.ASCII;

                           // Use the hashing key to Encrypt the parameter list using HMAC-SHA1
                           HMACSHA1 oHMACSHA1 = new HMACSHA1(oCurrentEncoding.GetBytes(sHashingKey));

                           // Convert the EncryptionParameters into bytes
                           byte[] arrBytesEncryptionParameter = oCurrentEncoding.GetBytes(sEncryptionParameters);

                           // generate the auth token
                           string sAuthToken = BitConverter.ToString(oHMACSHA1.ComputeHash(arrBytesEncryptionParameter)).Replace("-", string.Empty).ToLower();

                           return sAuthToken;
                     }

 

 

The problem we are facing is we are not able to convert "String" to "Byte" and not finding "BitConverter" equivalent in Apex. Please suggest.

 

Thanks,

Prasad

Hi All

We have some kind of unique problem.

On Opportunity, While adding Opportunity product when we give 100% discount it shows Total price = 0.0 and sales price = 100.00 $ (For e.g.. Only)
But when we update above product without changing any value ( Just click on Edit and click on Save ) Sales Price become null.
We can't figure it out why sales price is becoming NULL.


We have some logic on Before Insert / Before update of Opportunity Product which set Discount field to some value depends on some conditions.
We observe when we remove this logic the issue is not reproducible. Same issue is not reproducible when we provide any discount other than 100%.
Same logic is getting fired here also). We can’t understand how sales price will become NULL if we set discount = 100%. (If sales price become 0.00$ it is acceptable)

Could you suggest some pointers?

When I try to create validation rule on Opportunity Object, I get "Error: java.lang.NullPointerException". The Error Condition Formula for validation rule is as shown below:

AND
(
ISPICKVAL( Account.Restaurant_Country__c , "India") = false,
NOT(ISPICKVAL(PRIORVALUE( StageName),'Closed Won')),
ISPICKVAL(StageName, 'Closed Won'),
ISBLANK(Account.PC__c)
)

When I remove first and last conditions in Formula, I do not get null pointer exception. I'm getting null pointer exception on only one sandbox. When I try to create valiation rule with same formula on other sandbox, I do not get exception.

Because of this exception, we are not able to deliver these valiation rules from one sandbox to other using Change Set. Any thoughts on why null pointer exception and how do we resolve this issue?

Need to add filter on Contact Name Lookup field on Quote to display only those Contacts linked to the Account. At present, Contact lookup on Quote shows all the Contacts. I tried to add Lookup Filter on Contact Name field but not able to add desired filter. Please suggest.

We are working on synchronization where records from "Account Teams" section on Account object will be synchronized with other system. The trigger for synchronization is, when Users are added/changed/removed from Account Teams for Account. During investigation on how to detect changes in Account Teams, we found that when Users added/changed/removed from "Account Teams" section on Account, trigger on Account object is NOT fired. Also we cannot write trigger on AccountTeamMember standard object because it is not supported in SFDC. AccountTeamMember object is not available for "Field Update" and "Workflow Rule". What is the best way to detect changes in Account Teams?

Need to add filter on Contact Name Lookup field on Quote to display only those Contacts linked to the Account. At present, Contact lookup on Quote shows all the Contacts. I tried to add Lookup Filter on Contact Name field but not able to add desired filter. Please suggest.

Hi,

 

How do we generate authentication token using HMACSHA1 in Apex?

 

Thanks,

Prasad

Hi,

 

How do we convert String to Byte?

 

Thanks,

Prasad

Hi,

 

We are using following C# code to generate authentication token. We with to migrate following code to Apex:

 

private static string GenerateAuthToken(string sInputName)
              {
                     try
                     {
                           // Concat SecretKey and AccountName which are the encryption parameters
                           string sEncryptionParameters = m_sSecretKey + sInputName;

                           // set the hashing key as the partner key
                           string sHashingKey = m_sPartnerKey;

                           // choose ASCII encoding
                           Encoding oCurrentEncoding = Encoding.ASCII;

                           // Use the hashing key to Encrypt the parameter list using HMAC-SHA1
                           HMACSHA1 oHMACSHA1 = new HMACSHA1(oCurrentEncoding.GetBytes(sHashingKey));

                           // Convert the EncryptionParameters into bytes
                           byte[] arrBytesEncryptionParameter = oCurrentEncoding.GetBytes(sEncryptionParameters);

                           // generate the auth token
                           string sAuthToken = BitConverter.ToString(oHMACSHA1.ComputeHash(arrBytesEncryptionParameter)).Replace("-", string.Empty).ToLower();

                           return sAuthToken;
                     }

 

 

The problem we are facing is we are not able to convert "String" to "Byte" and not finding "BitConverter" equivalent in Apex. Please suggest.

 

Thanks,

Prasad

Need to add filter on Contact Name Lookup field on Quote to display only those Contacts linked to the Account. At present, Contact lookup on Quote shows all the Contacts. I tried to add Lookup Filter on Contact Name field but not able to add desired filter. Please suggest.