вторник, 24 марта 2020 г.

Фикс ромбов в консоли на русских буквах, кракозябры, кириллица, консоль, CentOS

если не отображаются русские буквы в консоли Linux (CentOS):
yum localinstall http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/fedora/releases/19/Everything/x86_64/os/workaround-cyrillic-console-1.0-5.fc19.R.noarch.rpm

пример кириллического шрифта

воскресенье, 22 марта 2020 г.

Много оперативной памяти занято сразу после старта Windows 10

https://imacros.ru/raznoe/sluzhba-politiki-diagnostiki-windows-10.html
После отключения нескольких служб освобождается до 10Гб RAM.

  • Служба политики диагностики (Diagnostic Policy Service).
  • Вспомогательная служба IP (IP Helper) 
  • Модуль поддержки NetBIOS через TCP/IP (TCP/IP NetBIOS Helper)
  • Windows Search

пятница, 20 марта 2020 г.

Не пингуется хост из гостевой Hyper-V, нет интернета в гостевой машине Hyper-V, Windows 10

Виртуальная машина в Hyper-V, использующая Default switch, может лишаться сети из-за VPN-клиента на хосту. Как пишут, дефолт-свич может использовать настройки доступного ему DHCP-сервера, из-за чего по всей видимости могут прописаться не те роуты.
В общем, отключение VPN на момент настройки свича (возможно, при каждой загрузке винды это происходит) возвращает доступность сети и интернета в гостевой машине.

UPD
Это не решает проблему после перезагрузок, на данный момент рабочая схема с созданным внутренним hyper-v свичом с NATом, с которым делится интернетом вайфай-соединение (основное рабочее).

вторник, 3 марта 2020 г.

VirtualBox под Windows 10(host) проблемы с установкой Ubuntu, Debian, CentOS

Непонятные ошибки при установке, послеустановочном запуске.
Нужно отключить Hyper-V в панели управления - вкл/выкл компонентов Windows.

понедельник, 10 июня 2019 г.

MessageSource message.properties Spring i18n интернационализация сообщений




  • @Bean("messageSource")
    public ReloadableResourceBundleMessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();    messageSource.setBasename("classpath:messages/messages"); // любой путь к файлу    messageSource.setDefaultEncoding("UTF-8");    return messageSource;}
     
    // Ключевое - ReloadableRes.... - reloadable - поддержка любого пути. 
     
  •  
    @Componentpublic class Translator {
    
        private static MessageSource messageSource;
        @Autowired    Translator(MessageSource messageSource) {
            Translator.messageSource = messageSource;    }
    
        public static String toLocale(String msgCode, Object[] args) {
            Locale locale = LocaleContextHolder.getLocale();//        Locale tmp = new Locale("ru");        return messageSource.getMessage(msgCode, args, locale);    }
    }
  •  
    Translator.toLocale("respMsg.savedOK", null)
  •  messages_ru_RU.properties: 
    respMsg.savedOK=Сохранено
  •  

воскресенье, 24 июня 2018 г.

Spring MVC @PathVariable with encoded slashes, REST c прямыми слэшами в URL в значении переменной

Use case:
@RequestMapping("/path/{variableAbleCaptureSlashes:.+}
public ResponseEntity<String> method(@PathVariable("variableAbleCaptureSlashes") var) {
    // var must accept values like "/a/b/"
             // нужно, чтобы в var  могли падать значения с прямыми слэшами

}

Решение:
  • разрешить слэши в пути
    System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
  • отключить в UrlPathHelper url-декодирование 
    @Override    public void configurePathMatch(PathMatchConfigurer configurer) {
            UrlPathHelper urlPathHelper = new UrlPathHelperNonDecoding();        urlPathHelper.setUrlDecode(false);        configurer.setUrlPathHelper(urlPathHelper);    }
  • подставить кастомную имплементацию UrlPathHelper (https://jira.spring.io/browse/SPR-11101)
  • разрешить любые символы в значении pathvariable: @RequestMapping("/path/{variableAbleCaptureSlashes:.+}


@SpringBootApplication
@EnableErrorHandlingpublic class Application extends WebMvcConfigurerAdapter {
    public static void main(String[] args) {
        System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");        SpringApplication.run(Application.class, args);    }

    @Override    public void configurePathMatch(PathMatchConfigurer configurer) {
        UrlPathHelper urlPathHelper = new UrlPathHelperNonDecoding();        urlPathHelper.setUrlDecode(false);        configurer.setUrlPathHelper(urlPathHelper);    }

    public class UrlPathHelperNonDecoding extends UrlPathHelper {

        public UrlPathHelperNonDecoding() {
            super.setUrlDecode(false);        }

        @Override        public void setUrlDecode(boolean urlDecode) {
            if (urlDecode) {
                throw new IllegalArgumentException("Handler does not support URL decoding.");            }
        }

        @Override        public String getServletPath(HttpServletRequest request) {
            String servletPath = getOriginatingServletPath(request);            return servletPath;        }


        @Override        public String getOriginatingServletPath(HttpServletRequest request) {
            String servletPath = request.getRequestURI().substring(request.getContextPath().length());            return servletPath;        }
    }
}

пятница, 8 декабря 2017 г.

Настройка NTLM и Basic аутентификации JAX-WS клиента в конфигурационном файле Spring

AllowChunking="false" в элементе http-conf:conduit/http-conf:client активизирует аутентификацию NTLM, если не указывать ее тип в http-conf:authorization . Без этой установки будет применяться аутентификация Basic.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns="http://www.springframework.org/schema/beans"
       xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/transports/http/configuration
        http://cxf.apache.org/schemas/configuration/http-conf.xsd">

    <beans>

        <!-- Setting AllowChunking="false" activates NTLM authentication.
        Basic authentication will be used without it -->
        <http-conf:conduit name="*.http-conduit"
            xmlns:sec="http://cxf.apache.org/configuration/security"
            xmlns="http://cxf.apache.org/transports/http/configuration">
            <http-conf:client
                    ConnectionTimeout="1000"
                    ReceiveTimeout="10000"
                    AllowChunking="false" />
            <http-conf:authorization>
                <sec:UserName>${auth.username}</sec:UserName>
                <sec:Password>${auth.password}</sec:Password>
            </http-conf:authorization>
        </http-conf:conduit>

        <!--WS Clients-->
        <jaxws:client id="ws-client-id"
                      serviceClass="com.microsoft.schemas.sharepoint.soap.XXXX"
                      address="${endpoints.someaddress}">
        </jaxws:client>

    </beans>

</beans>

Из доков CXF:

Finally, you need to setup the CXF client to turn off chunking. The reason is that the NTLM authentication requires a 3 part handshake which breaks the streaming.

//Turn off chunking so that NTLM can occur
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
http.setClient(httpClientPolicy);