Skip to content

Instantly share code, notes, and snippets.

@Anakin-Hao
Created December 11, 2018 00:55
Show Gist options
  • Save Anakin-Hao/66401c7eaaa6eafb3fc8ad803a099597 to your computer and use it in GitHub Desktop.
Save Anakin-Hao/66401c7eaaa6eafb3fc8ad803a099597 to your computer and use it in GitHub Desktop.
xmlstarlet to added apache mssl spi in keycloak xml
# set alias xl='xmlstarlet'
xl ed -L -u '//spi[@name="x509cert-lookup"]/default-provider' -v "apache" test.xml
xl ed -L -u '//spi[@name="x509cert-lookup"]/provider[@name="default"]/@name' -v "apache" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]' -t elem -n "properties" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties' -t elem -n "property" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "name" -v "sslClientCert" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "value" -v "ssl-client-cert" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties' -t elem -n "property" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "name" -v "sslCertChainPrefix" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "value" -v "USELESS" test.xml
xl ed -L -s '//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties' -t elem -n "property" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "name" -v "certificateChainLength" test.xml
xl ed -L -i '(//spi[@name="x509cert-lookup"]/provider[@name="apache"]/properties/property)[last()]' -t attr -n "value" -v "0" test.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment