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

com.jeesuite.security.SecurityTicketManager Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.jeesuite.security;

import com.jeesuite.common.util.TokenGenerator;
import com.jeesuite.security.SecurityConstants.CacheType;
import com.jeesuite.security.cache.LocalCache;
import com.jeesuite.security.cache.RedisCache;

public class SecurityTicketManager {

	private Cache cache;
	
	public SecurityTicketManager(SecurityDecisionProvider decisionProvider) {
	       if(CacheType.redis == decisionProvider.cacheType()){
	    	   this.cache = new RedisCache("security.ticket:", 180);
			}else{
				this.cache = new LocalCache(180);
			}
	}
	
	public String setTicketObject(Object ticketObject){
		String ticket = TokenGenerator.generate();
		cache.setObject(ticket, ticketObject);
		return ticket;
	}
	
	public  T getTicketObject(String ticket){
		return cache.getObject(ticket);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy