Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Moz API
      • Moz API Home
      • Compare SEO Products
      • Moz Data
    • Free SEO Tools
      • Domain Analysis
      • Keyword Explorer
      • Link Explorer
      • Competitive Research
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your all-in-one suite of SEO essentials.

      • Moz Local

        Raise your local SEO visibility with complete local SEO management.

      • STAT

        SERP tracking and analytics for enterprise SEO experts.

      • Moz API

        Power your SEO with our index of over 44 trillion links.

      • Compare SEO Products

        See which Moz SEO solution best meets your business needs.

      • Moz Data

        Power your SEO strategy & AI models with custom data solutions.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Free SEO Tools
      • Domain Analysis

        Get top competitive SEO metrics like DA, top pages and more.

      • Keyword Explorer

        Find traffic-driving keywords with our 1.25 billion+ keyword index.

      • Link Explorer

        Explore over 40 trillion links for powerful backlink data.

      • Competitive Research

        Uncover valuable insights on your organic search competitors.

      • MozBar

        See top SEO metrics for free as you browse the web.

      • More Free SEO Tools

        Explore all the free SEO tools Moz has to offer.

      What is your Brand Authority?
      Moz

      What is your Brand Authority?

      Check yours now
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

      • SEO Q&A

        Insights & discussions from an SEO community of 500,000+.

      Unlock flexible pricing & new endpoints
      Moz API

      Unlock flexible pricing & new endpoints

      Find your plan
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

      • New Releases

        Get the scoop on the latest and greatest from Moz.

      Surface actionable competitive intel
      New Feature

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Moz API
      • Moz API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. Home
    2. SEO Tactics
    3. Technical SEO
    4. Generating a signature and expires in java

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    Generating a signature and expires in java

    Technical SEO
    1
    3
    828
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question management privileges can see it.
    • TRich50
      TRich50 last edited by

      Hello,

      I am developing a tool for my company to get stats from SeoMoz using your API.  During development, I have been using the example signature and expires values which are auto-generated for me.  Now that testing is complete, my code will need to generate these values.  I have been googling looking for a resource demonstrating how to do this using Java, but I have not found a good example.  I was hoping that someone at SeoMoz would have a resource or an example that they could share.

      The email associated with this account belongs to a non-developer, so if a response is provided via email in addition to the forum, sending it to my email would be much appreciated.

      Thank you,

      Anthony

      aruffino@ignitemedia.com

      1 Reply Last reply Reply Quote 0
      • TRich50
        TRich50 last edited by

        Never mind,  I have come up with a solution:

        package com.yourpackage.signature;

        import java.io.IOException;
        import java.security.InvalidKeyException;
        import java.security.NoSuchAlgorithmException;
        import java.util.Date;

        import javax.crypto.Mac;
        import javax.crypto.spec.SecretKeySpec;

        import org.apache.geronimo.mail.util.Base64; //can be whichever flavor of encoder you'd like

        public class SignatureGenerator {

        public static final String ACCESS_ID = "member-XXXXXXX";
            public static final String SECRET_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXx";

        //expireTime should be in seconds since Jan 1 1970 : new Date().getTime()/1000) + X
            public static String generateSignature(String data, String key, String expireTime, String algorithm)
                    throws InvalidKeyException, NoSuchAlgorithmException, IOException {

        data += expireTime;

        byte[] hmacData = null;

        SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"),
                            algorithm);
                    Mac mac = Mac.getInstance(algorithm);
                    mac.init(secretKey);
                    hmacData = mac.doFinal(data.getBytes("UTF-8"));

        String encoded = new String(Base64.encode(hmacData));

        return encoded;
            }

        public static void main(String[] args) {
                try {

        Long longTime = new Long(new Date().getTime()/1000) + 60;

        System.out.println(longTime);

        String data = ACCESS_ID + "\n";

        System.out.println(generateSignature(data, SECRET_KEY, String.valueOf(longTime), "HMACSHA1"));
                } catch (Exception e) {
                    e.printStackTrace();
                }

        }

        }

        1 Reply Last reply Reply Quote 0
        • TRich50
          TRich50 last edited by

          There has been no response from SeoMoz on this forum or to my email.

          Please provide some feedback.  I am afraid If I cannot solve this issue I will be forced to cancel our account as it is not practical for me to manually load the sample signature and expired value on a daily basis.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post

          Got a burning SEO question?

          Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


          Start my free trial


          Browse Questions

          Explore more categories

          • Moz Tools

            Chat with the community about the Moz tools.

          • SEO Tactics

            Discuss the SEO process with fellow marketers

          • Community

            Discuss industry events, jobs, and news!

          • Digital Marketing

            Chat about tactics outside of SEO

          • Research & Trends

            Dive into research and trends in the search industry.

          • Support

            Connect on product support and feature requests.

          • See all categories

          Related Questions

          • dklarse

            Are Expires Headers Detrimental to SEO Health?

            My dev was looking into Expires Headers to increase speed, but she don't know the ramifications behind them for SEO. What I found online is really old: https://moz.com/blog/expires-headers-for-seo-why-you-should-think-twice-before-using-them What do SEOs think? Thanks in advance! ~Dana

            Technical SEO | | dklarse
            0
          • lina_digital

            I am trying to generate GEO meta tag for my website where on one page there are multiple locations My question is, Can I add GEO tagging for every address?

            Am I restricted to 1 geo tag per page or can i add multiple geo tags ?

            Technical SEO | | lina_digital
            0
          • Taswirh

            Expired domain 404 crawl error

            I recently purchased a Expired domain from auction and after I started my new site on it, I am noticing 500+ "not found" errors in Google Webmaster Tools, which are generating from the previous owner's contents.Should I use a redirection plugin to redirect those non-exist posts to any new post(s) of my site? or I should use a 301 redirect? or I should leave them just as it is without taking further action? Please advise.

            Technical SEO | | Taswirh
            1
          • Ideas-Money-Art

            Why xml generator is not detecting all my urls?

            Hi Mozzers, After adding 3 new pages to example.com, when generating the xml sitemap,  Iwasn't able to locate those 3 new url. This is the first time it is happening. I have checked the meta tags of these pages and they are fine. No meta robots setup! Any thoughts or idea why this is happening? how to fix this? Thanks!

            Technical SEO | | Ideas-Money-Art
            0
          • mtthompsons

            Forum profile section or signature line as backlink

            Hi, Forum profile section or signature line as backlink VS Answering a question and giving a related post URl as the answer is better? I have the above question on which would be better Would a signature or website name in the profile is valuable then a link to your site where information is available? Does Google consider both as spam/blackhat? Thanks

            Technical SEO | | mtthompsons
            0
          • MeMediaSEO

            Google Impressions Drop Due to Expired SSL

            Recently I noticed a huge drop in our clients Google Impressions via GWMT from 900 impressions to 70 overnight on October 30, 2012 and has remained this way for the entire month of November 2012. The SSL Cert had expired in mid October due to the notification message for renewal going to the SPAM folder and being missed. Is it possible for an SSL expiry to be related to this massive drop in daily impressions which in-turn has also effected traffic? I also can't see any evidence of duplicate pages (ie. https and http) being indexed but to be honest I'm not the one doing the SEO therefore haven't been tracking this. Thanks for your help! Chris

            Technical SEO | | MeMediaSEO
            0
          • Donaab

            How best to redirect URL from expired classified ads?

            We have problem because our content are classifieds. Every ad expired after one or two mounts and then ad becomes inactive and we keep his page for one mount latter like a same page but we ad a notice that ad is inactive. After that we delete the ad and his page but need to redirect that URL to search results page which contains similar ads because we don't want to lose the traffic form that pages. How is the best way to redirect ad URL? Our thinking was to redirect internal without 301 redirection because the httacces file will be very big after a while  and we are thinking to try a canonicalization because we don't want engine to think that we have to much duplicate content.

            Technical SEO | | Donaab
            0
          • SEOPractices

            Best Dynamic Sitemap Generator

            Hello Mozers, Could you please share the best Dynamic Sitemap Generator you are using.  I have found this place: http://www.seotools.kreationstudio.com/xml-sitemap-generator/free_dynamic_xml_sitemap_generator.php Thanks in advanced for your help.

            Technical SEO | | SEOPractices
            0

          Get started with Moz Pro!

          Unlock the power of advanced SEO tools and data-driven insights.

          Start my free trial
          Products
          • Moz Pro
          • Moz Local
          • Moz API
          • Moz Data
          • STAT
          • Product Updates
          Moz Solutions
          • SMB Solutions
          • Agency Solutions
          • Enterprise Solutions
          Free SEO Tools
          • Domain Authority Checker
          • Link Explorer
          • Keyword Explorer
          • Competitive Research
          • Brand Authority Checker
          • MozBar Extension
          • MozCast
          Resources
          • Blog
          • SEO Learning Center
          • Help Hub
          • Beginner's Guide to SEO
          • How-to Guides
          • Moz Academy
          • API Docs
          About Moz
          • About
          • Team
          • Careers
          • Contact
          Why Moz
          • Case Studies
          • Testimonials
          Get Involved
          • Become an Affiliate
          • MozCon
          • Webinars
          • Practical Marketer Series
          • MozPod
          Connect with us

          Contact the Help team

          Join our newsletter
          Moz logo
          © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
          • Accessibility
          • Terms of Use
          • Privacy

          Looks like your connection to Moz was lost, please wait while we try to reconnect.