File jce.spec of Package jce_sun
Name: jce_sun
Version: 1.6.0
Release: %mkrel
License: http://www.oracle.com/technetwork/java/javase/terms/license/index.html
Summary: Java Cryptography Extension Unlimited for Sun JDK
Url: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html
Group: Java
Source0: jce_policy-6.zip
BuildRequires: jre-1.6.0-sun
BuildRequires: unzip
Provides: jce_sun_local_policy = %{version}
Provides: jce_sun_us_export_policy = %{version}
# Seems to be an issue due to JVM path, so noarch isn't an option
# BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# BuildRequires: java-sun <= 1.7.0 unzip
# Requires: java-sun <= 1.7.0
Requires(post): update-alternatives
Requires(postun): update-alternatives
%description
Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6.
Sun JDK and JRE come with limitation to respect US cryptography policy. Trying to
use long key will result in errors like "java.security.InvalidKeyException: Invalid
key length".
This package installs jars provided by Sun to get rid of those limitation.
%prep
%setup -q -n jce
%build
%install
mkdir -p %{buildroot}%{_javadir}/jce
cp *.jar %{buildroot}%{_javadir}/jce
%clean
rm -Rf %{buildroot}
%post
# Use unlimited local and US export policy
# See OBS Java:sun:Factory java-1_6_0-sun to see how the initial local_policy and US_export_policy are installed as alternatives
# Priority is set to 1699 as we want to stay over default jce priority. It's actually 1617, I guess it'll stay 16XX to follow version number
if [ ! -e %{_libdir}/jvm/java-%{version}-sun-%{version}/jre/lib/security/local_policy.jar -o \
! -e %{_libdir}/jvm/java-%{version}-sun-%{version}/jre/lib/security/US_export_policy ]; then
update-alternatives --auto jce_%{version}_sun_local_policy
fi
update-alternatives \
--install \
%{_libdir}/jvm/java-%{version}-sun-%{version}/jre/lib/security/local_policy.jar \
jce_%{version}_sun_local_policy \
%{_javadir}/jce/local_policy.jar \
1699 \
--slave \
%{_libdir}/jvm/java-%{version}-sun-%{version}/jre/lib/security/US_export_policy.jar \
jce_%{version}_sun_us_export_policy \
%{_javadir}/jce/US_export_policy.jar || true
# update-alternatives --set jce_%{version}_sun_local_policy %{_javadir}/jce/local_policy.jar
%postun
# Remove unlimited local policy
update-alternatives --remove jce_%{version}_sun_local_policy %{_javadir}/jce/local_policy.jar
# Remove unlimited US export policy
# update-alternatives --remove jce_%{version}_sun_us_export_policy %{_javadir}/jce/US_export_policy.jar
%files
%defattr(-,root,root)
%doc README.txt COPYRIGHT.html
%{_javadir}/jce
%changelog