• Labrix
  • NEWBIE
  • 25 Points
  • Member since 2010

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

I have been attempting to create a VF page that automatically redirects to another page on my sites. I do not want it to display anything simply redirect. I have looked across the all the documentation only to get lost in mountains of information. I figure this is fairly simple, I just can't seem to get it to work. Any help would be appreciated.

 

 

Here is what I have been trying to use.

<apex:page action="{page2}">

</apex:page>

My Company is attempting to use Amazon S3 for storage of various image files that need to be kept secure.  To do this we have setup Amazon's s3 service with an encrypted key security system.  This system fails about 50% of the time for some unknown reason that we think is to do with the clocks at Amazon and Sales-force being slightly off.  

 

We would like to know why our system is failing sometimes (producing broken image links) and if their is a simple fix to allow the passthrough to work.

 

Code:

 

    public static String GenerateAWSLink(Boolean isFront, String barcode){
    	String bucketName = '';
    	String fileName = '';
    	if(isFront){
    		bucketName = 'front_' + AWSAmazonS3.key.toLowerCase();
    		fileName = barcode.toUpperCase() + '_front.jpg';
    	}
    	else{
    		bucketName = 'back_' + AWSAmazonS3.key.toLowerCase();
    		fileName = barcode.toUpperCase() + '_back.jpg';
    	}

        fileName = EncodingUtil.urlEncode(fileName, 'UTF-8');
        
        Datetime now = DateTime.now();
        //Not working due to being 1 second off of AWS or something along those lines.
        
        String stringToSign = 'GET\n\n\n' + now.addSeconds(240).getTime()/1000 + '\n/' + bucketName + '/' + fileName;
        System.debug(stringToSign);
        String signed = GetAWSSignature(stringToSign);
        System.debug(signed);
        String codedsigned = EncodingUtil.urlEncode(signed, 'UTF-8');
        System.debug(codedsigned);
        String url = 'https://s3.amazonaws.com/' + bucketName + '/' + fileName + '?AWSAccessKeyId=' + AWSCredentials.key + '&Expires=' + now.addSeconds(240).getTime()/1000 + '&Signature=' + signed;
        System.debug(url);
        return url;
    }
    
    private static String GetAWSSignature(String toSign){
        String macUrl;
        String signingKey = EncodingUtil.base64Encode(Blob.valueOf(AWSCredentials.secret));
        Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(toSign), blob.valueof(AWSCredentials.secret)); 
        macUrl = EncodingUtil.base64Encode(mac);                
        return macUrl;
    }
}

 

 

Thanks for your help!

 

  • September 28, 2010
  • Like
  • 0

HI,

 

I have developed a login page for the partner portal in that there is a command link "forgot you password" which is not at working below  is the  code.Initially it was working  all of a sudden it was stopped working.Can any one help me.

 

 VF code:

 

 <div>
                  <table border="0" cellpadding="0" cellspacing="0">
                      <tr>
                          <td> <apex:commandLink value="Forgot your password?" action="{!ForgotPasswordLink}"/> </td>
                       </tr>
                  </table>
             </div> 

 

controller  method code :

Global pageReference ForgotPasswordLink (){       
String startURL = ' ';       
if(url.contains('cs')){           
startURL = 'https://tapp0.salesforce.com/secur/forgotpasswordp.jsp';         
  startURL += '?orgId=*************&portalId=**************&loginType=3';
            startURL += '&pLu=%2Fsecur%2Flogin_portal.jsp';          
    }        

else{            
startURL = 'https://na7.salesforce.com/secur/forgotpasswordp.jsp';       
    startURL += '?orgId=*************&portalId=*******************&loginType=3';
           startURL += '&pLu=%2Fsecur%2Flogin_portal.jsp';       
 }                           

pageReference p = new PageReference(startURL);      
 p.setredirect(true);      
 return p;   

 }

 

  • September 29, 2010
  • Like
  • 0

I have been attempting to create a VF page that automatically redirects to another page on my sites. I do not want it to display anything simply redirect. I have looked across the all the documentation only to get lost in mountains of information. I figure this is fairly simple, I just can't seem to get it to work. Any help would be appreciated.

 

 

Here is what I have been trying to use.

<apex:page action="{page2}">

</apex:page>

My Company is attempting to use Amazon S3 for storage of various image files that need to be kept secure.  To do this we have setup Amazon's s3 service with an encrypted key security system.  This system fails about 50% of the time for some unknown reason that we think is to do with the clocks at Amazon and Sales-force being slightly off.  

 

We would like to know why our system is failing sometimes (producing broken image links) and if their is a simple fix to allow the passthrough to work.

 

Code:

 

    public static String GenerateAWSLink(Boolean isFront, String barcode){
    	String bucketName = '';
    	String fileName = '';
    	if(isFront){
    		bucketName = 'front_' + AWSAmazonS3.key.toLowerCase();
    		fileName = barcode.toUpperCase() + '_front.jpg';
    	}
    	else{
    		bucketName = 'back_' + AWSAmazonS3.key.toLowerCase();
    		fileName = barcode.toUpperCase() + '_back.jpg';
    	}

        fileName = EncodingUtil.urlEncode(fileName, 'UTF-8');
        
        Datetime now = DateTime.now();
        //Not working due to being 1 second off of AWS or something along those lines.
        
        String stringToSign = 'GET\n\n\n' + now.addSeconds(240).getTime()/1000 + '\n/' + bucketName + '/' + fileName;
        System.debug(stringToSign);
        String signed = GetAWSSignature(stringToSign);
        System.debug(signed);
        String codedsigned = EncodingUtil.urlEncode(signed, 'UTF-8');
        System.debug(codedsigned);
        String url = 'https://s3.amazonaws.com/' + bucketName + '/' + fileName + '?AWSAccessKeyId=' + AWSCredentials.key + '&Expires=' + now.addSeconds(240).getTime()/1000 + '&Signature=' + signed;
        System.debug(url);
        return url;
    }
    
    private static String GetAWSSignature(String toSign){
        String macUrl;
        String signingKey = EncodingUtil.base64Encode(Blob.valueOf(AWSCredentials.secret));
        Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(toSign), blob.valueof(AWSCredentials.secret)); 
        macUrl = EncodingUtil.base64Encode(mac);                
        return macUrl;
    }
}

 

 

Thanks for your help!

 

  • September 28, 2010
  • Like
  • 0