Search in sources :

Example 1 with IHostKeyBL

use of de.metas.hostkey.api.IHostKeyBL in project metasfresh-webui-api by metasfresh.

the class HostKeyConfig method setupHostKeyStorage.

@PostConstruct
public void setupHostKeyStorage() {
    Services.registerService(IHttpSessionProvider.class, new SpringHttpSessionProvider());
    final IHostKeyBL hostKeyBL = Services.get(IHostKeyBL.class);
    // when this method is called, there is not DB connection yet.
    // so provide the storage implementation as a supplier when it's actually needed and when (hopefully)
    // the system is ready
    hostKeyBL.setHostKeyStorage(() -> {
        final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class);
        final IHostKeyStorage hostKeyStorageImpl;
        final String hostKeyStorage = sysConfigBL.getValue(PRINTING_WEBUI_HOST_KEY_STORAGE_MODE, "cookies");
        if (hostKeyStorage.toLowerCase().startsWith("cookie".toLowerCase())) {
            hostKeyStorageImpl = new HttpCookieHostKeyStorage();
        } else {
            // https://github.com/metasfresh/metasfresh/issues/1274
            hostKeyStorageImpl = new SessionRemoteHostStorage();
        }
        return hostKeyStorageImpl;
    });
}
Also used : SessionRemoteHostStorage(de.metas.hostkey.spi.impl.SessionRemoteHostStorage) IHostKeyStorage(de.metas.hostkey.spi.IHostKeyStorage) ISysConfigBL(org.adempiere.service.ISysConfigBL) HttpCookieHostKeyStorage(de.metas.hostkey.spi.impl.HttpCookieHostKeyStorage) IHostKeyBL(de.metas.hostkey.api.IHostKeyBL) PostConstruct(javax.annotation.PostConstruct)

Aggregations

IHostKeyBL (de.metas.hostkey.api.IHostKeyBL)1 IHostKeyStorage (de.metas.hostkey.spi.IHostKeyStorage)1 HttpCookieHostKeyStorage (de.metas.hostkey.spi.impl.HttpCookieHostKeyStorage)1 SessionRemoteHostStorage (de.metas.hostkey.spi.impl.SessionRemoteHostStorage)1 PostConstruct (javax.annotation.PostConstruct)1 ISysConfigBL (org.adempiere.service.ISysConfigBL)1