This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | |
| import com.google.api.client.json.JsonFactory; | |
| import com.google.api.client.json.jackson2.JacksonFactory; | |
| import com.google.api.services.drive.Drive; | |
| import com.google.api.services.forms.v1.Forms; | |
| import java.io.IOException; | |
| import java.security.GeneralSecurityException; | |
| public class Boilerplate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @AutoConfigureAfter(RedisAutoConfiguration.class) | |
| public class CacheConfig { | |
| public final static String BLACKLIST_CACHE_NAME = "jwt-black-list"; | |
| @Value("${jwt.duration:0}") | |
| private int tokenDuration; | |
| @Value("${spring.redis.host:localhost}") | |
| private String redisHost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Service | |
| public class BlackListingService { | |
| @CachePut(CacheConfig.BLACKLIST_CACHE_NAME) | |
| public String blackListJwt(String jwt) { | |
| return jwt; | |
| } | |
| @Cacheable(value = CacheConfig.BLACKLIST_CACHE_NAME, unless = "#result == null") | |
| public String getJwtBlackList(String jwt) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RestController | |
| @RequestMapping("/logout") | |
| public class LogoutController { | |
| @Autowired | |
| private BlackListingService blackListingService; | |
| @Autowired | |
| private UserRequestScopedBean userRequestScopedBean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class JWTInterceptor implements HandlerInterceptor { | |
| @Value("${jwt.key}") | |
| private String jwtKey; | |
| @Autowired | |
| private BlackListingService blackListingService; | |
| @Autowired | |
| private UserRequestScopedBean userRequestScopedBean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Resurrected { | |
| private static final Set<Resurrected> resurrected = new HashSet<>(); | |
| @Override | |
| protected void finalize() throws Throwable { | |
| resurrected.add(this); // Resurrect the object by creating a new reference | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| protected void finalize() throws Throwable { | |
| // closing resources here.... | |
| super.finalize(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FileInputStream input = null; | |
| try { | |
| input = new FileInputStream(file1); | |
| input.close(); input = null; | |
| } finally { | |
| if (input != null) input.close(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sessionStorage.setItem('pets', '{"pets":{"fido":{"species":"dog"}}}'); | |
| const store = createStore(); | |
| const persister = createSessionPersister(store, 'pets'); | |
| await persister.load(); | |
| console.log(store.getTables()); | |
| // -> {pets: {fido: {species: 'dog'}}} | |
| sessionStorage.clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const store = createStore().setTable('pets', { | |
| fido: {species: 'dog'}, | |
| felix: {species: 'cat'}, | |
| cujo: {species: 'dog'}, | |
| }); | |
| const indexes = createIndexes(store); | |
| indexes.setIndexDefinition( | |
| 'bySpecies', // indexId | |
| 'pets', // tableId to index | |
| 'species', // cellId to index |