Commit 4bfa5616 by Yonathan Carvajal

Initial commit

parents
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
../logs
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
2023-09-21 11:46:13 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-21 11:46:14 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-21 11:46:14 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-21 11:46:14 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-21 11:46:14 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
2023-09-21 11:46:59 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-21 11:46:59 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-21 11:46:59 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-21 11:46:59 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-21 11:46:59 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
2023-09-21 11:47:04 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-21 11:47:04 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-21 11:47:04 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-21 11:47:04 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-21 11:47:04 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
2023-09-20 12:36:16 ERROR TrustedServicio:151 - error consultando los certificados para el nuip: 1004683412 javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
2023-09-20 12:39:50 ERROR TrustedServicio:151 - error consultando los certificados para el nuip: 1004683412 javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
2023-09-20 13:25:11 ERROR TrustedServicio:151 - error consultando los certificados para el nuip: 1004683412 javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
2023-09-20 13:31:11 ERROR TrustedServicio:151 - error consultando los certificados para el nuip: 1004683412 javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
2023-09-20 13:35:53 ERROR TrustedServicio:151 - error consultando los certificados para el nuip: 1004683412 javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
2023-09-20 13:37:59 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-20 13:38:00 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-20 13:38:00 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-20 13:38:00 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-20 13:38:00 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
2023-09-20 13:38:09 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-20 13:38:09 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-20 13:38:09 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-20 13:38:09 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-20 13:38:09 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
2023-09-20 14:04:37 INFO SoapClienteServicio:66 - Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: 1004683412
2023-09-20 14:04:38 INFO SoapClienteServicio:51 - Inicia peticion SOAP para validar si exisite el usuario con el nuip: 1004683412
2023-09-20 14:04:39 INFO SoapClienteServicio:36 - Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: 1004683412
2023-09-20 14:04:39 INFO UtilsXML:30 - generando xml para el nuip: 1004683412
2023-09-20 14:04:39 INFO UtilsXML:79 - xml generado para el nuip: 1004683412
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.16-SNAPSHOT</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>co.com.certicamara</groupId>
<artifactId>ms-list-certificate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ms-list-certificate</name>
<description>Proyecto para listar certificados</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>
package co.com.certicamara;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MsListCertificateApplication {
public static void main(String[] args) {
SpringApplication.run(MsListCertificateApplication.class, args);
}
}
package co.com.certicamara.configuracion;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.client.RestTemplate;
@Configuration
public class configuracion {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
//solo activa para ambiente de desarrollo
@Bean
@Profile("development")
public HttpsURLConnection conexionSegura() {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
return null;
}
}
package co.com.certicamara.controlador;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import co.com.certicamara.dto.EntidadRespuestaError;
import co.com.certicamara.dto.EntidadSolicitudDto;
import co.com.certicamara.servicio.TrustedServicio;
@RestController
@RequestMapping("/certificate")
public class CertificadoControlador {
@Autowired
TrustedServicio trustedServicio;
@PostMapping("/list")
private Object listarCertificado(@RequestBody EntidadSolicitudDto entidad) {
try {
if (entidad.getNuip() != null && !entidad.getNuip().isEmpty()) {
String nuip = entidad.getNuip().trim();
entidad.setNuip(nuip);
return trustedServicio.listarCertificados(entidad);
} else {
return new EntidadRespuestaError("409", "El NUIP no puede estar vacio.", "Error en la peticion");
}
} catch (Exception e) {
return new EntidadRespuestaError("204", "error.", e.getMessage());
}
}
}
package co.com.certicamara.dto;
public class CertificadoDto {
private String cn;
private String o;
private String serialNumber;
private String ou;
private String serial;
private ValidezDto validity;
private String issuer;
public String getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
public String getO() {
return o;
}
public void setO(String o) {
this.o = o;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getOu() {
return ou;
}
public void setOu(String ou) {
this.ou = ou;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public ValidezDto getValidity() {
return validity;
}
public void setValidity(ValidezDto validity) {
this.validity = validity;
}
public String getIssuer() {
return issuer;
}
public void setIssuer(String issuer) {
this.issuer = issuer;
}
}
package co.com.certicamara.dto;
import java.util.List;
public class EntidadRespuesta {
private int code;
private String nuip;
private List<CertificadoDto> certificates;
public EntidadRespuesta() {
super();
}
public EntidadRespuesta(int code, String nuip, List<CertificadoDto> certificates) {
super();
this.code = code;
this.nuip = nuip;
this.certificates = certificates;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getNuip() {
return nuip;
}
public void setNuip(String nuip) {
this.nuip = nuip;
}
public List<CertificadoDto> getCertificates() {
return certificates;
}
public void setCertificates(List<CertificadoDto> certificates) {
this.certificates = certificates;
}
}
package co.com.certicamara.dto;
public class EntidadRespuestaError {
private String faultCode;
private String faultString;
private String errorMessage;
private String exception;
private int statusCode;
private String resultMajor;
private String resultMinor;
private String resultMessage;
public EntidadRespuestaError(String faultCode, String faultString, String errorMessage,
String exception, int statusCode, String resultMajor, String resultMinor, String resultMessage) {
this.faultCode = faultCode;
this.faultString = faultString;
this.errorMessage = errorMessage;
this.exception = exception;
this.statusCode = statusCode;
this.resultMajor = resultMajor;
this.resultMinor = resultMinor;
this.resultMessage = resultMessage;
}
// public EntidadRespuestaError(int statusCode, String errorMessage, String exception) {
// this(Integer.toString(statusCode), "", errorMessage, exception, statusCode, "", "", "");
// }
public EntidadRespuestaError(String faultCode, String faultString, String errorMessage) {
this.errorMessage = errorMessage;
this.faultCode = faultCode;
this.faultString = faultString;
}
// public EntidadRespuestaError(int statusCode, String resultMajor, String resultMinor, String resultMessage) {
// this(Integer.toString(statusCode), "", "", null, statusCode, resultMajor, resultMinor, resultMessage);
// }
public String getFaultCode() {
return faultCode;
}
public void setFaultCode(String faultCode) {
this.faultCode = faultCode;
}
public String getFaultString() {
return faultString;
}
public void setFaultString(String faultString) {
this.faultString = faultString;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public String getException() {
return exception;
}
public void setException(String exception) {
this.exception = exception;
}
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public String getResultMajor() {
return resultMajor;
}
public void setResultMajor(String resultMajor) {
this.resultMajor = resultMajor;
}
public String getResultMinor() {
return resultMinor;
}
public void setResultMinor(String resultMinor) {
this.resultMinor = resultMinor;
}
public String getResultMessage() {
return resultMessage;
}
public void setResultMessage(String resultMessage) {
this.resultMessage = resultMessage;
}
}
package co.com.certicamara.dto;
public class EntidadSolicitudDto {
private String nuip;
private String password;
public String getNuip() {
return nuip;
}
public void setNuip(String nuip) {
this.nuip = nuip;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package co.com.certicamara.dto;
public class ValidezDto {
private String notBefore;
private String notAfter;
public ValidezDto(String notBefore, String notAfter) {
this.notBefore = notBefore;
this.notAfter = notAfter;
}
public String getNotBefore() {
return notBefore;
}
public void setNotBefore(String notBefore) {
this.notBefore = notBefore;
}
public String getNotAfter() {
return notAfter;
}
public void setNotAfter(String notAfter) {
this.notAfter = notAfter;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class CNombreModelo {
@XmlElement(name = "Title")
private String titulo;
@XmlElement(name = "FName")
private String fNombre;
@XmlElement(name = "Surname")
private String surnombre;
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getfNombre() {
return fNombre;
}
public void setfNombre(String fNombre) {
this.fNombre = fNombre;
}
public String getSurnombre() {
return surnombre;
}
public void setSurnombre(String surnombre) {
this.surnombre = surnombre;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class CertificadosModelo {
@XmlElement(name = "Certificate")
private String[] certificados;
public String[] getCertificados() {
return certificados;
}
public void setCertificados(String[] certificado) {
this.certificados = certificado;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class ContactoModelo {
@XmlElement(name = "Work")
private TrabajoModelo trabajo;
public TrabajoModelo getTrabajo() {
return trabajo;
}
public void setTrabajo(TrabajoModelo trabajo) {
this.trabajo = trabajo;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class CuerpoModelo {
@XmlElement(name = "ReadResponse", namespace = "http://www.safelayer.com/TWS")
private RespuestaLecturaModelo respuestaLecturaModelo;
@XmlElement(name = "SearchResponse", namespace = "http://www.safelayer.com/TWS")
private RespuestaBusqueda searchResponse;
@XmlElement(name = "AuthNResponse", namespace = "http://www.safelayer.com/TWS")
private RespuestaAutenticacion authNResponse;
public RespuestaLecturaModelo getRespuestaLecturaModelo() {
return respuestaLecturaModelo;
}
public void setRespuestaLecturaModelo(RespuestaLecturaModelo respuestaLecturaModelo) {
this.respuestaLecturaModelo = respuestaLecturaModelo;
}
public RespuestaBusqueda getSearchResponse() {
return searchResponse;
}
public void setSearchResponse(RespuestaBusqueda searchResponse) {
this.searchResponse = searchResponse;
}
public RespuestaAutenticacion getAuthNResponse() {
return authNResponse;
}
public void setAuthNResponse(RespuestaAutenticacion authNResponse) {
this.authNResponse = authNResponse;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class DatosModelo {
@XmlElement(name = "User")
private UsuarioModelo usuario;
public UsuarioModelo getUsuario() {
return usuario;
}
public void setUsuario(UsuarioModelo usuario) {
this.usuario = usuario;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class ONombreModelo {
@XmlElement(name = "Title")
private String titulo;
@XmlElement(name = "O")
private String o;
@XmlElement(name = "OU")
private String ou;
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getO() {
return o;
}
public void setO(String o) {
this.o = o;
}
public String getOu() {
return ou;
}
public void setOu(String ou) {
this.ou = ou;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class RespuestaAutenticacion {
@XmlElement(name = "AssertionIDReference", namespace = "urn:oasis:names:tc:SAML:1.0:assertion")
private String iDReferencia;
public String getiDReferencia() {
return iDReferencia;
}
public void setiDReferencia(String iDReferencia) {
this.iDReferencia = iDReferencia;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class RespuestaBusqueda {
@XmlElement(name = "result", namespace = "http://www.safelayer.com/TWS")
private String resultado;
@XmlElement(name = "data", namespace = "http://www.safelayer.com/TWS")
private Boolean datos;
public String getResultado() {
return resultado;
}
public void setResultado(String resultado) {
this.resultado = resultado;
}
public Boolean getDatos() {
return datos;
}
public void setDatos(Boolean datos) {
this.datos = datos;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class RespuestaLecturaModelo {
@XmlElement(name = "result", namespace = "http://www.safelayer.com/TWS")
private String resultado;
@XmlElement(name = "totalElements", namespace = "http://www.safelayer.com/TWS")
private int totalElementos;
@XmlElement(name = "numElements", namespace = "http://www.safelayer.com/TWS")
private int numElementos;
@XmlElement(name = "startAt", namespace = "http://www.safelayer.com/TWS")
private int inicioAt;
@XmlElement(name = "endAt", namespace = "http://www.safelayer.com/TWS")
private int finAt;
@XmlElement(name = "end", namespace = "http://www.safelayer.com/TWS")
private boolean fin;
@XmlElement(name = "data", namespace = "http://www.safelayer.com/TWS")
private DatosModelo datos;
public String getResultado() {
return resultado;
}
public void setResultado(String resultado) {
this.resultado = resultado;
}
public int getTotalElementos() {
return totalElementos;
}
public void setTotalElementos(int totalElementos) {
this.totalElementos = totalElementos;
}
public int getNumElementos() {
return numElementos;
}
public void setNumElementos(int numElementos) {
this.numElementos = numElementos;
}
public int getInicioAt() {
return inicioAt;
}
public void setInicioAt(int inicioAt) {
this.inicioAt = inicioAt;
}
public int getFinAt() {
return finAt;
}
public void setFinAt(int finAt) {
this.finAt = finAt;
}
public boolean isFin() {
return fin;
}
public void setFin(boolean fin) {
this.fin = fin;
}
public DatosModelo getDatos() {
return datos;
}
public void setDatos(DatosModelo datos) {
this.datos = datos;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Envelope", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
public class RespuestaModelo {
@XmlElement(name = "Body", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
private CuerpoModelo body;
public CuerpoModelo getBody() {
return body;
}
public void setBody(CuerpoModelo body) {
this.body = body;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class SNombreModelo {
@XmlElement(name = "UID")
private String uid;
@XmlElement(name = "Passwd")
private String contrasena;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getContrasena() {
return contrasena;
}
public void setContrasena(String contrasena) {
this.contrasena = contrasena;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class TrabajoModelo {
@XmlElement(name = "Mail")
private String correo;
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
}
package co.com.certicamara.modelos;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlAccessorType(XmlAccessType.FIELD)
public class UsuarioModelo {
@XmlElement(name = "Description")
private String descripcion;
@XmlElement(name = "CName")
private CNombreModelo cNombre;
@XmlElement(name = "OName")
private ONombreModelo oNombre;
@XmlElement(name = "SName")
private SNombreModelo sNombre;
@XmlElement(name = "Language")
private String lenguage;
@XmlElement(name = "Certificates")
private CertificadosModelo certificados;
@XmlElement(name = "Contacts")
private ContactoModelo contacto;
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public CNombreModelo getcNombre() {
return cNombre;
}
public void setcNombre(CNombreModelo cNombre) {
this.cNombre = cNombre;
}
public ONombreModelo getoNombre() {
return oNombre;
}
public void setoNombre(ONombreModelo oNombre) {
this.oNombre = oNombre;
}
public SNombreModelo getsNombre() {
return sNombre;
}
public void setsNombre(SNombreModelo sNombre) {
this.sNombre = sNombre;
}
public String getLenguage() {
return lenguage;
}
public void setLenguage(String lenguage) {
this.lenguage = lenguage;
}
public CertificadosModelo getCertificados() {
return certificados;
}
public void setCertificados(CertificadosModelo certificados) {
this.certificados = certificados;
}
public ContactoModelo getContacto() {
return contacto;
}
public void setContacto(ContactoModelo contacto) {
this.contacto = contacto;
}
}
package co.com.certicamara.servicio;
import org.springframework.stereotype.Service;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpEntity;
import org.springframework.web.client.RestTemplate;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import co.com.certicamara.dto.EntidadSolicitudDto;
import co.com.certicamara.utils.UtilsXML;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
@Service
public class SoapClienteServicio {
private final Logger logger = Logger.getLogger(this.getClass());
@Value("${HOST_TRUSTED}")
private String host;
@Autowired
private RestTemplate restTemplate;
@Autowired
private UtilsXML utilsXML;
public ResponseEntity<String> listarCertificados(EntidadSolicitudDto entidad) throws Exception {
logger.info("Inicia peticion SOAP para listar certificados en el TrustedX con el nuip: " + entidad.getNuip());
try {
String xmlRequestBody = utilsXML.generarSoapCertificados(entidad.getNuip(), entidad.getPassword(),
entidad.getNuip());
HttpHeaders headers = new HttpHeaders();
headers.set("SOAPAction", "Read");
headers.set("TwsAuthN", "urn:safelayer:tws:policies:authentication:default:firmadigital");
return enviarPeticion(xmlRequestBody, headers);
} catch (Exception e) {
logger.error("error haciendo la peticion al servicio trusted");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error: " + e.getMessage());
}
}
public ResponseEntity<String> validarUsuario(EntidadSolicitudDto entidad) throws Exception {
logger.info("Inicia peticion SOAP para validar si exisite el usuario con el nuip: " + entidad.getNuip());
try {
String xmlRequestBody = utilsXML.generarSoapValidarUsuario(entidad.getNuip(), entidad.getPassword(),
entidad.getNuip());
HttpHeaders headers = new HttpHeaders();
headers.set("SOAPAction", "Search");
headers.set("TwsAuthN", "urn:safelayer:tws:policies:authentication:default:firmadigital");
return enviarPeticion(xmlRequestBody, headers);
} catch (Exception e) {
logger.error("error haciendo la peticion al servicio trusted");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error: " + e.getMessage());
}
}
public ResponseEntity<String> validarAutenticacion(EntidadSolicitudDto entidad) throws Exception {
logger.info("Inicia peticion SOAP para validar autenticacion al TrustedX con el nuip: " + entidad.getNuip());
try {
String xmlRequestBody = utilsXML.generarSoapValidarAutenticacion(entidad.getNuip(), entidad.getPassword());
HttpHeaders headers = new HttpHeaders();
headers.set("SOAPAction", "AuthN");
headers.set("TwsAuthN", "urn:safelayer:tws:policies:authentication:usersconfig");
return enviarPeticion(xmlRequestBody, headers);
} catch (Exception e) {
logger.error("error haciendo la peticion al servicio trusted");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error: " + e.getMessage());
}
}
private ResponseEntity<String> enviarPeticion(String xmlRequestBody, HttpHeaders headers) throws Exception {
try {
StringBuilder buf = new StringBuilder();
buf.append(xmlRequestBody);
byte[] outs = buf.toString().getBytes();
headers.set("Content-Type", "text/xml;charset=UTF-8");
headers.set("Accept-Encoding", "gzip,deflate");
headers.set("Content-Length", String.valueOf(outs.length));
headers.set("Connection", "Keep-Alive");
HttpEntity<String> requestEntity = new HttpEntity<>(xmlRequestBody, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(host, HttpMethod.POST, requestEntity,
String.class);
return responseEntity;
} catch (Exception e) {
logger.error("fallo la consulta al servidor de trustedx " + e);
throw new Exception("fallo la consulta al servidor de trustedx " + e.getMessage());
}
}
}
package co.com.certicamara.servicio;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import co.com.certicamara.dto.CertificadoDto;
import co.com.certicamara.dto.EntidadRespuesta;
import co.com.certicamara.dto.EntidadRespuestaError;
import co.com.certicamara.dto.EntidadSolicitudDto;
import co.com.certicamara.dto.ValidezDto;
import co.com.certicamara.modelos.RespuestaModelo;
import co.com.certicamara.utils.Constantes;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import org.apache.commons.codec.binary.Base64;
import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.security.Principal;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class TrustedServicio {
private final Logger logger = Logger.getLogger(this.getClass());
@Autowired
private SoapClienteServicio soapClienteServicio;
public Object listarCertificados(EntidadSolicitudDto entidad) {
try {
JAXBContext context = JAXBContext.newInstance(RespuestaModelo.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
try {
ResponseEntity<String> credenciales = soapClienteServicio.validarAutenticacion(entidad);
RespuestaModelo respuesta = (RespuestaModelo) unmarshaller
.unmarshal(new StringReader(credenciales.getBody()));
if (!respuesta.getBody().getAuthNResponse().getiDReferencia()
.equals(Constantes.AUTENTICACION_iNVALID)) {
ResponseEntity<String> usuarioValidado = soapClienteServicio.validarUsuario(entidad);
respuesta = (RespuestaModelo) unmarshaller.unmarshal(new StringReader(usuarioValidado.getBody()));
if (respuesta.getBody().getSearchResponse().getDatos()) {
ResponseEntity<String> listacertificado = soapClienteServicio.listarCertificados(entidad);
respuesta = (RespuestaModelo) unmarshaller.unmarshal(new StringReader(listacertificado.getBody()));
if (respuesta.getBody().getRespuestaLecturaModelo().getResultado()
.equals(Constantes.SUCCESS_LECTURA)) {
if (respuesta.getBody().getRespuestaLecturaModelo().getNumElementos() > 0
&& respuesta.getBody().getRespuestaLecturaModelo().isFin()) {
String[] certificados = respuesta.getBody().getRespuestaLecturaModelo().getDatos()
.getUsuario().getCertificados().getCertificados();
List<CertificadoDto> certificadosNuevos = new ArrayList<CertificadoDto>();
for (String certificado : certificados) {
byte[] certificadoBytes = Base64.decodeBase64(certificado);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate x509Certificado = (X509Certificate) certificateFactory
.generateCertificate(new ByteArrayInputStream(certificadoBytes));
// setear las fechas de la validéz del certificado
Date antes = x509Certificado.getNotBefore();
Date despues = x509Certificado.getNotAfter();
Date ahora = new Date();
if (ahora.before(despues)) {
BigInteger serial = x509Certificado.getSerialNumber();
Principal sujeto = x509Certificado.getSubjectDN();
CertificadoDto nuevoCertificado = new CertificadoDto();
SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy");
String antesF = formatDate.format(antes);
String despuesF = formatDate.format(despues);
ValidezDto validity = new ValidezDto(antesF, despuesF);
String issuer = x509Certificado.getIssuerX500Principal().getName();
nuevoCertificado.setValidity(validity);
nuevoCertificado.setIssuer(issuer);
nuevoCertificado.setSerial(serial.toString());
Map<String, String> subjectInfoMap = obetnerInformacionCertificado(
sujeto.getName());
for (Map.Entry<String, String> entry : subjectInfoMap.entrySet()) {
switch (entry.getKey()) {
case "CN":
nuevoCertificado.setCn(entry.getValue());
break;
case "O":
nuevoCertificado.setO(entry.getValue());
break;
case "SERIALNUMBER":
nuevoCertificado.setSerialNumber(entry.getValue());
break;
case "OU":
nuevoCertificado.setOu(entry.getValue());
break;
default:
break;
}
}
certificadosNuevos.add(nuevoCertificado);
}
}
EntidadRespuesta entidadRespuesta = new EntidadRespuesta(200, entidad.getNuip(),
certificadosNuevos);
return entidadRespuesta;
} else {
EntidadRespuestaError error = new EntidadRespuestaError("500",
"No se han encontrado resultados",
"No se han encontrado resultados nuip: " + entidad.getNuip());
return error;
}
}
} else {
EntidadRespuestaError error = new EntidadRespuestaError("403", "Usuario no registrado",
"El usuario: " + entidad.getNuip() + ", no se encuentra registrado en el sistema.");
return error;
}
} else {
EntidadRespuestaError error = new EntidadRespuestaError("401", "Credenciales incorrectas",
"Las credenciales ingresadas no son válidas para el usuario: " + entidad.getNuip());
return error;
}
} catch (Exception e) {
logger.error("Error con las credenciales del Trusted para nuip: " + entidad.getNuip() + " " + e);
EntidadRespuestaError error = new EntidadRespuestaError("401", "Error con las credenciales del Trusted",
"Por favor validar las credenciales del Trusted, que no esten siendo usuadas por otra direccion IP.");
return error;
}
} catch (Exception e) {
logger.error("error consultando los certificados para el nuip: " + entidad.getNuip() + " " + e);
}
return null;
}
private Map<String, String> obetnerInformacionCertificado(String x500Name) {
Map<String, String> map = new HashMap<>();
String[] components = x500Name.split(",");
for (String component : components) {
String[] keyValue = component.trim().split("=");
if (keyValue.length == 2) {
map.put(keyValue[0], keyValue[1]);
}
}
return map;
}
}
package co.com.certicamara.utils;
public class Constantes {
public static final String SUCCESS_LECTURA = "success";
public static final String AUTENTICACION_iNVALID = "AaApiException.incorrectCredentials";
}
package co.com.certicamara.utils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
@Component
public class UtilsXML {
private final Logger logger = Logger.getLogger(this.getClass());
public String generarSoapCertificados(String username, String password, String nuip)
throws ParserConfigurationException {
logger.info("generando xml para el nuip: " + nuip);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element envelope = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Envelope");
envelope.setAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
envelope.setAttribute("xmlns:tws", "http://www.safelayer.com/TWS");
doc.appendChild(envelope);
Element header = doc.createElement("soapenv:Header");
envelope.appendChild(header);
Element security = doc.createElement("wsse:Security");
security.setAttribute("xmlns:wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
security.setAttribute("soapenv:actor", "http://schemas.xmlsoap.org/soap/actor/next");
security.setAttribute("soapenv:mustUnderstand", "1");
header.appendChild(security);
Element usernameToken = doc.createElement("wsse:UsernameToken");
security.appendChild(usernameToken);
Element usernameElem = doc.createElement("wsse:Username");
usernameElem.appendChild(doc.createTextNode(username));
usernameToken.appendChild(usernameElem);
Element passwordElem = doc.createElement("wsse:Password");
passwordElem.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
passwordElem.appendChild(doc.createTextNode(password));
usernameToken.appendChild(passwordElem);
Element body = doc.createElement("soapenv:Body");
envelope.appendChild(body);
Element readRequest = doc.createElement("tws:ReadRequest");
readRequest.setAttribute("xpath", "/TWS/EP/PU/User[SName/UID='" + nuip + "']");
Element startAt = doc.createElement("tws:startAt");
startAt.appendChild(doc.createTextNode("1"));
readRequest.appendChild(startAt);
Element nextElements = doc.createElement("tws:nextElements");
nextElements.appendChild(doc.createTextNode("100"));
readRequest.appendChild(nextElements);
body.appendChild(readRequest);
logger.info("xml generado para el nuip: " + nuip);
return documentoToString(doc);
}
public String generarSoapValidarUsuario(String username, String password, String nuip)
throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element envelope = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Envelope");
envelope.setAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
envelope.setAttribute("xmlns:tws", "http://www.safelayer.com/TWS");
doc.appendChild(envelope);
Element header = doc.createElement("soapenv:Header");
envelope.appendChild(header);
Element security = doc.createElement("wsse:Security");
security.setAttribute("xmlns:wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
security.setAttribute("soapenv:actor", "http://schemas.xmlsoap.org/soap/actor/next");
security.setAttribute("soapenv:mustUnderstand", "1");
header.appendChild(security);
Element usernameToken = doc.createElement("wsse:UsernameToken");
security.appendChild(usernameToken);
Element usernameElem = doc.createElement("wsse:Username");
usernameElem.appendChild(doc.createTextNode(username));
usernameToken.appendChild(usernameElem);
Element passwordElem = doc.createElement("wsse:Password");
passwordElem.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
passwordElem.appendChild(doc.createTextNode(password));
usernameToken.appendChild(passwordElem);
Element body = doc.createElement("soapenv:Body");
envelope.appendChild(body);
Element searchRequest = doc.createElement("tws:SearchRequest");
searchRequest.setAttribute("xpath", "/TWS/EP/PU/User[SName/UID='" + nuip + "']");
body.appendChild(searchRequest);
return documentoToString(doc);
}
public String generarSoapValidarAutenticacion(String username, String password)
throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Element envelope = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "SOAP-ENV:Envelope");
envelope.setAttribute("xmlns:SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
doc.appendChild(envelope);
Element header = doc.createElement("SOAP-ENV:Header");
envelope.appendChild(header);
Element security = doc.createElement("wsse:Security");
security.setAttribute("xmlns:wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
security.setAttribute("xmlns:wsu",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
header.appendChild(security);
Element usernameToken = doc.createElement("wsse:UsernameToken");
usernameToken.setAttribute("wsu:Id", "SecurityToken-VR0lBBYwFAYIKwYBB");
security.appendChild(usernameToken);
Element usernameElem = doc.createElement("wsse:Username");
usernameElem.appendChild(doc.createTextNode(username));
usernameToken.appendChild(usernameElem);
Element passwordElem = doc.createElement("wsse:Password");
passwordElem.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
passwordElem.appendChild(doc.createTextNode(password));
usernameToken.appendChild(passwordElem);
Element body = doc.createElement("SOAP-ENV:Body");
envelope.appendChild(body);
Element authNRequest = doc.createElement("AuthNRequest");
body.appendChild(authNRequest);
Element direct = doc.createElement("direct");
authNRequest.appendChild(direct);
Element authPolicy = doc.createElement("tws:authPolicy");
authPolicy.appendChild(doc.createTextNode("urn:safelayer:tws:policies:authentication:default:firmadigital"));
direct.appendChild(authPolicy);
Element respondWith = doc.createElement("respondWith");
respondWith.appendChild(doc.createTextNode("saml:AssertionIDReference"));
direct.appendChild(respondWith);
return documentoToString(doc);
}
private String documentoToString(Document doc) {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty("indent", "yes");
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
DOMSource source = new DOMSource(doc);
transformer.transform(source, result);
return writer.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
project.name = ms-list-certificate
spring.application.name = ${project.name}
spring.http.encoding.charset = UTF-8
spring.http.encoding.enabled = true
server.port = ${PUERTO}
spring.profiles.active=${ENV}
#spring.profiles.active=development
\ No newline at end of file
# Root logger option
log4j.rootLogger=INFO, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.File=../logs/ms_list_certificate.log
>>>>>>> logs
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
package co.com.certicamara;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MsListCertificateApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment