Skip to content

Commit

Permalink
Merge pull request #18211 from hwupathum/master
Browse files Browse the repository at this point in the history
Update bouncycastle artifactID in FIPS compliance scripts
  • Loading branch information
hwupathum authored Nov 30, 2023
2 parents 4b770a8 + f44604e commit fc68a11
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
56 changes: 28 additions & 28 deletions modules/distribution/src/bin/fips.bat
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ if exist "%CARBON_HOME%\repository\components\dropins\bcpkix_fips*.jar" (
echo Successfully removed bcpkix-fips_%BCPKIX_FIPS_VERSION%.jar from components\dropins.
)

if not exist "%CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar" (
if not exist "%CARBON_HOME%\repository\components\plugins\bcprov-jdk18on*.jar" (
set server_restart_required=true
if exist "%homeDir%\.wso2-bc\backup\bcprov-jdk15on*.jar" (
for /r %homeDir%\.wso2-bc\backup\ %%G in (bcprov-jdk15on*.jar) do (
if exist "%homeDir%\.wso2-bc\backup\bcprov-jdk18on*.jar" (
for /r %homeDir%\.wso2-bc\backup\ %%G in (bcprov-jdk18on*.jar) do (
set bcprov_location=%%G
set file_name=%%~nG
goto checkbcprovVersion
Expand All @@ -88,13 +88,13 @@ if not exist "%CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar" (
:bbb
move "%bcprov_location%" "%CARBON_HOME%\repository\components\plugins"
echo Moved %bcprov_file_name% from %homeDir%\.wso2-bc\backup to components/plugins.
) else ( echo "Required bcprov-jdk15on jar is not available in %homeDir%/.wso2-bc/backup. Download the jar from maven central repository." )
) else ( echo "Required bcprov-jdk18on jar is not available in %homeDir%/.wso2-bc/backup. Download the jar from maven central repository." )
)

if not exist "%CARBON_HOME%\repository\components\plugins\bcpkix-jdk15on*.jar" (
if not exist "%CARBON_HOME%\repository\components\plugins\bcpkix-jdk18on*.jar" (
set server_restart_required=true
if exist "%homeDir%\.wso2-bc\backup\bcpkix-jdk15on*.jar" (
for /r %homeDir%\.wso2-bc\backup\ %%G in (bcpkix-jdk15on*.jar) do (
if exist "%homeDir%\.wso2-bc\backup\bcpkix-jdk18on*.jar" (
for /r %homeDir%\.wso2-bc\backup\ %%G in (bcpkix-jdk18on*.jar) do (
set bcpkix_location=%%G
set bcpkix_file_name=%%~nG
set verify=false
Expand All @@ -107,7 +107,7 @@ if not exist "%CARBON_HOME%\repository\components\plugins\bcpkix-jdk15on*.jar" (
:bbb
move "%bcpkix_location%" "%CARBON_HOME%\repository\components\plugins"
echo Moved %bcpkix_file_name% from %homeDir%\.wso2-bc\backup to components/plugins.
) else ( echo "Required bcpkix-jdk15on jar is not available in %homeDir%/.wso2-bc/backup. Download the jar from maven central repository." )
) else ( echo "Required bcpkix-jdk18on jar is not available in %homeDir%/.wso2-bc/backup. Download the jar from maven central repository." )
)

findstr /c:%bcprov_text% %bundles_info% > nul
Expand Down Expand Up @@ -140,9 +140,9 @@ if not exist "%homeDir%\.wso2-bc\backup" (
mkdir "%homeDir%\.wso2-bc\backup"
)

if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar (
if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk18on*.jar (
set server_restart_required=true
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcprov-jdk15on*.jar) do (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcprov-jdk18on*.jar) do (
set bcprov_location=%%G
set bcprov_file_name=%%~nG
goto checkBcVersion
Expand All @@ -152,17 +152,17 @@ if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar (
goto removeBcProv

:removeBcProv
echo Remove existing bcprov-jdk15on jar from plugins folder.
if exist "%homeDir%\.wso2-bc\backup\bcprov-jdk15on*.jar" (
DEL /F "%homeDir%\.wso2-bc\backup\bcprov-jdk15on*.jar"
echo Remove existing bcprov-jdk18on jar from plugins folder.
if exist "%homeDir%\.wso2-bc\backup\bcprov-jdk18on*.jar" (
DEL /F "%homeDir%\.wso2-bc\backup\bcprov-jdk18on*.jar"
)
move "%bcprov_location%" "%homeDir%\.wso2-bc\backup"
echo Successfully removed %bcprov_file_name% from components\plugins.
)

if exist %CARBON_HOME%\repository\components\plugins\bcpkix-jdk15on*.jar (
if exist %CARBON_HOME%\repository\components\plugins\bcpkix-jdk18on*.jar (
set server_restart_required=true
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcpkix-jdk15on*.jar) do (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcpkix-jdk18on*.jar) do (
set bcpkix_location=%%G
set bcpkix_file_name=%%~nG
goto checkBcpkixVersion
Expand All @@ -172,9 +172,9 @@ if exist %CARBON_HOME%\repository\components\plugins\bcpkix-jdk15on*.jar (
goto removeBcPkix

:removeBcPkix
echo Remove existing bcpkix-jdk15on jar from plugins folder.
if exist "%homeDir%\.wso2-bc\backup\bcpkix-jdk15on*.jar" (
DEL /F "%homeDir%\.wso2-bc\backup\bcpkix-jdk15on*.jar"
echo Remove existing bcpkix-jdk18on jar from plugins folder.
if exist "%homeDir%\.wso2-bc\backup\bcpkix-jdk18on*.jar" (
DEL /F "%homeDir%\.wso2-bc\backup\bcpkix-jdk18on*.jar"
)
move "%bcpkix_location%" "%homeDir%\.wso2-bc\backup"
echo Successfully removed %bcpkix_file_name% from components\plugins.
Expand Down Expand Up @@ -292,8 +292,8 @@ if not exist "%CARBON_HOME%\repository\components\lib\bcpkix-fips*.jar" (
)
)
)
set bcprov_text=bcprov-jdk15on,%bcprov_version%,../plugins/bcprov-jdk15on_%bcprov_version%.jar,4,true
set bcpkix_text=bcpkix-jdk15on,%bcpkix_version%,../plugins/bcpkix-jdk15on_%bcpkix_version%.jar,4,true
set bcprov_text=bcprov-jdk18on,%bcprov_version%,../plugins/bcprov-jdk18on_%bcprov_version%.jar,4,true
set bcpkix_text=bcpkix-jdk18on,%bcpkix_version%,../plugins/bcpkix-jdk18on_%bcpkix_version%.jar,4,true

set temp_file=%CARBON_HOME%\repository\components\default\configuration\org.eclipse.equinox.simpleconfigurator\temp.info
findstr /v /c:%bcprov_text% /c:%bcpkix_text% %bundles_info% > !temp_file!
Expand All @@ -302,8 +302,8 @@ goto printRestartMsg

:verifyFipsMode
set verify=true
if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcprov-jdk15on*.jar) do (
if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk18on*.jar (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcprov-jdk18on*.jar) do (
set bc_location=%%G
set file_name=%%~nG
set verify=false
Expand All @@ -313,8 +313,8 @@ if exist %CARBON_HOME%\repository\components\plugins\bcprov-jdk15on*.jar (
echo Found %file_name% in plugins folder. This jar should be removed.
)

if exist %CARBON_HOME%\repository\components\plugins\bcpkix-jdk15on*.jar (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcpkix-jdk15on*.jar) do (
if exist %CARBON_HOME%\repository\components\plugins\bcpkix-jdk18on*.jar (
for /r %CARBON_HOME%\repository\components\plugins\ %%G in (bcpkix-jdk18on*.jar) do (
set bcpkix_location=%%G
set file_name=%%~nG
set verify=false
Expand Down Expand Up @@ -344,16 +344,16 @@ if exist "%CARBON_HOME%\repository\components\lib\bcpkix-fips*.jar" (
echo can not be found bc-fips_%BC_FIPS_VERSION%.jar in components/lib folder. This jar should be added.
)

findstr /i /c:"bcprov-jdk15on" "%bundles_info%" >nul
findstr /i /c:"bcprov-jdk18on" "%bundles_info%" >nul
if %errorlevel%==0 (
set verify=false
echo Found bcprov-jdk15on entry in bundles.info. This should be removed.
echo Found bcprov-jdk18on entry in bundles.info. This should be removed.
)

findstr /i /c:"bcpkix-jdk15on" "%bundles_info%" >nul
findstr /i /c:"bcpkix-jdk18on" "%bundles_info%" >nul
if %errorlevel%==0 (
set verify=false
echo Found bcpkix-jdk15on entry in bundles.info. This should be removed.
echo Found bcpkix-jdk18on entry in bundles.info. This should be removed.
)
if "%verify%"=="true" (
echo Verified : Product is FIPS compliant.
Expand Down
64 changes: 32 additions & 32 deletions modules/distribution/src/bin/fips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,35 @@ if [ "$ARGUMENT" = "DISABLE" ] || [ "$ARGUMENT" = "disable" ]; then
rm rm $CARBON_HOME/repository/components/dropins/bcpkix_fips*.jar 2> /dev/null
echo "Successfully removed bcpkix_fips_$BCPKIX_FIPS_VERSION.jar from component/dropins."
fi
if [ ! -e $CARBON_HOME/repository/components/plugins/bcprov-jdk15on*.jar ]; then
if [ ! -e $CARBON_HOME/repository/components/plugins/bcprov-jdk18on*.jar ]; then
sever_restart_required=true
if [ -e $homeDir/.wso2-bc/backup/bcprov-jdk15on*.jar ]; then
location=$(find "$homeDir/.wso2-bc/backup/" -type f -name "bcprov-jdk15on*.jar" | head -1)
if [ -e $homeDir/.wso2-bc/backup/bcprov-jdk18on*.jar ]; then
location=$(find "$homeDir/.wso2-bc/backup/" -type f -name "bcprov-jdk18on*.jar" | head -1)
bcprov_file_name=$(basename "$location")
bcprov_version=${bcprov_file_name#*_}
bcprov_version=${bcprov_version%.jar}
mv "$location" "$CARBON_HOME/repository/components/plugins"
echo "Moved $bcprov_file_name from $homeDir/.wso2-bc/backup to components/plugins."
else
echo "Required bcprov-jdk15on jar is not available in $homeDir/.wso2-bc/backup. Download the jar from maven central repository."
echo "Required bcprov-jdk18on jar is not available in $homeDir/.wso2-bc/backup. Download the jar from maven central repository."
fi
fi
if [ ! -e $CARBON_HOME/repository/components/plugins/bcpkix-jdk15on*.jar ]; then
if [ ! -e $CARBON_HOME/repository/components/plugins/bcpkix-jdk18on*.jar ]; then
sever_restart_required=true
if [ -e $homeDir/.wso2-bc/backup/bcpkix-jdk15on*.jar ]; then
location=$(find "$homeDir/.wso2-bc/backup/" -type f -name "bcpkix-jdk15on*.jar" | head -1)
if [ -e $homeDir/.wso2-bc/backup/bcpkix-jdk18on*.jar ]; then
location=$(find "$homeDir/.wso2-bc/backup/" -type f -name "bcpkix-jdk18on*.jar" | head -1)
bcpkix_file_name=$(basename "$location")
bcpkix_version=${bcpkix_file_name#*_}
bcpkix_version=${bcpkix_version%.jar}
mv "$location" "$CARBON_HOME/repository/components/plugins"
echo "Moved $bcpkix_file_name from $homeDir/.wso2-bc/backup to components/plugins."
else
echo "Required bcpkix-jdk15on jar is not available in $homeDir/.wso2-bc/backup. Download the jar from maven central repository."
echo "Required bcpkix-jdk18on jar is not available in $homeDir/.wso2-bc/backup. Download the jar from maven central repository."
fi
fi

bcprov_text="bcprov-jdk15on,$bcprov_version,../plugins/$bcprov_file_name,4,true";
bcpkix_text="bcpkix-jdk15on,$bcpkix_version,../plugins/$bcpkix_file_name,4,true";
bcprov_text="bcprov-jdk18on,$bcprov_version,../plugins/$bcprov_file_name,4,true";
bcpkix_text="bcpkix-jdk18on,$bcpkix_version,../plugins/$bcpkix_file_name,4,true";
if ! grep -q "$bcprov_text" "$bundles_info" ; then
echo $bcprov_text >> $bundles_info;
sever_restart_required=true
Expand All @@ -96,14 +96,14 @@ if [ "$ARGUMENT" = "DISABLE" ] || [ "$ARGUMENT" = "disable" ]; then

elif [ "$ARGUMENT" = "VERIFY" ] || [ "$ARGUMENT" = "verify" ]; then
verify=true;
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk15on*.jar ]; then
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcprov-jdk15on*.jar" | head -1)
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk18on*.jar ]; then
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcprov-jdk18on*.jar" | head -1)
file_name=$(basename "$location")
verify=false
echo "Found $file_name in plugins folder. This jar should be removed."
fi
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk15on*.jar ]; then
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcpkix-jdk15on*.jar" | head -1)
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk18on*.jar ]; then
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcpkix-jdk18on*.jar" | head -1)
file_name=$(basename "$location")
verify=false
echo "Found $file_name in plugins folder. This jar should be removed."
Expand All @@ -128,14 +128,14 @@ elif [ "$ARGUMENT" = "VERIFY" ] || [ "$ARGUMENT" = "verify" ]; then
echo "Can not be found bcpkix-fips_$BCPKIX_FIPS_VERSION.jar in components/lib folder. This jar should be added."

fi
if grep -q "bcprov-jdk15on" "$bundles_info" ; then
if grep -q "bcprov-jdk18on" "$bundles_info" ; then
verify=false
echo "Found bcprov-jdk15on entry in bundles.info. This should be removed.";
echo "Found bcprov-jdk18on entry in bundles.info. This should be removed.";

fi
if grep -q "bcpkix-jdk15on" "$bundles_info" ; then
if grep -q "bcpkix-jdk18on" "$bundles_info" ; then
verify=false
echo "Found bcpkix-jdk15on entry in bundles.info. This should be removed.";
echo "Found bcpkix-jdk18on entry in bundles.info. This should be removed.";
fi

if [ $verify = true ]; then
Expand Down Expand Up @@ -165,38 +165,38 @@ while getopts "f:m:" opt; do
if [ ! -d "$homeDir/.wso2-bc/backup" ]; then
mkdir "$homeDir/.wso2-bc/backup"
fi
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk15on*.jar ]; then
if [ -f $CARBON_HOME/repository/components/plugins/bcprov-jdk18on*.jar ]; then
sever_restart_required=true
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcprov-jdk15on*.jar" | head -1)
echo "Remove existing bcprov-jdk15on jar from plugins folder."
if [ -f $homeDir/.wso2-bc/backup/bcprov-jdk15on*.jar ]; then
rm $homeDir/.wso2-bc/backup/bcprov-jdk15on*.jar
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcprov-jdk18on*.jar" | head -1)
echo "Remove existing bcprov-jdk18on jar from plugins folder."
if [ -f $homeDir/.wso2-bc/backup/bcprov-jdk18on*.jar ]; then
rm $homeDir/.wso2-bc/backup/bcprov-jdk18on*.jar
fi
mv "$location" "$homeDir/.wso2-bc/backup"
bcprov_file_name=$(basename "$location")
bcprov_version=${file_name#*_}
bcprov_version=${bcprov_version%.jar}
echo "Successfully removed $bcprov_file_name from component/plugins."
fi
if [ -f $CARBON_HOME/repository/components/plugins/bcpkix-jdk15on*.jar ]; then
if [ -f $CARBON_HOME/repository/components/plugins/bcpkix-jdk18on*.jar ]; then
sever_restart_required=true
echo "Remove existing bcpkix-jdk15on jar from plugins folder."
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcpkix-jdk15on*.jar" | head -1)
if [ -f $homeDir/.wso2-bc/backup/bcpkix-jdk15on*.jar ]; then
rm $homeDir/.wso2-bc/backup/bcpkix-jdk15on*.jar
echo "Remove existing bcpkix-jdk18on jar from plugins folder."
location=$(find "$CARBON_HOME/repository/components/plugins/" -type f -name "bcpkix-jdk18on*.jar" | head -1)
if [ -f $homeDir/.wso2-bc/backup/bcpkix-jdk18on*.jar ]; then
rm $homeDir/.wso2-bc/backup/bcpkix-jdk18on*.jar
fi
mv "$location" "$homeDir/.wso2-bc/backup"
bcpkix_file_name=$(basename "$location")
echo "Successfully removed $bcpkix_file_name from component/plugins."
fi

if grep -q "bcprov-jdk15on" "$bundles_info"; then
if grep -q "bcprov-jdk18on" "$bundles_info"; then
sever_restart_required=true
perl -i -ne 'print unless /bcprov-jdk15on/' $bundles_info
perl -i -ne 'print unless /bcprov-jdk18on/' $bundles_info
fi
if grep -q "bcpkix-jdk15on" "$bundles_info"; then
if grep -q "bcpkix-jdk18on" "$bundles_info"; then
sever_restart_required=true
perl -i -ne 'print unless /bcpkix-jdk15on/' $bundles_info
perl -i -ne 'print unless /bcpkix-jdk18on/' $bundles_info
fi

if [ -e $CARBON_HOME/repository/components/lib/bc-fips*.jar ]; then
Expand Down

0 comments on commit fc68a11

Please sign in to comment.