/** * Constructs a TransportToken using the given transport string. The transport string that is * given may be either be a plain text string, an encrypted string, or a URL encoded encrypted * string. * * @param transportString the transport string to be used to initialize this instance of transport * token. * @throws AgentException in case of any unexpected failure in initialization. */ public TransportToken(String transportString) throws AgentException { if ((transportString == null) || (transportString.trim().length() == 0)) { throw new AgentException("Invalid transport string"); } String innerTransportString = transportString; if (transportString.startsWith(ENC_CRYPT_PREFIX)) { transportString = URLDecoder.decode(transportString); } if (transportString.startsWith(CRYPT_PREFIX)) { ICrypt crypt = ServiceFactory.getCryptProvider(); String randomCryptString = crypt.decrypt(transportString.substring(CRYPT_PREFIX.length())); int index = randomCryptString.indexOf(":") + 1; innerTransportString = randomCryptString.substring(index); } initializeFromString(innerTransportString); }
public String getEncryptedTransportString() throws AgentException { ICrypt crypt = ServiceFactory.getCryptProvider(); return CRYPT_PREFIX + crypt.encrypt(String.valueOf(System.currentTimeMillis()) + ":" + getTransportString()); }