
org.jsmart.zerocode.zerocodejavaexec.utils.TokenGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-testing Show documentation
Show all versions of http-testing Show documentation
How to use zerocode in your project
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