All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsmart.zerocode.zerocodejavaexec.utils.TokenGenerator Maven / Gradle / Ivy

The newest version!
package org.jsmart.zerocode.zerocodejavaexec.utils;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

public class TokenGenerator {

    public Map generateNew(String anyParam){
        Map tokenMap = new HashMap<>();

        // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        //          Your token generation logic goes here.
        // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        // You need to put a valid implementation for this token.
        // For time being it's unique here as current time-stamp.
        // The key "token" here is just for demo purpose.
        // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        String uniqueToken = tokenFromCurrentTimeStamp();

        // ------------------------------------
        // Now put this token into a map key
        //  - Choose any key name e.g. newToken
        // ------------------------------------
        tokenMap.put("newToken", uniqueToken);

        return tokenMap;
    }

    private String tokenFromCurrentTimeStamp() {
        return LocalDateTime.now().toString()
                    .replace(":", "-")
                    .replace(".", "-");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy