Skip to content
Commits on Source (100)
......@@ -3,5 +3,8 @@
<classpathentry excluding="samples/" kind="src" path=""/>
<classpathentry kind="src" path="samples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/share/java/slf4j/slf4j-api.jar"/>
<classpathentry kind="lib" path="/usr/share/java/commons-lang.jar"/>
<classpathentry kind="lib" path="/usr/share/java/commons-codec.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
# BEGIN COPYRIGHT BLOCK
# (C) 2018 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
services:
- docker
env:
- FEDORA=27
- FEDORA=28
install:
- docker pull registry.fedoraproject.org/fedora:$FEDORA
- docker run
--name=container
--detach
-i
-v $(pwd):/root/jss
registry.fedoraproject.org/fedora:$FEDORA
- docker exec container dnf install -y dnf-plugins-core gcc make rpm-build
- docker exec container dnf copr -y enable @pki/10.6
- docker exec container dnf builddep -y --spec /root/jss/jss.spec.in
- docker exec container /root/jss/build.sh --with-timestamp --with-commit-id rpm
script:
- docker exec container rpm -Uvh /root/build/jss/RPMS/*
============================================
|| Upstream JSS Build/Test Instructions ||
============================================
(1) Prepare a work area
(a) For upstream builds which checkout and utilize
the current NSPR and NSS source repositories:
# mkdir sandbox
# cd sandbox
# hg clone https://hg.mozilla.org/projects/nspr
# hg clone https://hg.mozilla.org/projects/nss
# git clone git@github.com:dogtagpki/jss.git
# cd ..
(There is no need to clone every time. For additional builds,
simply use:
cd nspr; hg pull -u -v; cd ..; cd nss; hg pull -u -v; cd ..;
cd jss; hg pull -u -v; cd ..
)
(b) Alternatively, for upstream builds which use
the NSPR and NSS installed on the system:
# mkdir sandbox
# cd sandbox
# export USE_INSTALLED_NSPR=1
# export USE_INSTALLED_NSS=1
# export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
# export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
# export NSPR_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nspr | sed 's/-I//'`
# export NSPR_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nspr | sed 's/-L//'`
# export NSS_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nss | sed 's/-I//'`
# export NSS_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nss | sed 's/-L//'`
# export XCFLAGS="-g"
# hg clone https://hg.mozilla.org/projects/jss
# cd ..
(There is no need to clone every time. For additional builds,
simply use:
cd jss; hg pull -u -v; cd ..
)
(2) Prepare an interactive shell for building:
# export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
# export USE_64=1
NOTE: JSS will now attempt to verify whether or not these two
environment variables have been set (JAVA_HOME is mandatory;
USE_64 is mandatory on 64-bit platforms when building 64-bit).
The following steps are optional, and left to the discretion of the user:
Debug vs. Optimized jar files:
By default, JSS will be built as a debuggable jar
(xpclass_dbg.jar - generally recommended for test builds);
to create an optimized jar (xpclass.jar), set the following
environment variable:
# export BUILD_OPT=1
Beta vs. Non-Beta builds:
Finally, by default, JSS is not built as a "beta" release (as
specified in 'org/mozilla/jss/util/jssver.h'):
#define JSS_BETA PR_FALSE
If a "beta" version of JSS is desired, reset this #define (as
specified in 'org/mozilla/jss/util/jssver.h') to:
#define JSS_BETA PR_TRUE
(3) Build JSS
# cd sandbox/jss
# make clean all
# cd ../..
(or you can run "# script -c 'make clean all' typescript.build")
NOTE: When build method (1)(a) is being utilized, if nss has not been
built, it will now automatically be built before jss; if nss has
already been built, only jss will be built/re-built.
(4) Install JSS on the System (Optional)
If JSS already exists on the system, run something similar to the
following command(s):
# sudo mv /usr/lib/java/jss4.jar /usr/lib/java/jss4.jar.orig
If the platform is 32-bit Linux:
# sudo mv /usr/lib/jss/libjss4.so /usr/lib/jss/libjss4.so.orig
else if the platform is 64-bit Linux:
# sudo mv /usr/lib64/jss/libjss4.so /usr/lib64/jss/libjss4.so.orig
If BUILD_OPT is undefined (default Debuggable Jar):
# sudo cp sandbox/dist/xpclass_dbg.jar /usr/lib/java/jss4.jar
else if BUILD_OPT is defined (Optimized Jar):
# sudo cp sandbox/dist/xpclass.jar /usr/lib/java/jss4.jar
# sudo chown root:root /usr/lib/java/jss4.jar
# sudo chmod 644 /usr/lib/java/jss4.jar
# sudo cp sandbox/jss/lib/Linux*.OBJ/libjss4.so /usr/lib64/jss/libjss4.so
# sudo chown root:root /usr/lib64/jss/libjss4.so
# sudo chmod 755 /usr/lib64/jss/libjss4.so
(5) Run JSS Tests (Optional, but only if build method (1)(a) was utilized)
If build method (1)(a) is being utilized, it is possible to run the
built-in JSS tests:
# cd sandbox/jss
# make test_jss
# cd ../..
(or you can run "# script -c 'make test_jss' typescript.tests")
NOTE: This command is currently only available on Linux and Macintosh
platforms when method (1)(a) has been utilized to build JSS
since the tests are dependent upon the work area as setup in
this method; currenty JSS must be built via 'make clean all' before
execution of this command (e.g. - build is separate from test).
(6) Restoration of non-Test-Only Systems (Optional)
If step (4) above was run, and the system is being used for purposes
other than test, the user may wish to restore the original system JSS
by running the following commands:
# sudo mv /usr/lib/java/jss4.jar.orig /usr/lib/java/jss4.jar
If the platform is 32-bit Linux:
# sudo mv /usr/lib/jss/libjss4.so.orig /usr/lib/jss/libjss4.so
else if the platform is 64-bit Linux:
# sudo mv /usr/lib64/jss/libjss4.so.orig /usr/lib64/jss/libjss4.so
NOTE: For this procedure, no ownership or permission changes should
be necessary.
(7) Tagging the Source Code for a Release
During development, several releases may be made. Consequently, it is
good practice to create a "regular tag" to the source code at these
various points in time using the following format:
# hg tag -m "message" JSS_<major>_<minor>_YYYYMMDD
where: <major> = JSS Major Version Number
<minor> = JSS Minor Version Number
YYYY = 4-digit year (e. g. - 2017)
MM = 2-digit month (e. g. - 01, ..., 12)
DD = 2-digit day of the month (e. g. - 01, ..., 31)
For example:
# hg id
b3e864205ff0+ tip
# hg tag -m "Added tag JSS_4_4_20170328 for changeset b3e864205ff0" JSS_4_4_20170328
At the appropriate time, a new major.minor version may be created. At this
time, it is important to create a maintenance branch for any future changes
to the previous major.minor version:
For example:
# hg id
f00f00f00f00+ tip
# hg branch -m "Created branch JSS_4_4_BRANCH for changeset f00f00f00f00" JSS_4_4_BRANCH
(8) Known Issues
* Mozilla Bug #1346410 - Load JSS libraries appropriately
NOTE: This issue should not occur unless step (4) above was skipped.
Testing failures were found while working on Bug 1346410 when loading the
JSS libraries to meet requirements of certain operating systems. Our
investigation revealed that due to the nature of the changes made via this
patch and its interaction with the HMAC Tests (both non-FIPS and FIPS),
that a failure may be encountered on one or more of the HMAC algorithms
causing these two tests to fail. On 64-bit Linux, for example, the
workaround for this issue is to perform the following steps before
re-running the tests:
(a) Install the new JSS builds by executing step (4) above
(b) Execute the following commands:
# cd sandbox/jss; make test_jss
NOTE: If the system is being used for purposes other than test, the user
may wish to restore the original JSS by executing step (6) above.
Network Security Services for Java (JSS)
========================================
Overview
--------
**Network Security Services for Java** is a Java interface to [NSS](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS).
JSS supports most of the security standards and encryption technologies supported by NSS.
JSS also provides a pure Java interface for ASN.1 types and BER/DER encoding.
* Website: http://www.dogtagpki.org/wiki/JSS
* Issues: https://pagure.io/jss/issues
Build/Test Instructions
-----------------------
### 1. Prepare a work area
(a) For upstream builds which checkout and utilize
the current NSPR and NSS source repositories:
```
# mkdir sandbox
# cd sandbox
# hg clone https://hg.mozilla.org/projects/nspr
# hg clone https://hg.mozilla.org/projects/nss
# git clone git@github.com:dogtagpki/jss.git
# cd ..
```
There is no need to clone every time. For additional builds,
simply use:
```
# cd nspr
# hg pull -u -v
# cd ..
# cd nss
# hg pull -u -v
# cd ..
# cd jss
# git pull -v
# cd ..
````
(b) Alternatively, for upstream builds which use
the NSPR and NSS installed on the system:
```
# mkdir sandbox
# cd sandbox
# export USE_INSTALLED_NSPR=1
# export USE_INSTALLED_NSS=1
# export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
# export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
# export NSPR_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nspr | sed 's/-I//'`
# export NSPR_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nspr | sed 's/-L//'`
# export NSS_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nss | sed 's/-I//'`
# export NSS_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nss | sed 's/-L//'`
# export XCFLAGS="-g"
# hg clone https://hg.mozilla.org/projects/jss
# cd ..
```
There is no need to clone every time. For additional builds,
simply use:
```
# cd jss
# git pull -v
# cd ..
```
### 2. Prepare an interactive shell for building
```
# export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
# export USE_64=1
```
NOTE: JSS will now attempt to verify whether or not these two
environment variables have been set (JAVA_HOME is mandatory;
USE_64 is mandatory on 64-bit platforms when building 64-bit).
The following steps are optional, and left to the discretion of the user:
#### Normal vs. Optimized builds
By default, JSS will be built as a normal binaries.
To create an optimized build, set the following
environment variable:
```
# export BUILD_OPT=1
```
#### Beta vs. Non-Beta builds
Finally, by default, JSS is not built as a "beta" release (as
specified in 'org/mozilla/jss/util/jssver.h'):
```
#define JSS_BETA PR_FALSE
```
If a "beta" version of JSS is desired, reset this #define (as
specified in 'org/mozilla/jss/util/jssver.h') to:
```
#define JSS_BETA PR_TRUE
```
### 3. Build JSS
To build JSS, execute the following commands:
```
# cd sandbox/jss
# make clean all
# cd ../..
```
or you can run:
```
# script -c 'make clean all' typescript.build
```
NOTE: When build method (1)(a) is being utilized, if nss has not been
built, it will now automatically be built before jss; if nss has
already been built, only jss will be built/re-built.
### 4. Install JSS on the System (Optional)
If JSS already exists on the system, run something similar to the
following command(s):
```
# sudo mv /usr/lib/java/jss4.jar /usr/lib/java/jss4.jar.orig
```
If the platform is 32-bit Linux:
```
# sudo mv /usr/lib/jss/libjss4.so /usr/lib/jss/libjss4.so.orig
```
else if the platform is 64-bit Linux:
```
# sudo mv /usr/lib64/jss/libjss4.so /usr/lib64/jss/libjss4.so.orig
```
Then install the new JSS binaries:
```
# sudo cp sandbox/dist/xpclass.jar /usr/lib/java/jss4.jar
# sudo chown root:root /usr/lib/java/jss4.jar
# sudo chmod 644 /usr/lib/java/jss4.jar
# sudo cp sandbox/jss/lib/Linux*.OBJ/libjss4.so /usr/lib64/jss/libjss4.so
# sudo chown root:root /usr/lib64/jss/libjss4.so
# sudo chmod 755 /usr/lib64/jss/libjss4.so
```
### 5. Run JSS Tests (Optional, but only if build method (1)(a) was utilized)
If build method (1)(a) is being utilized, it is possible to run the built-in JSS tests:
```
# cd sandbox/jss
# make test_jss
# cd ../..
```
or you can run:
```
# script -c 'make test_jss' typescript.tests
```
NOTE: This command is currently only available on Linux and Macintosh
platforms when method (1)(a) has been utilized to build JSS
since the tests are dependent upon the work area as setup in
this method; currenty JSS must be built via 'make clean all' before
execution of this command (e.g. - build is separate from test).
### 6. Restoration of non-Test-Only Systems (Optional)
If step (4) above was run, and the system is being used for purposes
other than test, the user may wish to restore the original system JSS
by running the following commands:
```
# sudo mv /usr/lib/java/jss4.jar.orig /usr/lib/java/jss4.jar
```
If the platform is 32-bit Linux:
```
# sudo mv /usr/lib/jss/libjss4.so.orig /usr/lib/jss/libjss4.so
```
else if the platform is 64-bit Linux:
```
# sudo mv /usr/lib64/jss/libjss4.so.orig /usr/lib64/jss/libjss4.so
```
NOTE: For this procedure, no ownership or permission changes should
be necessary.
### 7. Tagging the Source Code for a Release
During development, several releases may be made. Consequently, it is
good practice to create a "regular tag" to the source code at these
various points in time using the following format:
```
# git tag -m "message" JSS_<major>_<minor>_<YYYYMMDD>
```
where:
* major = JSS Major Version Number
* minor = JSS Minor Version Number
* YYYY = 4-digit year (e. g. - 2017)
* MM = 2-digit month (e. g. - 01, ..., 12)
* DD = 2-digit day of the month (e. g. - 01, ..., 31)
For example:
```
# git rev-parse HEAD
b3e864205ff0...
# git tag -m "Added tag JSS_4_4_20170328 for changeset b3e864205ff0" JSS_4_4_20170328
```
At the appropriate time, a new major.minor version may be created. At this
time, it is important to create a maintenance branch for any future changes
to the previous major.minor version:
For example:
```
# git rev-parse HEAD
f00f00f00f00...
# git checkout -b JSS_4_4_BRANCH
```
### 8. Known Issues
Some of the known issues are:
* Mozilla Bug #1346410 - Load JSS libraries appropriately
NOTE: This issue should not occur unless step (4) above was skipped.
Testing failures were found while working on Bug 1346410 when loading the
JSS libraries to meet requirements of certain operating systems. Our
investigation revealed that due to the nature of the changes made via this
patch and its interaction with the HMAC Tests (both non-FIPS and FIPS),
that a failure may be encountered on one or more of the HMAC algorithms
causing these two tests to fail. On 64-bit Linux, for example, the
workaround for this issue is to perform the following steps before
re-running the tests:
* Install the new JSS builds by executing step (4) above
* Execute the following commands:
```
# cd sandbox/jss
# make test_jss
```
NOTE: If the system is being used for purposes other than test, the user
may wish to restore the original JSS by executing step (6) above.
#!/bin/bash -e
# BEGIN COPYRIGHT BLOCK
# (C) 2018 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
NAME=jss
SCRIPT_PATH=`readlink -f "$0"`
SCRIPT_NAME=`basename "$SCRIPT_PATH"`
SRC_DIR=`dirname "$SCRIPT_PATH"`
WORK_DIR="$HOME/build/$NAME"
SOURCE_TAG=
SPEC_TEMPLATE=
WITH_TIMESTAMP=
WITH_COMMIT_ID=
DIST=
VERBOSE=
DEBUG=
usage() {
echo "Usage: $SCRIPT_NAME [OPTIONS] <target>"
echo
echo "Options:"
echo " --work-dir=<path> Working directory (default: $WORK_DIR)."
echo " --source-tag=<tag> Generate RPM sources from a source tag."
echo " --spec=<file> Use the specified RPM spec."
echo " --with-timestamp Append timestamp to release number."
echo " --with-commit-id Append commit ID to release number."
echo " --dist=<name> Distribution name (e.g. fc28)."
echo " -v,--verbose Run in verbose mode."
echo " --debug Run in debug mode."
echo " --help Show help message."
echo
echo "Target:"
echo " src Generate RPM sources."
echo " spec Generate RPM spec."
echo " srpm Build SRPM package."
echo " rpm Build RPM packages (default)."
}
generate_rpm_sources() {
TARBALL="$NAME-$VERSION${_PHASE}.tar.gz"
if [ "$SOURCE_TAG" != "" ] ; then
if [ "$VERBOSE" = true ] ; then
echo "Generating $TARBALL from $SOURCE_TAG tag"
fi
git -C "$SRC_DIR" \
archive \
--format=tar.gz \
--prefix $NAME-$VERSION${_PHASE}/ \
-o "$WORK_DIR/SOURCES/$TARBALL" \
$SOURCE_TAG
if [ "$SOURCE_TAG" != "HEAD" ] ; then
TAG_ID=`git -C "$SRC_DIR" rev-parse $SOURCE_TAG`
HEAD_ID=`git -C "$SRC_DIR" rev-parse HEAD`
if [ "$TAG_ID" != "$HEAD_ID" ] ; then
generate_patch
fi
fi
return
fi
if [ "$VERBOSE" = true ] ; then
echo "Generating $TARBALL"
fi
tar czf "$WORK_DIR/SOURCES/$TARBALL" \
--transform "s,^./,$NAME-$VERSION${_PHASE}/," \
--exclude .git \
--exclude bin \
-C "$SRC_DIR" \
.
}
generate_patch() {
PATCH="$NAME-$VERSION-$RELEASE.patch"
if [ "$VERBOSE" = true ] ; then
echo "Generating $PATCH for all changes since $SOURCE_TAG tag"
fi
git -C "$SRC_DIR" \
format-patch \
--stdout \
$SOURCE_TAG \
> "$WORK_DIR/SOURCES/$PATCH"
}
generate_rpm_spec() {
RPM_SPEC="$NAME.spec"
if [ "$VERBOSE" = true ] ; then
echo "Generating $RPM_SPEC"
fi
# hard-code timestamp
commands="s/%{?_timestamp}/${_TIMESTAMP}/g"
# hard-code commit ID
commands="${commands}; s/%{?_commit_id}/${_COMMIT_ID}/g"
# hard-code phase
commands="${commands}; s/%{?_phase}/${_PHASE}/g"
# hard-code patch
if [ "$PATCH" != "" ] ; then
commands="${commands}; s/# Patch: jss-VERSION-RELEASE.patch/Patch: $PATCH/g"
fi
sed "$commands" "$SPEC_TEMPLATE" > "$WORK_DIR/SPECS/$RPM_SPEC"
# rpmlint "$WORK_DIR/SPECS/$RPM_SPEC"
}
while getopts v-: arg ; do
case $arg in
v)
VERBOSE=true
;;
-)
LONG_OPTARG="${OPTARG#*=}"
case $OPTARG in
work-dir=?*)
WORK_DIR=`readlink -f "$LONG_OPTARG"`
;;
source-tag=?*)
SOURCE_TAG="$LONG_OPTARG"
;;
spec=?*)
SPEC_TEMPLATE="$LONG_OPTARG"
;;
with-timestamp)
WITH_TIMESTAMP=true
;;
with-commit-id)
WITH_COMMIT_ID=true
;;
dist=?*)
DIST="$LONG_OPTARG"
;;
verbose)
VERBOSE=true
;;
debug)
VERBOSE=true
DEBUG=true
;;
help)
usage
exit
;;
'')
break # "--" terminates argument processing
;;
work-dir* | source-tag* | spec* | dist*)
echo "ERROR: Missing argument for --$OPTARG option" >&2
exit 1
;;
*)
echo "ERROR: Illegal option --$OPTARG" >&2
exit 1
;;
esac
;;
\?)
exit 1 # getopts already reported the illegal option
;;
esac
done
# remove parsed options and args from $@ list
shift $((OPTIND-1))
if [ "$#" -lt 1 ] ; then
BUILD_TARGET=rpm
else
BUILD_TARGET=$1
fi
if [ "$DEBUG" = true ] ; then
echo "WORK_DIR: $WORK_DIR"
echo "BUILD_TARGET: $BUILD_TARGET"
fi
if [ "$BUILD_TARGET" != "src" ] &&
[ "$BUILD_TARGET" != "spec" ] &&
[ "$BUILD_TARGET" != "srpm" ] &&
[ "$BUILD_TARGET" != "rpm" ] ; then
echo "ERROR: Invalid build target: $BUILD_TARGET" >&2
exit 1
fi
if [ "$SPEC_TEMPLATE" = "" ] ; then
SPEC_TEMPLATE="$SRC_DIR/$NAME.spec.in"
fi
VERSION="`rpmspec -P "$SPEC_TEMPLATE" | grep "^Version:" | awk '{print $2;}'`"
if [ "$DEBUG" = true ] ; then
echo "VERSION: $VERSION"
fi
RELEASE="`rpmspec -P "$SPEC_TEMPLATE" --undefine dist | grep "^Release:" | awk '{print $2;}'`"
if [ "$DEBUG" = true ] ; then
echo "RELEASE: $RELEASE"
fi
spec=$(<"$SPEC_TEMPLATE")
regex=$'%global *_phase *([^\n]+)'
if [[ $spec =~ $regex ]] ; then
_PHASE="${BASH_REMATCH[1]}"
fi
if [ "$DEBUG" = true ] ; then
echo "PHASE: ${_PHASE}"
fi
if [ "$WITH_TIMESTAMP" = true ] ; then
TIMESTAMP="`date +"%Y%m%d%H%M%S"`"
_TIMESTAMP=".$TIMESTAMP"
fi
if [ "$DEBUG" = true ] ; then
echo "TIMESTAMP: $TIMESTAMP"
fi
if [ "$WITH_COMMIT_ID" = true ]; then
COMMIT_ID="`git -C "$SRC_DIR" rev-parse --short=8 HEAD`"
_COMMIT_ID=".$COMMIT_ID"
fi
if [ "$DEBUG" = true ] ; then
echo "COMMIT_ID: $COMMIT_ID"
fi
echo "Building $NAME-$VERSION-$RELEASE${_TIMESTAMP}${_COMMIT_ID}"
################################################################################
# Initialize working directory
################################################################################
if [ "$VERBOSE" = true ] ; then
echo "Initializing $WORK_DIR"
fi
mkdir -p $WORK_DIR
cd $WORK_DIR
rm -rf BUILD
rm -rf RPMS
rm -rf SOURCES
rm -rf SPECS
rm -rf SRPMS
mkdir BUILD
mkdir RPMS
mkdir SOURCES
mkdir SPECS
mkdir SRPMS
################################################################################
# Generate RPM sources
################################################################################
generate_rpm_sources
echo "RPM sources:"
find "$WORK_DIR/SOURCES" -type f -printf " %p\n"
if [ "$BUILD_TARGET" = "src" ] ; then
exit
fi
################################################################################
# Generate RPM spec
################################################################################
generate_rpm_spec
echo "RPM spec:"
find "$WORK_DIR/SPECS" -type f -printf " %p\n"
if [ "$BUILD_TARGET" = "spec" ] ; then
exit
fi
################################################################################
# Build source package
################################################################################
OPTIONS=()
OPTIONS+=(--quiet)
OPTIONS+=(--define "_topdir ${WORK_DIR}")
if [ "$WITH_TIMESTAMP" = true ] ; then
OPTIONS+=(--define "_timestamp ${_TIMESTAMP}")
fi
if [ "$WITH_COMMIT_ID" = true ] ; then
OPTIONS+=(--define "_commit_id ${_COMMIT_ID}")
fi
if [ "$DIST" != "" ] ; then
OPTIONS+=(--define "dist .$DIST")
fi
if [ "$DEBUG" = true ] ; then
echo "rpmbuild -bs ${OPTIONS[@]} $WORK_DIR/SPECS/$RPM_SPEC"
fi
# build SRPM with user-provided options
rpmbuild -bs "${OPTIONS[@]}" "$WORK_DIR/SPECS/$RPM_SPEC"
rc=$?
if [ $rc != 0 ]; then
echo "ERROR: Unable to build SRPM package"
exit 1
fi
SRPM=`find "$WORK_DIR/SRPMS" -type f`
echo "SRPM package:"
echo " $SRPM"
if [ "$BUILD_TARGET" = "srpm" ] ; then
exit
fi
################################################################################
# Build binary packages
################################################################################
OPTIONS=()
if [ "$VERBOSE" = true ] ; then
OPTIONS+=(--define "_verbose 1")
fi
OPTIONS+=(--define "_topdir ${WORK_DIR}")
if [ "$DEBUG" = true ] ; then
echo "rpmbuild --rebuild ${OPTIONS[@]} $SRPM"
fi
# rebuild RPM with hard-coded options in SRPM
rpmbuild --rebuild "${OPTIONS[@]}" "$SRPM"
rc=$?
if [ $rc != 0 ]; then
echo "ERROR: Unable to build RPM packages"
exit 1
fi
# install SRPM to restore sources and spec file removed during rebuild
rpm -i --define "_topdir $WORK_DIR" "$SRPM"
# flatten folder
find "$WORK_DIR/RPMS" -mindepth 2 -type f -exec mv -i '{}' "$WORK_DIR/RPMS" ';'
# remove empty subfolders
find "$WORK_DIR/RPMS" -mindepth 1 -type d -delete
echo "RPM packages:"
find "$WORK_DIR/RPMS" -type f -printf " %p\n"
#use strict;
use Cwd qw(abs_path);
use File::Find;
use File::Compare;
use File::Basename;
......@@ -143,32 +144,45 @@ sub setup_vars {
$javah = "$ENV{JAVA_HOME}/bin/javah";
$javadoc = "$ENV{JAVA_HOME}/bin/javadoc";
$dist_dir = $cmdline_vars{SOURCE_PREFIX};
$dist_dir = abs_path($cmdline_vars{SOURCE_PREFIX});
$jce_jar = $ENV{JCE_JAR};
$class_release_dir = $cmdline_vars{SOURCE_RELEASE_PREFIX};
$class_dir = "$dist_dir/classes";
$class_jar = "$dist_dir/$cmdline_vars{XPCLASS_JAR}";
$class_release_dir .= "/$cmdline_vars{SOURCE_RELEASE_CLASSES_DIR}";
if( $ENV{BUILD_OPT} ) {
$class_dir = "$dist_dir/classes";
$class_jar = "$dist_dir/$cmdline_vars{XPCLASS_JAR}";
$class_release_dir .= "/$cmdline_vars{SOURCE_RELEASE_CLASSES_DIR}";
$javac_opt_flag = "-O";
$debug_source_file = "org/mozilla/jss/util/Debug_ship.jnot";
} else {
$class_dir = "$dist_dir/classes_DBG";
$class_jar = "$dist_dir/$cmdline_vars{XPCLASS_DBG_JAR}";
$class_release_dir .= "/$cmdline_vars{SOURCE_RELEASE_CLASSES_DBG_DIR}";
$javac_opt_flag = "-g";
$debug_source_file = "org/mozilla/jss/util/Debug_debug.jnot";
}
$jni_header_dir = "$dist_dir/private/jss/_jni";
if( $ENV{DEBIAN_BUILD} ) {
$jarFiles = "/usr/share/java/slf4j-api.jar:/usr/share/java/commons-codec.jar";
} else {
$jarFiles = "/usr/share/java/slf4j/slf4j-api.jar:/usr/share/java/commons-codec.jar";
}
$classpath = "-classpath $jarFiles:/usr/share/java/commons-lang.jar";
if( $jce_jar ) {
$classpath = "-classpath $jce_jar";
$classpath .= ":$jce_jar";
}
if( $ENV{CHECK_DEPRECATION} ) {
$javac_deprecation_flag = "-Xlint:deprecation";
} else {
$javac_deprecation_flag = "";
}
# retrieve present working directory
$pwd = `pwd`;
$pwd =~ chomp $pwd;
$jss_dir = `pwd`;
$jss_dir =~ chomp $jss_dir;
print "JSS directory: $jss_dir\n";
$work_dir = dirname($jss_dir);
print "Working directory: $work_dir\n";
# retrieve architecture
$arch = `uname -m`;
......@@ -178,13 +192,17 @@ sub setup_vars {
$os = `uname`;
$os =~ chomp $os;
$jss_objdir = "$work_dir/dist/$cmdline_vars{JSS_OBJDIR_NAME}";
print "jss_objdir=$jss_objdir\n";
if( ( $ENV{USE_INSTALLED_NSPR} ) && ( $ENV{USE_INSTALLED_NSS} ) ) {
print "Using the NSPR and NSS installed on the system to build JSS.\n";
} else {
# Verify existence of work area
if(( ! -d "$pwd/../nspr" ) ||
( ! -d "$pwd/../nss" ) ||
( ! -d "$pwd/../jss" )) {
if(( ! -d "$work_dir/nspr" ) ||
( ! -d "$work_dir/nss" ) ||
( ! -d "$jss_dir" )) {
my $workarea = "\nA work area must first be prepared; for example:\n\n"
. " mkdir sandbox\n"
. " cd sandbox\n"
......@@ -197,56 +215,41 @@ sub setup_vars {
}
# Build NSS if not already built
if( ! -d $dist_dir ) {
my $nss_latest_objdir = "$dist_dir/latest";
if( ! -e $nss_latest_objdir ) {
print("########################\n" .
"# BEGIN: Building NSS #\n" .
"########################\n");
print_do("cd ../nss;make clean nss_build_all;cd ../jss");
print_do("cd $work_dir/nss;make clean nss_build_all;cd $jss_dir");
print("######################\n" .
"# END: Building NSS #\n" .
"######################\n");
}
if( $os eq 'Linux' || $os eq 'Darwin' ) {
# set major and minor release numbers
$majorrel = `uname -r | cut -f1 -d.`;
$majorrel =~ chomp $majorrel;
$minorrel = `uname -r | cut -f2 -d.`;
$minorrel =~ chomp $minorrel;
# read the contents of the $dist_dir into an array
opendir DIR, $dist_dir or die "Cannot open directory: $!";
my @files = readdir DIR;
closedir DIR;
# process the array to obtain the NSS OBJDIR_NAME
my $prefix = "$os$majorrel.$minorrel";
foreach my $file (@files) {
if ((index($file, $prefix) != -1) &&
(index($file, "_cc") != -1)) {
$nss_objdir_name = $file;
print "NSS OBJDIR_NAME=$nss_objdir_name\n";
# craft JSS OBJDIR_NAME based upon value of NSS OBJDIR_NAME
$jss_objdir_name = $nss_objdir_name;
$jss_objdir_name =~ s/_cc//;
print "JSS OBJDIR_NAME=$jss_objdir_name\n";
break;
}
}
# create a JSS OBJDIR_NAME symlink to NSS OBJDIR_NAME in $dist_dir
$jss_symlink = "$pwd/../dist/$jss_objdir_name";
if( ! -l $jss_symlink ) {
my $cmd = "cd ../dist;"
. "ln -s $nss_objdir_name $jss_objdir_name;"
. "cd ../jss";
print_do($cmd);
}
print "jss_symlink=$jss_symlink\n"
$nss_objdir_name = `cat $nss_latest_objdir`;
chomp($nss_objdir_name);
$nss_bin_dir = "$dist_dir/$nss_objdir_name/bin";
$nss_lib_dir = "$dist_dir/$nss_objdir_name/lib";
$jss_objdir_name = $nss_objdir_name;
$jss_objdir_name =~ s/_cc//;
# create a JSS OBJDIR_NAME symlink to NSS OBJDIR_NAME
if( ! -l $jss_objdir ) {
my $cmd = "cd $work_dir/dist;"
. "ln -s $nss_objdir_name $jss_objdir_name;"
. "cd $jss_dir";
print_do($cmd);
}
}
print "nss_bin_dir=$nss_bin_dir\n";
print "nss_lib_dir=$nss_lib_dir\n";
$jss_lib_dir = "$jss_objdir/lib";
print "jss_lib_dir=$jss_lib_dir\n";
}
sub clean {
......@@ -266,19 +269,23 @@ sub build {
}
#
# generate manifest.mf file in lib dir
# generate MANIFEST.MF file in dist dir
#
my $manifest_file = "MANIFEST.MF";
my $manifest_file = "$dist_dir/MANIFEST.MF";
print "Creating $manifest_file\n";
my $jss_revision = `grep JSS_VERSION org/mozilla/jss/util/jssver.h`;
chop($jss_revision);
$jss_revision = substr($jss_revision, 22, 3);
my $build_revision = $jss_revision;
$append = 0;
ensure_dir_exists($dist_dir);
if ($append) {
open(MYOUTFILE, ">MANIFEST.MF"); #open for write, overwrite
open(MYOUTFILE, ">$manifest_file"); #open for write, overwrite
} else {
open(MYOUTFILE, ">>MANIFEST.MF"); #open for write, append
open(MYOUTFILE, ">>$manifest_file"); #open for write, append
}
#*** Print freeform text, semicolon required ***
......@@ -330,10 +337,9 @@ MyLabel
#
if( scalar(@source_list) > 0 ) {
ensure_dir_exists($class_dir);
print_do("$javac $javac_opt_flag -sourcepath . -d $class_dir " .
print_do("$javac $javac_opt_flag $javac_deprecation_flag -sourcepath . -d $class_dir " .
"$classpath " . join(" ",@source_list));
print_do("sh -c 'pwd && cd $class_dir && pwd && rm -f $class_jar && pwd && ls -al && ls -al ../../dist && $jar -cvmf ../../jss/$manifest_file ../$class_jar *'");
print_do("rm -f $manifest_file");
print_do("sh -c 'cd $dist_dir/classes && $jar cvmf $dist_dir/MANIFEST.MF $dist_dir/xpclass.jar *'");
print "Exit status was " . ($?>>8) . "\n";
}
......@@ -373,7 +379,7 @@ sub needs_update {
# the source file's directory is different from its package, and it
# doesn't know about nested or inner classes.
# source_file: the relative path to the source file ("org/mozilla/jss/...")
# dest_dir: the directory where classes are output ("../../dist/classes_DBG")
# dest_dir: the directory where classes are output ("../../dist/classes")
# Returns 1 if the source file is newer than the class file, or the class file
# doesn't exist. Returns 0 if the class file is newer than the source file.
sub java_source_needs_update {
......@@ -427,7 +433,7 @@ sub javadoc {
ensure_dir_exists("$dist_dir/jssdoc");
my $targets = join(" ", @packages);
print "$targets\n";
print_do("$javadoc -breakiterator -sourcepath . -d $dist_dir/jssdoc $html_header_opt $targets");
print_do("$javadoc -breakiterator $classpath -sourcepath . -d $dist_dir/jssdoc $html_header_opt $targets");
print_do("cp $dist_dir/jssdoc/index.html $dist_dir/jssdoc/index.html.bak");
print_do("cp $dist_dir/jssdoc/overview-summary.html $dist_dir/jssdoc/index.html");
}
......@@ -437,11 +443,12 @@ sub test {
die "make test_jss is only available on upstream builds of Linux and MacOS platforms.";
} elsif( $os eq 'Linux' || $os eq 'Darwin' ) {
# Test JSS presuming that it has already been built
if(( -d $dist_dir ) &&
( -l $jss_symlink )) {
my $cmd = "cd $pwd/org/mozilla/jss/tests;"
. "perl all.pl dist $jss_symlink;"
. "cd $pwd";
( -d $jss_objdir || -l $jss_objdir )) {
my $cmd = "cd $jss_dir/org/mozilla/jss/tests;"
. "perl all.pl dist \"$dist_dir\" \"$nss_bin_dir\" \"$nss_lib_dir\" \"$jss_lib_dir\";"
. "cd $jss_dir";
print("#######################\n" .
"# BEGIN: Testing JSS #\n" .
......@@ -451,7 +458,7 @@ sub test {
"# END: Testing JSS #\n" .
"#####################\n");
} else {
die "JSS builds are not available at $jss_symlink.";
die "JSS builds are not available at $jss_objdir.";
}
} else {
die "make test_jss is only available on Linux and MacOS platforms.";
......
......@@ -21,11 +21,7 @@ endif
# set default location of the java classes repository
ifeq ($(JAVA_DESTPATH),)
ifdef BUILD_OPT
JAVA_DESTPATH = $(SOURCE_CLASSES_DIR)
else
JAVA_DESTPATH = $(SOURCE_CLASSES_DBG_DIR)
endif
endif
# set default location of the package under the java classes repository
......
......@@ -134,9 +134,8 @@ release_cpdistdir::
"SOURCE_RELEASE_PREFIX=$(SOURCE_RELEASE_XP_DIR)" \
"RELEASE_XP_DIR=$(RELEASE_XP_DIR)" \
"RELEASE_MD_DIR=$(RELEASE_MD_DIR)" \
"FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR) XP_FILES MD_FILES" \
"FILES=$(XPCLASS_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR) XP_FILES MD_FILES" \
"$(XPCLASS_JAR)=$(SOURCE_RELEASE_CLASSES_DIR)|x"\
"$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_CLASSES_DBG_DIR)|x"\
"$(XPHEADER_JAR)=$(SOURCE_RELEASE_XPHEADERS_DIR)|x" \
"$(MDHEADER_JAR)=$(SOURCE_RELEASE_MDHEADERS_DIR)|m" \
"$(MDBINARY_JAR)=$(SOURCE_RELEASE_MD_DIR)|m" \
......@@ -155,9 +154,8 @@ release_jars::
"OS_ARCH=$(OS_ARCH)" \
"RELEASE_VERSION=$(RELEASE_VERSION)" \
"SOURCE_RELEASE_DIR=$(SOURCE_RELEASE_DIR)" \
"FILES=$(XPCLASS_JAR) $(XPCLASS_DBG_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
"FILES=$(XPCLASS_JAR) $(XPHEADER_JAR) $(MDHEADER_JAR) $(MDBINARY_JAR)" \
"$(XPCLASS_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)|b"\
"$(XPCLASS_DBG_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)|b"\
"$(XPHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_XPHEADERS_DIR)|a" \
"$(MDHEADER_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MDHEADERS_DIR)|a" \
"$(MDBINARY_JAR)=$(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_MD_DIR)|bi"
......@@ -181,24 +179,13 @@ ifneq ($(CLASSES),)
RELEASE_CLASSES := $(patsubst %,%,$(CLASSES))
ifdef BUILD_OPT
RELEASE_CLASS_PATH := $(patsubst %,$(SOURCE_CLASSES_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
RELEASE_NESTED := $(foreach file,$(RELEASE_CLASS_PATH),$(wildcard $(file)$$*))
RELEASE_FILES := $(patsubst %,%.class,$(RELEASE_CLASS_PATH)) $(RELEASE_NESTED)
else
RELEASE_DBG_CLASS_PATH:= $(patsubst %,$(SOURCE_CLASSES_DBG_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
RELEASE_DBG_NESTED := $(foreach file,$(RELEASE_DBG_CLASS_PATH),$(wildcard $(file)$$*))
RELEASE_DBG_FILES := $(patsubst %,%.class,$(RELEASE_DBG_CLASS_PATH)) $(RELEASE_DBG_NESTED)
endif
RELEASE_CLASS_PATH := $(patsubst %,$(SOURCE_CLASSES_DIR)/$(PACKAGE)/%, $(RELEASE_CLASSES))
RELEASE_NESTED := $(foreach file,$(RELEASE_CLASS_PATH),$(wildcard $(file)$$*))
RELEASE_FILES := $(patsubst %,%.class,$(RELEASE_CLASS_PATH)) $(RELEASE_NESTED)
# Substitute \$ for $ so the shell doesn't choke
ifdef BUILD_OPT
release_classes::
$(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DIR)/$(PACKAGE)
else
release_classes::
$(INSTALL) -m 444 $(subst $$,\$$,$(RELEASE_DBG_FILES)) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_CLASSES_DBG_DIR)/$(PACKAGE)
endif
endif
......
......@@ -32,15 +32,10 @@ endif
#
SOURCE_CLASSES_DIR = $(SOURCE_XP_DIR)/classes
SOURCE_CLASSES_DBG_DIR = $(SOURCE_XP_DIR)/classes_DBG
SOURCE_XPHEADERS_DIR = $(SOURCE_XP_DIR)/public/$(MODULE)
SOURCE_XPPRIVATE_DIR = $(SOURCE_XP_DIR)/private/$(MODULE)
ifdef BUILD_OPT
IMPORT_XPCLASS_DIR = $(SOURCE_CLASSES_DIR)
else
IMPORT_XPCLASS_DIR = $(SOURCE_CLASSES_DBG_DIR)
endif
IMPORT_XPCLASS_DIR = $(SOURCE_CLASSES_DIR)
#
# <user_source_tree> machine-dependent (md) master import/export directory
......@@ -111,7 +106,6 @@ SOURCE_RELEASE_XP_DIR = $(SOURCE_RELEASE_PREFIX)
#
SOURCE_RELEASE_CLASSES_DIR = classes
SOURCE_RELEASE_CLASSES_DBG_DIR = classes_DBG
SOURCE_RELEASE_XPHEADERS_DIR = include
#
......@@ -119,16 +113,10 @@ SOURCE_RELEASE_XPHEADERS_DIR = include
#
XPCLASS_JAR = xpclass.jar
XPCLASS_DBG_JAR = xpclass_dbg.jar
XPHEADER_JAR = xpheader.jar
ifdef BUILD_OPT
SOURCE_RELEASE_XP_CLASSES_DIR = $(SOURCE_RELEASE_CLASSES_DIR)
IMPORT_XPCLASS_JAR = $(XPCLASS_JAR)
else
SOURCE_RELEASE_XP_CLASSES_DIR = $(SOURCE_RELEASE_CLASSES_DBG_DIR)
IMPORT_XPCLASS_JAR = $(XPCLASS_DBG_JAR)
endif
SOURCE_RELEASE_XP_CLASSES_DIR = $(SOURCE_RELEASE_CLASSES_DIR)
IMPORT_XPCLASS_JAR = $(XPCLASS_JAR)
#
# <user_source_tree> machine-dependent (md) source-side master release directory
......
......@@ -6,28 +6,48 @@ Summary: Java Security Services (JSS)
URL: http://www.dogtagpki.org/wiki/JSS
License: MPLv1.1 or GPLv2+ or LGPLv2+
Version: 4.4.4
Release: 1%{?_timestamp}%{?_commit_id}%{?dist}
Version: 4.5.0
Release: 0.4%{?_timestamp}%{?_commit_id}%{?dist}
%global _phase -a4
# To generate the source tarball:
#
# git clone https://github.com/dogtagpki/jss.git
# cd jss
# git archive --format=tar.gz --prefix jss-VERSION/jss/ -o jss-VERSION.tar.gz -v HEAD
#
Source: https://github.com/dogtagpki/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
# $ git clone https://github.com/dogtagpki/jss.git
# $ cd jss
# $ git archive \
# --format=tar.gz \
# --prefix jss-VERSION/ \
# -o jss-VERSION.tar.gz \
# <version tag>
Source: https://github.com/dogtagpki/%{name}/archive/v%{version}%{?_phase}/%{name}-%{version}%{?_phase}.tar.gz
# To create a patch for all changes since a version tag:
# $ git format-patch \
# --stdout \
# <version tag> \
# > jss-VERSION-RELEASE.patch
# Patch: jss-VERSION-RELEASE.patch
Conflicts: idm-console-framework < 1.1.17-4
Conflicts: pki-base < 10.4.0
Conflicts: tomcatjss < 7.2.1
################################################################################
# Build Dependencies
################################################################################
# autosetup
BuildRequires: git
BuildRequires: gcc-c++
BuildRequires: nss-devel >= 3.28.4-6
BuildRequires: nspr-devel >= 4.13.1
BuildRequires: java-devel
BuildRequires: jpackage-utils
BuildRequires: slf4j
%if 0%{?rhel} && 0%{?rhel} <= 7
# no slf4j-jdk14
%else
BuildRequires: slf4j-jdk14
%endif
BuildRequires: apache-commons-lang
BuildRequires: apache-commons-codec
%if 0%{?fedora} >= 25 || 0%{?rhel} > 7
BuildRequires: perl-interpreter
%endif
......@@ -35,6 +55,18 @@ BuildRequires: perl-interpreter
Requires: nss >= 3.28.4-6
Requires: java-headless
Requires: jpackage-utils
Requires: slf4j
%if 0%{?rhel} && 0%{?rhel} <= 7
# no slf4j-jdk14
%else
Requires: slf4j-jdk14
%endif
Requires: apache-commons-lang
Requires: apache-commons-codec
Conflicts: idm-console-framework < 1.1.17-4
Conflicts: pki-base < 10.6.3
Conflicts: tomcatjss < 7.3.2
%description
Java Security Services (JSS) is a java native interface which provides a bridge
......@@ -55,7 +87,7 @@ This package contains the API documentation for JSS.
################################################################################
%prep
%autosetup -n %{name}-%{version} -p 1 -S git
%autosetup -n %{name}-%{version}%{?_phase} -p 1 -S git
################################################################################
%build
......@@ -66,10 +98,7 @@ This package contains the API documentation for JSS.
[ -z "$USE_INSTALLED_NSPR" ] && export USE_INSTALLED_NSPR=1
[ -z "$USE_INSTALLED_NSS" ] && export USE_INSTALLED_NSS=1
# Enable compiler optimizations and disable debugging code
# NOTE: If you ever need to create a debug build with optimizations disabled
# just comment out this line and change in the %%install section below the
# line that copies jars xpclass.jar to be xpclass_dbg.jar
# Enable compiler optimizations
export BUILD_OPT=1
# Generate symbolic info for debuggers
......@@ -99,59 +128,51 @@ export USE_64
%endif
# The Makefile is not thread-safe
make -C jss/coreconf
make -C jss
make -C jss javadoc
make -C coreconf
make
make javadoc
################################################################################
%install
# Copy the license files here so we can include them in %%doc
cp -p jss/MPL-1.1.txt .
cp -p jss/gpl.txt .
cp -p jss/lgpl.txt .
# There is no install target so we'll do it by hand
# jars
install -d -m 0755 $RPM_BUILD_ROOT%{_jnidir}
# NOTE: if doing a debug no opt build change xpclass.jar to xpclass_dbg.jar
install -m 644 dist/xpclass.jar ${RPM_BUILD_ROOT}%{_jnidir}/jss4.jar
install -m 644 ../dist/xpclass.jar ${RPM_BUILD_ROOT}%{_jnidir}/jss4.jar
# We have to use the name libjss4.so because this is dynamically
# loaded by the jar file.
install -d -m 0755 $RPM_BUILD_ROOT%{_libdir}/jss
install -m 0755 dist/Linux*.OBJ/lib/libjss4.so ${RPM_BUILD_ROOT}%{_libdir}/jss/
install -m 0755 ../dist/Linux*.OBJ/lib/libjss4.so ${RPM_BUILD_ROOT}%{_libdir}/jss/
pushd ${RPM_BUILD_ROOT}%{_libdir}/jss
ln -fs %{_jnidir}/jss4.jar jss4.jar
popd
# javadoc
install -d -m 0755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -rp dist/jssdoc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -p jss/jss.html $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -p jss/*.txt $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -rp ../dist/jssdoc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -p jss.html $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -p *.txt $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
# No ldconfig is required since this library is loaded by Java itself.
################################################################################
%files
%defattr(-,root,root,-)
%doc jss/jss.html jss/MPL-1.1.txt jss/gpl.txt jss/lgpl.txt
%{_libdir}/jss/*
%doc jss.html MPL-1.1.txt gpl.txt lgpl.txt
%{_libdir}/*
%{_jnidir}/*
%{_libdir}/jss/lib*.so
################################################################################
%files javadoc
%defattr(-,root,root,-)
%dir %{_javadocdir}/%{name}-%{version}
%{_javadocdir}/%{name}-%{version}/*
%{_javadocdir}/%{name}-%{version}/
################################################################################
%changelog
* Tue May 29 2018 Dogtag PKI Team <pki-devel@redhat.com> 4.4.0-0
* Tue May 29 2018 Dogtag PKI Team <pki-devel@redhat.com> 4.5.0-0
- To list changes in <branch> since <tag>:
$ git log --pretty=oneline --abbrev-commit --no-decorate <tag>..<branch>
......@@ -330,3 +330,13 @@ Java_org_mozilla_jss_pkcs11_PK11Store_importEncryptedPrivateKeyInfo;
;+ local:
;+ *;
;+};
;+JSS_4.5 { # JSS 4.5 release
;+ global:
Java_org_mozilla_jss_pkcs11_PK11RSAPrivateKey_getModulusByteArray;
Java_org_mozilla_jss_pkcs11_PK11Token_importPublicKey;
Java_org_mozilla_jss_pkcs11_PK11Store_loadPrivateKeys;
Java_org_mozilla_jss_pkcs11_PK11Store_loadPublicKeys;
Java_org_mozilla_jss_pkcs11_PK11Store_deletePublicKey;
;+ local:
;+ *;
;+};
......@@ -7,6 +7,7 @@ package org.mozilla.jss;
* Thrown if a CRL cannot be imported
*/
public class CRLImportException extends java.lang.Exception {
private static final long serialVersionUID = 1L;
public CRLImportException() {}
public CRLImportException(String mesg) {
super(mesg);
......
......@@ -8,6 +8,7 @@ package org.mozilla.jss;
* or if an error occurs while opening it.
*/
public class CertDatabaseException extends java.lang.Exception {
private static final long serialVersionUID = 1L;
public CertDatabaseException() {}
public CertDatabaseException(String mesg) {
super(mesg);
......
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.jss;
import java.util.ArrayList;
import java.util.Iterator;
/**
* CertificateUsage options for validation
*/
public final class CertificateUsage {
private int usage;
private String name;
// certificateUsage, these must be kept in sync with nss/lib/certdb/certt.h
private static final int certificateUsageCheckAllUsages = 0x0000;
private static final int certificateUsageSSLClient = 0x0001;
private static final int certificateUsageSSLServer = 0x0002;
private static final int certificateUsageSSLServerWithStepUp = 0x0004;
private static final int certificateUsageSSLCA = 0x0008;
private static final int certificateUsageEmailSigner = 0x0010;
private static final int certificateUsageEmailRecipient = 0x0020;
private static final int certificateUsageObjectSigner = 0x0040;
private static final int certificateUsageUserCertImport = 0x0080;
private static final int certificateUsageVerifyCA = 0x0100;
private static final int certificateUsageProtectedObjectSigner = 0x0200;
private static final int certificateUsageStatusResponder = 0x0400;
private static final int certificateUsageAnyCA = 0x0800;
static private ArrayList<CertificateUsage> list = new ArrayList<>();
private CertificateUsage() {
}
private CertificateUsage(int usage, String name) {
this.usage = usage;
this.name = name;
list.add(this);
}
public int getUsage() {
return usage;
}
static public Iterator<CertificateUsage> getCertificateUsages() {
return list.iterator();
}
public String toString() {
return name;
}
public static final CertificateUsage CheckAllUsages = new CertificateUsage(certificateUsageCheckAllUsages, "CheckAllUsages");
public static final CertificateUsage SSLClient = new CertificateUsage(certificateUsageSSLClient, "SSLClient");
public static final CertificateUsage SSLServer = new CertificateUsage(certificateUsageSSLServer, "SSLServer");
public static final CertificateUsage SSLServerWithStepUp = new CertificateUsage(certificateUsageSSLServerWithStepUp, "SSLServerWithStepUp");
public static final CertificateUsage SSLCA = new CertificateUsage(certificateUsageSSLCA, "SSLCA");
public static final CertificateUsage EmailSigner = new CertificateUsage(certificateUsageEmailSigner, "EmailSigner");
public static final CertificateUsage EmailRecipient = new CertificateUsage(certificateUsageEmailRecipient, "EmailRecipient");
public static final CertificateUsage ObjectSigner = new CertificateUsage(certificateUsageObjectSigner, "ObjectSigner");
public static final CertificateUsage UserCertImport = new CertificateUsage(certificateUsageUserCertImport, "UserCertImport");
public static final CertificateUsage VerifyCA = new CertificateUsage(certificateUsageVerifyCA, "VerifyCA");
public static final CertificateUsage ProtectedObjectSigner = new CertificateUsage(certificateUsageProtectedObjectSigner, "ProtectedObjectSigner");
public static final CertificateUsage StatusResponder = new CertificateUsage(certificateUsageStatusResponder, "StatusResponder");
public static final CertificateUsage AnyCA = new CertificateUsage(certificateUsageAnyCA, "AnyCA");
/*
The folllowing usages cannot be verified:
certUsageAnyCA
certUsageProtectedObjectSigner
certUsageUserCertImport
certUsageVerifyCA
*/
public static final int basicCertificateUsages = /*0x0b80;*/
certificateUsageUserCertImport |
certificateUsageVerifyCA |
certificateUsageProtectedObjectSigner |
certificateUsageAnyCA ;
}
This diff is collapsed.
......@@ -5,7 +5,7 @@ package org.mozilla.jss;
/**
* A class for closing databases. Since closing the databases is
* very dangerous and breaks the JSS model, it may only be done from
* very dangerous and breaks the JSS model, it may only be done from
* special applications. This class should be subclasses by
* authorized subclasses. It cannot be instantiated itself.
*/
......@@ -23,7 +23,7 @@ public abstract class DatabaseCloser {
* @throws Exception If the instantiation is not a valid subclass.
*/
public DatabaseCloser() throws Exception {
Class clazz = this.getClass();
Class<?> clazz = this.getClass();
String name = clazz.getName();
boolean approved = false;
for(int i=0; i < authorizedClosers.length; i++) {
......
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.jss;
import org.mozilla.jss.util.ConsolePasswordCallback;
import org.mozilla.jss.util.PasswordCallback;
/**
* The various options that can be used to initialize CryptoManager.
*/
public final class InitializationValues {
protected InitializationValues() {
throw new RuntimeException("Default InitializationValues constructor");
}
/////////////////////////////////////////////////////////////
// Constants
/////////////////////////////////////////////////////////////
/**
* Token names must be this length exactly.
*/
public final int TOKEN_LENGTH = 33;
/**
* Slot names must be this length exactly.
*/
public final int SLOT_LENGTH = 65;
/**
* ManufacturerID must be this length exactly.
*/
public final int MANUFACTURER_LENGTH = 33;
/**
* Library description must be this length exactly.
*/
public final int LIBRARY_LENGTH = 33;
/**
* This class enumerates the possible modes for FIPS compliance.
*/
public static final class FIPSMode {
private FIPSMode() {}
/**
* Enable FIPS mode.
*/
public static final InitializationValues.FIPSMode ENABLED = new FIPSMode();
/**
* Disable FIPS mode.
*/
public static final InitializationValues.FIPSMode DISABLED = new FIPSMode();
/**
* Leave FIPS mode unchanged. All servers except Admin
* Server should use this, because only Admin Server should
* be altering FIPS mode.
*/
public static final InitializationValues.FIPSMode UNCHANGED = new FIPSMode();
}
public InitializationValues(String configDir) {
this.configDir = configDir;
}
public InitializationValues(String configDir, String certPrefix,
String keyPrefix, String secmodName)
{
this.configDir = configDir;
this.certPrefix = certPrefix;
this.keyPrefix = keyPrefix;
this.secmodName = secmodName;
}
public String configDir = null;
public String certPrefix = null;
public String keyPrefix = null;
public String secmodName = null;
/**
* The password callback to be used by JSS whenever a password
* is needed. May be NULL, in which the library will immediately fail
* to get a password if it tries to login automatically while
* performing
* a cryptographic operation. It will still work if the token
* has been manually logged in with <code>CryptoToken.login</code>.
* <p>The default is a <code>ConsolePasswordCallback</code>.
*/
public PasswordCallback passwordCallback =
new ConsolePasswordCallback();
/**
* The FIPS mode of the security library. Servers should
* use <code>FIPSMode.UNCHANGED</code>, since only
* Admin Server is supposed to alter this value.
* <p>The default is <code>FIPSMode.UNCHANGED</code>.
*/
public InitializationValues.FIPSMode fipsMode = FIPSMode.UNCHANGED;
/**
* To open the databases in read-only mode, set this flag to
* <code>true</code>. The default is <code>false</code>, meaning
* the databases are opened in read-write mode.
*/
public boolean readOnly = false;
////////////////////////////////////////////////////////////////////
// Manufacturer ID
////////////////////////////////////////////////////////////////////
/**
* Returns the Manufacturer ID of the internal PKCS #11 module.
* <p>The default is <code>"mozilla.org "</code>.
*
* @return Manufacturer ID.
*/
public String getManufacturerID() { return manufacturerID; }
/**
* Sets the Manufacturer ID of the internal PKCS #11 module.
* This value must be exactly <code>MANUFACTURER_LENGTH</code>
* characters long.
*
* @param s Manufacturer ID.
* @exception InvalidLengthException If <code>s.length()</code> is not
* exactly <code>MANUFACTURER_LENGTH</code>.
*/
public void setManufacturerID(String s) throws InvalidLengthException {
if( s.length() != MANUFACTURER_LENGTH ) {
throw new InvalidLengthException();
}
manufacturerID = s;
}
private String manufacturerID =
"mozilla.org ";
////////////////////////////////////////////////////////////////////
// Library Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 module.
* <p>The default is <code>"Internal Crypto Services "</code>.
*
* @return Library description.
*/
public String getLibraryDescription() { return libraryDescription; }
/**
* Sets the description of the internal PKCS #11 module.
* This value must be exactly <code>LIBRARY_LENGTH</code>
* characters long.
*
* @param s Library description.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>LIBRARY_LENGTH</code>.
*/
public void setLibraryDescription(String s)
throws InvalidLengthException
{
if( s.length() != LIBRARY_LENGTH ) {
throw new InvalidLengthException();
}
libraryDescription = s;
}
private String libraryDescription =
"Internal Crypto Services ";
////////////////////////////////////////////////////////////////////
// Internal Token Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 token.
* <p>The default is <code>"Internal Crypto Services Token "</code>.
*
* @return Description of internal PKCS #11 token.
*/
public String getInternalTokenDescription() {
return internalTokenDescription;
}
/**
* Sets the description of the internal PKCS #11 token.
* This value must be exactly <code>TOKEN_LENGTH</code> characters long.
*
* @param s Description of internal PKCS #11 token.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>TOKEN_LENGTH</code>.
*/
public void setInternalTokenDescription(String s)
throws InvalidLengthException
{
if(s.length() != TOKEN_LENGTH) {
throw new InvalidLengthException();
}
internalTokenDescription = s;
}
private String internalTokenDescription =
"NSS Generic Crypto Services ";
////////////////////////////////////////////////////////////////////
// Internal Key Storage Token Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 key storage token.
* <p>The default is <code>"Internal Key Storage Token "</code>.
*
* @return Description of internal PKCS #11 key storage token.
*/
public String getInternalKeyStorageTokenDescription() {
return internalKeyStorageTokenDescription;
}
/**
* Sets the description of the internal PKCS #11 key storage token.
* This value must be exactly <code>TOKEN_LENGTH</code> characters long.
*
* @param s Description of internal PKCS #11 key storage token.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>TOKEN_LENGTH</code>.
*/
public void setInternalKeyStorageTokenDescription(String s)
throws InvalidLengthException
{
if(s.length() != TOKEN_LENGTH) {
throw new InvalidLengthException();
}
internalKeyStorageTokenDescription = s;
}
private String internalKeyStorageTokenDescription =
"Internal Key Storage Token ";
////////////////////////////////////////////////////////////////////
// Internal Slot Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 slot.
* <p>The default is <code>"NSS Internal Cryptographic Services "</code>.
*
* @return Description of internal PKCS #11 slot.
*/
public String getInternalSlotDescription() {
return internalSlotDescription;
}
/**
* Sets the description of the internal PKCS #11 slot.
* This value must be exactly <code>SLOT_LENGTH</code> characters
* long.
*
* @param s Description of internal PKCS #11 slot.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>SLOT_LENGTH</code>.
*/
public void setInternalSlotDescription(String s)
throws InvalidLengthException
{
if(s.length() != SLOT_LENGTH) {
throw new InvalidLengthException();
}
internalSlotDescription = s;
}
private String internalSlotDescription =
"NSS Internal Cryptographic Services ";
////////////////////////////////////////////////////////////////////
// Internal Key Storage Slot Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 key storage slot.
* <p>The default is <code>"NSS Internal Private Key and Certificate Storage "</code>.
*
* @return Description of internal PKCS #11 key storage slot.
*/
public String getInternalKeyStorageSlotDescription() {
return internalKeyStorageSlotDescription;
}
/**
* Sets the description of the internal PKCS #11 key storage slot.
* This value must be exactly <code>SLOT_LENGTH</code> characters
* long.
*
* @param s Description of internal PKCS #11 key storage slot.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>SLOT_LENGTH</code>.
*/
public void setInternalKeyStorageSlotDescription(String s)
throws InvalidLengthException
{
if(s.length() != SLOT_LENGTH) {
throw new InvalidLengthException();
}
internalKeyStorageSlotDescription = s;
}
private String internalKeyStorageSlotDescription =
"NSS User Private Key and Certificate Services ";
////////////////////////////////////////////////////////////////////
// FIPS Slot Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 FIPS slot.
* <p>The default is
* <code>"NSS FIPS 140-2 User Private Key Services"</code>.
*
* @return Description of internal PKCS #11 FIPS slot.
*/
public String getFIPSSlotDescription() {
return FIPSSlotDescription;
}
/**
* Sets the description of the internal PKCS #11 FIPS slot.
* This value must be exactly <code>SLOT_LENGTH</code> characters
* long.
*
* @param s Description of internal PKCS #11 FIPS slot.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>SLOT_LENGTH</code>.
*/
public void setFIPSSlotDescription(String s)
throws InvalidLengthException
{
if(s.length() != SLOT_LENGTH) {
throw new InvalidLengthException();
}
FIPSSlotDescription = s;
}
private String FIPSSlotDescription =
"NSS FIPS 140-2 User Private Key Services ";
////////////////////////////////////////////////////////////////////
// FIPS Key Storage Slot Description
////////////////////////////////////////////////////////////////////
/**
* Returns the description of the internal PKCS #11 FIPS
* Key Storage slot.
* <p>The default is
* <code>"NSS FIPS 140-2 User Private Key Services"</code>.
*
* @return Description of internal PKCS #11 FIPS key storage slot.
*/
public String getFIPSKeyStorageSlotDescription() {
return FIPSKeyStorageSlotDescription;
}
/**
* Sets the description of the internal PKCS #11 FIPS Key Storage slot.
* This value must be exactly <code>SLOT_LENGTH</code> characters
* long.
*
* @param s Description of internal PKCS #11 FIPS key storage slot.
* @exception InvalidLengthException If <code>s.length()</code> is
* not exactly <code>SLOT_LENGTH</code>.
*/
public void setFIPSKeyStorageSlotDescription(String s)
throws InvalidLengthException
{
if(s.length() != SLOT_LENGTH) {
throw new InvalidLengthException();
}
FIPSKeyStorageSlotDescription = s;
}
private String FIPSKeyStorageSlotDescription =
"NSS FIPS 140-2 User Private Key Services ";
/**
* To have NSS check the OCSP responder for when verifying
* certificates, set this flags to true. It is false by
* default.
*/
public boolean ocspCheckingEnabled = false;
/**
* Specify the location and cert of the responder.
* If OCSP checking is enabled *and* this variable is
* set to some URL, all OCSP checking will be done via
* this URL.
*
* If this variable is null, the OCSP responder URL will
* be obtained from the AIA extension in the certificate
* being queried.
*
* If this is set, you must also set ocspResponderCertNickname
*
*/
public String ocspResponderURL = null;
/**
* The nickname of the cert to trust (expected) to
* sign the OCSP responses.
* Only checked when the OCSPResponder value is set.
*/
public String ocspResponderCertNickname = null;
/**
* Install the JSS crypto provider. Default is true.
*/
public boolean installJSSProvider = true;
/**
* Remove the Sun crypto provider. Default is false.
*/
public boolean removeSunProvider = false;
/**
* If <tt>true</tt>, none of the underlying NSS components will
* be initialized. Only the Java portions of JSS will be
* initialized. This should only be used if NSS has been initialized
* elsewhere.
*
* <p>Specifically, the following components will <b>not</b> be
* configured by <tt>CryptoManager.initialize</tt> if this flag is set:
* <ul>
* <li>The NSS databases.
* <li>OCSP checking.
* <li>The NSS password callback.
* <li>The internal PKCS #11 software token's identifier labels:
* slot, token, module, and manufacturer.
* <li>The minimum PIN length for the software token.
* <li>The frequency with which the user must login to the software
* token.
* <li>The cipher strength policy (export/domestic).
* </ul>
*
* <p>The default is <tt>false</tt>.
*/
public boolean initializeJavaOnly = false;
/**
* Enable PKIX verify rather than the old cert library,
* to verify certificates. Default is false.
*/
public boolean PKIXVerify = false;
/**
* Don't open the cert DB and key DB's, just
* initialize the volatile certdb. Default is false.
*/
public boolean noCertDB = false;
/**
* Don't open the security module DB,
* just initialize the PKCS #11 module.
* Default is false.
*/
public boolean noModDB = false;
/**
* Continue to force initializations even if the
* databases cannot be opened.
* Default is false.
*/
public boolean forceOpen = false;
/**
* Don't try to look for the root certs module
* automatically.
* Default is false.
*/
public boolean noRootInit = false;
/**
* Use smaller tables and caches.
* Default is false.
*/
public boolean optimizeSpace = false;
/**
* only load PKCS#11 modules that are
* thread-safe, ie. that support locking - either OS
* locking or NSS-provided locks . If a PKCS#11
* module isn't thread-safe, don't serialize its
* calls; just don't load it instead. This is necessary
* if another piece of code is using the same PKCS#11
* modules that NSS is accessing without going through
* NSS, for example the Java SunPKCS11 provider.
* Default is false.
*/
public boolean PK11ThreadSafe = false;
/**
* Init PK11Reload to ignore the CKR_CRYPTOKI_ALREADY_INITIALIZED
* error when loading PKCS#11 modules. This is necessary
* if another piece of code is using the same PKCS#11
* modules that NSS is accessing without going through
* NSS, for example Java SunPKCS11 provider.
* default is false.
*/
public boolean PK11Reload = false;
/**
* never call C_Finalize on any
* PKCS#11 module. This may be necessary in order to
* ensure continuous operation and proper shutdown
* sequence if another piece of code is using the same
* PKCS#11 modules that NSS is accessing without going
* through NSS, for example Java SunPKCS11 provider.
* The following limitation applies when this is set :
* SECMOD_WaitForAnyTokenEvent will not use
* C_WaitForSlotEvent, in order to prevent the need for
* C_Finalize. This call will be emulated instead.
* Default is false.
*/
public boolean noPK11Finalize = false;
/**
* Sets 4 recommended options for applications that
* use both NSS and the Java SunPKCS11 provider.
* Default is false.
*/
public boolean cooperate = false;
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.jss;
public final class InvalidLengthException extends Exception {
private static final long serialVersionUID = 1L;
}
......@@ -5,6 +5,7 @@ package org.mozilla.jss;
public final class JSSProvider extends java.security.Provider {
private static final long serialVersionUID = 1L;
/********************************************************************/
/* The VERSION Strings should be updated in the following */
/* files everytime a new release of JSS is generated: */
......@@ -18,7 +19,7 @@ public final class JSSProvider extends java.security.Provider {
/********************************************************************/
/* QUESTION: When do we change MINOR and PATCH to 4 and 0? */
private static int JSS_MAJOR_VERSION = 4;
private static int JSS_MINOR_VERSION = 4;
private static int JSS_MINOR_VERSION = 5;
private static int JSS_PATCH_VERSION = 0;
private static double JSS_VERSION = JSS_MAJOR_VERSION +
(JSS_MINOR_VERSION * 100 +
......@@ -148,6 +149,12 @@ public final class JSSProvider extends java.security.Provider {
put("KeyFactory.EC",
"org.mozilla.jss.provider.java.security.KeyFactorySpi1_2");
/////////////////////////////////////////////////////////////
// KeyStore
/////////////////////////////////////////////////////////////
put("KeyStore.PKCS11",
"org.mozilla.jss.provider.java.security.JSSKeyStoreSpi");
/////////////////////////////////////////////////////////////
// AlgorithmParameters
/////////////////////////////////////////////////////////////
......
......@@ -8,6 +8,7 @@ package org.mozilla.jss;
* an error occurs while opening it.
*/
public class KeyDatabaseException extends java.lang.Exception {
private static final long serialVersionUID = 1L;
public KeyDatabaseException() {}
public KeyDatabaseException(String mesg) {
super(mesg);
......