File autofirma.spec of Package autofirma

#
# spec file for package autofirma
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2020 Antonio Larrosa <alarrosa@suse.com>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           autofirma
Version:        1.8.3
Release:        0
Summary:        Cliente @firma
License:        GPL-2.0-only AND EUPL-1.1
Group:          Development/Libraries/Java
URL:            https://administracionelectronica.gob.es/ctt/clienteafirma
Source0:        %{name}-%{version}.tar.xz
Source2:        afirma.desktop
Source3:        afirma-standalone.desktop
Source4:        check-autofirma-certificate.py
Source5:        autofirma.sh
Patch0:         fix-convertSpec-call.patch
Patch1:         fix-provider.patch
Patch2:         fix-DERIA5String-deprecation.patch
#Patch3:         consider-java-17-supported.patch
BuildRequires:  dos2unix
BuildRequires:  ca-certificates
BuildRequires:  ca-certificates-mozilla
BuildRequires:  hicolor-icon-theme
BuildRequires:  java-devel >= 1.8
BuildRequires:  maven-local
BuildRequires:  mvn(axis:axis)
BuildRequires:  mvn(axis:axis-ant)
BuildRequires:  mvn(com.dmurph:JGoogleAnalyticsTracker)
BuildRequires:  mvn(org.bidib.com.github.markusbernhardt:proxy-vole)
BuildRequires:  mvn(com.io7m.xom:xom)
BuildRequires:  mvn(com.twelvemonkeys.imageio:imageio-jpeg)
BuildRequires:  mvn(es.gob.afirma.jmulticard:jmulticard)
BuildRequires:  mvn(es.gob.afirma.jmulticard:jmulticard-jse)
BuildRequires:  mvn(es.gob.afirma.jmulticard:jmulticard-ui)
BuildRequires:  mvn(es.gob.afirma.lib:afirma-lib-itext) >= 1.4
BuildRequires:  mvn(es.gob.afirma.lib:afirma-lib-jmimemagic)
BuildRequires:  mvn(es.gob.afirma.lib:afirma-lib-juniversalchardet)
BuildRequires:  mvn(es.gob.afirma.lib:afirma-lib-oro)
BuildRequires:  mvn(es.uji.crypto.xades:jxades)
BuildRequires:  mvn(javax.help:javahelp)
BuildRequires:  mvn(javax.json:javax.json-api)
BuildRequires:  mvn(org.json:json)
BuildRequires:  mvn(javax.servlet:javax.servlet-api)
BuildRequires:  mvn(javax.servlet:servlet-api)
BuildRequires:  mvn(net.java.dev.jna:jna)
BuildRequires:  mvn(org.apache.maven.plugins:maven-jarsigner-plugin)
BuildRequires:  mvn(org.apache.maven.plugins:maven-shade-plugin)
BuildRequires:  mvn(org.apache.maven.plugins:maven-war-plugin)
BuildRequires:  mvn(org.apache.pdfbox:pdfbox)
BuildRequires:  mvn(org.apache.santuario:xmlsec)
BuildRequires:  mvn(org.bouncycastle:bcpkix-jdk15on)
BuildRequires:  mvn(org.bouncycastle:bcprov-jdk15on)
BuildRequires:  mvn(org.bouncycastle:bcutil-jdk15) 
BuildRequires:  mvn(org.glassfish:javax.json)
BuildRequires:  mvn(org.java-websocket:Java-WebSocket)
BuildRequires:  mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires:  mvn(wss4j:wss4j)
BuildRequires:  update-desktop-files
BuildRequires:  xz
Requires:       bash
Requires:       ca-certificates
Requires:       java
Requires:       mozilla-nss-tools
Requires:       openssl
Requires:       python3
Requires(post): java
Suggests:       MozillaFirefox
Provides:       clienteafirma = %{version}
BuildArch:      noarch
%if 0%{?suse_version} >= 1500
Requires:       (python3-gobject-Gdk or python3-qt5)
%else
Recommends:     python3-gobject-Gdk
Recommends:     python3-qt5
%endif

%description
Autofirma is an application developed by the Ministry of Finance and Public Administration
of Spain to implement document signing for the spanish administration.

%prep
%setup -q

%pom_remove_dep -f com.madgag.spongycastle:core pom.xml */pom.xml */*/pom.xml
%pom_change_dep -f com.madgag.spongycastle:bcpkix-jdk15on org.bouncycastle: pom.xml */pom.xml */*/pom.xml
%pom_change_dep -f com.madgag.spongycastle:prov org.bouncycastle:bcprov-jdk15on pom.xml */pom.xml */*/pom.xml
%pom_change_dep -f com.github.markusbernhardt:proxy-vole org.bidib.com.github.markusbernhardt:proxy-vole pom.xml */pom.xml */*/pom.xml
%pom_add_dep  org.bouncycastle:bcutil-jdk15on afirma-crypto-core-pkcs7/pom.xml
%pom_add_dep  org.bouncycastle:bcutil-jdk15on afirma-crypto-validation/pom.xml afirma-simple/pom.xml
%pom_remove_dep  axis:axis-schema afirma-crypto-pdf-enhancer/pom.xml

find . -iname *.java -exec sed -ie "s/org\.spongycastle\./org.bouncycastle./g" "{}" \;
find . -iname *.java -exec sed -ie "s/\.getObject()/.getBaseObject()/g" "{}" \;

%patch -P 0 -p1
%patch -P 1 -p1
%patch -P 2 -p1

%pom_xpath_set "pom:project/pom:properties/pom:jdk.version" "1.8"

%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:source" "1.8" \
    afirma-server-simple-webstart \
    afirma-signature-retriever \
    afirma-signature-storage \
    afirma-standalone/afirma-ui-standalone
%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:target" "1.8" \
    afirma-server-simple-webstart \
    afirma-signature-retriever \
    afirma-signature-storage \
    afirma-standalone/afirma-ui-standalone

%build
%{mvn_build} -f -- \
    -Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
    -Penv-dev,env-install -Denv=install -Dsource=8

%install
export NO_BRP_CHECK_BYTECODE_VERSION=true
mkdir -p %{buildroot}%{_javadir}/autofirma

cp -a */target/*.jar %{buildroot}%{_javadir}/autofirma/

# Added manually
cp -a afirma-standalone-installer/Afirma_Standalone.jar %{buildroot}%{_javadir}/autofirma/Afirma_Standalone.jar
#mkdir -p %%{buildroot}%%{_libdir}/firefox/browser/defaults/preferences
#cp -a afirma-simple/src/main/resources/linux/AutoFirma.js %%{buildroot}%%{_libdir}/firefox/browser/defaults/preferences/autofirma.js

for size in 16 32 64 ; do
  mkdir -p %{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps
  cp afirma-ui-miniapplet-deploy/src/main/webapp/logo${size}.png %{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps/autofirma.png
done

#%%if !0%%{?is_opensuse}
#perl -pi -e "s,/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java,java," %%{S:2}
#perl -pi -e "s,/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java,java," %%{S:3}
#%%endif

cp %{SOURCE4} %{buildroot}%{_javadir}/autofirma/
mkdir %{buildroot}%{_bindir}
cp %{SOURCE5} %{buildroot}%{_bindir}/autofirma
chmod +x %{buildroot}%{_javadir}/autofirma/check-autofirma-certificate.py %{buildroot}%{_bindir}/autofirma

%suse_update_desktop_file -i afirma Office Viewer System Security
%suse_update_desktop_file -i afirma-standalone Office Viewer System Security

%post
java -Djava.awt.headless=true -jar %{_datadir}/java/autofirma/AutoFirmaConfigurador.jar -install
# The following commands are now done by check-autofirma-certificate.py in a per-user basis
#echo ""
#echo "##############################################################################################"
#echo "Don't forget to import the /usr/share/java/autofirma/AutoFirma_ROOT.cer certificate to Firefox"
#echo "You can go to Preferences / View Certificates and click on Import..."
#echo "Or alternatively, you can use something like the following commands:"
#echo ""
#echo 'certutil -A -d sql:/home/$USER/.pki/nssdb -n "AutoFirma ROOT" -i /usr/share/java/autofirma/AutoFirma_ROOT.cer -t "TCP,TCP,TCP"'
#echo 'certutil -A -d sql:/home/$USER/.mozilla/firefox/*.default -i /usr/share/java/autofirma/AutoFirma_ROOT.cer -n "AutoFirma ROOT" -t "C,,"'

%files
%license afirma-simple/src/main/resources/help/Spanish.lproj/pgs/Licencia.html
%{_javadir}/autofirma
%{_datadir}/applications/afirma.desktop
%{_datadir}/applications/afirma-standalone.desktop
%{_datadir}/icons/hicolor/*/apps/autofirma.png
%{_bindir}/autofirma
%ghost %{_javadir}/autofirma/autofirma.pfx
%ghost %{_javadir}/autofirma/AutoFirma_ROOT.cert
%ghost %{_javadir}/autofirma/script.sh
%ghost %{_javadir}/autofirma/uninstall.sh

%changelog
openSUSE Build Service is sponsored by