Class CMSServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.netscape.cms.servlet.base.CMSServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
- Direct Known Subclasses:
CheckIdentity, CloneServlet, ConnectorServlet, DirAuthServlet, DisableEnrollResult, DisplayHashUserEnroll, DisplayHtmlServlet, DownloadPKCS12, DynamicVariablesServlet, EnableEnrollResult, GetConfigEntries, GetCookie, GetOCSPInfo, GetStats, GetStatus, IndexServlet, MainPageServlet, OCSPServlet, PortsServlet, ProcessReq, QueryReq, RegisterUser, RemoteAuthConfig, SearchReqs, TokenAuthenticate, UpdateDomainXML, UpdateNumberRange
public abstract class CMSServlet
extends jakarta.servlet.http.HttpServlet
This is the base class of all CS servlet.
- Version:
- $Revision$, $Date$
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic Stringhandy routine to check if client want full enrollment responseprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic org.slf4j.Loggerprotected Stringprotected Stringprotected IAuthorityprotected AuthzSubsystemprotected Stringprotected ConfigStoreprotected Stringprotected Stringprotected Stringprotected Stringprotected booleanprotected RequestQueueprotected Hashtable<Integer, CMSLoadTemplate> protected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected RequestRepositoryprotected jakarta.servlet.ServletConfigprotected jakarta.servlet.ServletContextstatic final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final StringFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringSigned Audit Log Group ID This method is inherited by all extended "CMSServlet"s, and is called to obtain the "gid" for a signed audit log message.protected StringSigned Audit Log Subject ID This method is inherited by all extended "CMSServlet"s, and is called to obtain the "SubjectID" for a signed audit log message.authenticate(CMSRequest req) authenticate(CMSRequest req, String authMgrName) authenticate(jakarta.servlet.http.HttpServletRequest httpReq) authenticate(jakarta.servlet.http.HttpServletRequest httpReq, String authMgrName) AuthenticationAuthorize must occur after Authenticatestatic booleanclientIsMSIE(jakarta.servlet.http.HttpServletRequest httpReq) handy routine to check if client is msie based on user-agent.static booleanclientIsNav(jakarta.servlet.http.HttpServletRequest httpReq) handy routine to check if client is navigator based on user-agent.protected static booleanconnectionIsSSL(jakarta.servlet.http.HttpServletRequest httpReq) static booleandoCMMFResponse(ArgBlock httpParams) static booleandoFullResponse(ArgBlock httpParams) protected org.mozilla.jss.netscape.security.x509.RevokedCertImplformCRLEntry(BigInteger serialNo, org.mozilla.jss.netscape.security.x509.RevocationReason reason) make a CRL entry from a serial number and revocation reason.static AuthCredentialsgetAuthCreds(AuthManager authMgr, ArgBlock argBlock, X509Certificate clientCert) construct a authentication credentials to pass into authentication manager.protected AuthTokengetAuthToken(Request req) protected voidgetDontSaveHttpParams(jakarta.servlet.ServletConfig sc) get http parameters not to save from configuration.getId()static FilegetLangFile(jakarta.servlet.http.HttpServletRequest req, File realpathFile, Locale[] locale) protected LocalegetLocale(jakarta.servlet.http.HttpServletRequest req) Retrieves locale based on the request.static Localeprotected voidgetSaveHttpHeaders(jakarta.servlet.ServletConfig sc) get http headers to save from configuration.protected X509CertificategetSSLClientCertificate(jakarta.servlet.http.HttpServletRequest httpReq) get ssl client authenticated certificateprotected X509CertificategetSSLClientCertificate(jakarta.servlet.http.HttpServletRequest httpReq, boolean clientCertRequired) protected CMSTemplategetTemplate(String templateName, jakarta.servlet.http.HttpServletRequest httpReq, Locale[] locale) get a template based on result status.protected StringhashPassword(String pwd) voidinit(jakarta.servlet.ServletConfig sc) initializeAuthz(jakarta.servlet.ServletConfig sc, AuthzSubsystem authz, String id) protected static voidinvalidateSSLSession(jakarta.servlet.http.HttpServletRequest httpReq) Invalidates a SSL Session.booleanprotected CMSRequestCreate a new CMSRequest object.protected ICMSTemplateFillernewFillerObject(String fillerClass) instantiate a new filler from a class name,protected voidoutputArgBlockAsXML(XMLObject xmlObj, Node parent, String argBlockName, ArgBlock argBlock) protected voidoutputError(jakarta.servlet.http.HttpServletResponse httpResp, String errorString) protected voidoutputError(jakarta.servlet.http.HttpServletResponse httpResp, String errorString, String requestId) protected voidoutputError(jakarta.servlet.http.HttpServletResponse httpResp, String status, String errorString, String requestId) voidoutputHttpParameters(jakarta.servlet.http.HttpServletRequest httpReq) protected voidoutputResult(jakarta.servlet.http.HttpServletResponse httpResp, String contentType, byte[] content) protected voidoutputXML(jakarta.servlet.http.HttpServletResponse httpResp, CMSTemplateParams params) protected voidprocess(CMSRequest cmsRequest) process an HTTP request.protected voidrenderException(CMSRequest cmsReq, EBaseException e) Output exception (unexpected error) template This is different from other templates in that if an exception occurs while rendering the exception a message is printed out directly.voidrenderFinalError(CMSRequest cmsReq, Exception ex) protected voidrenderResult(CMSRequest cmsReq) Output a template.protected voidrenderTemplate(CMSRequest cmsReq, String templateName, ICMSTemplateFiller filler) protected static voidsaveAuthToken(AuthToken token, Request req) protected voidsaveHttpHeaders(jakarta.servlet.http.HttpServletRequest httpReq, Request req) save http headers in a Request.protected voidsaveHttpParams(ArgBlock httpParams, Request req) save http headers in a Request.voidservice(jakarta.servlet.http.HttpServletRequest httpReq, jakarta.servlet.http.HttpServletResponse httpResp) protected voidsetDefaultTemplates(jakarta.servlet.ServletConfig sc) set default templates.toHashtable(jakarta.servlet.http.HttpServletRequest req) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
logger
public static org.slf4j.Logger logger -
SUCCESS
- See Also:
-
FAILURE
- See Also:
-
AUTH_FAILURE
- See Also:
-
PROP_ID
- See Also:
-
PROP_AUTHORITY
- See Also:
-
PROP_AUTHORITYID
- See Also:
-
PROP_AUTHMGR
- See Also:
-
PROP_CLIENTAUTH
- See Also:
-
PROP_RESOURCEID
- See Also:
-
PROP_AUTHZ_MGR
- See Also:
-
PROP_ACL
- See Also:
-
AUTHZ_MGR_BASIC
- See Also:
-
AUTHZ_MGR_LDAP
- See Also:
-
PROP_FINAL_ERROR_MSG
- See Also:
-
ERROR_MSG_TOKEN
- See Also:
-
FINAL_ERROR_MSG
- See Also:
-
PROP_UNAUTHORIZED_TEMPLATE
- See Also:
-
UNAUTHORIZED_TEMPLATE
- See Also:
-
PROP_SUCCESS_TEMPLATE
- See Also:
-
SUCCESS_TEMPLATE
- See Also:
-
PROP_PENDING_TEMPLATE
- See Also:
-
PENDING_TEMPLATE
- See Also:
-
PROP_SVC_PENDING_TEMPLATE
- See Also:
-
SVC_PENDING_TEMPLATE
- See Also:
-
PROP_REJECTED_TEMPLATE
- See Also:
-
REJECTED_TEMPLATE
- See Also:
-
PROP_ERROR_TEMPLATE
- See Also:
-
ERROR_TEMPLATE
- See Also:
-
PROP_EXCEPTION_TEMPLATE
- See Also:
-
EXCEPTION_TEMPLATE
- See Also:
-
PROP_SUCCESS_TEMPLATE_FILLER
- See Also:
-
PROP_PENDING_TEMPLATE_FILLER
- See Also:
-
RA_AGENT_GROUP
- See Also:
-
CA_AGENT_GROUP
- See Also:
-
KRA_AGENT_GROUP
- See Also:
-
OCSP_AGENT_GROUP
- See Also:
-
TRUSTED_RA_GROUP
- See Also:
-
ADMIN_GROUP
- See Also:
-
PFX_HTTP_HEADER
- See Also:
-
PFX_HTTP_PARAM
- See Also:
-
PFX_AUTH_TOKEN
- See Also:
-
AUTHMGR_PARAM
- See Also:
-
CERT_ATTR
- See Also:
-
servletConfig
protected jakarta.servlet.ServletConfig servletConfig -
servletContext
protected jakarta.servlet.ServletContext servletContext -
mRenderResult
protected boolean mRenderResult -
mFinalErrorMsg
-
mTemplates
-
mDontSaveHttpParams
-
mSaveHttpHeaders
-
mId
-
mConfig
-
mAuthority
-
requestRepository
-
mRequestQueue
-
mGetClientCert
-
mAuthMgr
-
mAuthz
-
mAclMethod
-
mAuthzResourceName
-
mOutputTemplatePath
-
TEMPLATE_NAME
- See Also:
-
IMPORT_CERT
- See Also:
-
IMPORT_CHAIN
- See Also:
-
IMPORT_CERT_MIME_TYPE
- See Also:
-
NS_X509_USER_CERT
- See Also:
-
NS_X509_EMAIL_CERT
- See Also:
-
SIMPLE_ENROLLMENT_REQUEST
- See Also:
-
SIMPLE_ENROLLMENT_RESPONSE
- See Also:
-
FULL_ENROLLMENT_REQUEST
- See Also:
-
FULL_ENROLLMENT_RESPONSE
- See Also:
-
FULL_RESPONSE
handy routine to check if client want full enrollment response
-
-
Constructor Details
-
CMSServlet
public CMSServlet()
-
-
Method Details
-
toHashtable
-
getCMSEngine
-
initializeAuthz
public String initializeAuthz(jakarta.servlet.ServletConfig sc, AuthzSubsystem authz, String id) throws EBaseException - Throws:
EBaseException
-
init
public void init(jakarta.servlet.ServletConfig sc) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Servlet- Overrides:
initin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletException
-
getId
-
getAuthMgr
-
isClientCertRequired
public boolean isClientCertRequired() -
outputHttpParameters
public void outputHttpParameters(jakarta.servlet.http.HttpServletRequest httpReq) -
service
public void service(jakarta.servlet.http.HttpServletRequest httpReq, jakarta.servlet.http.HttpServletResponse httpResp) throws jakarta.servlet.ServletException, IOException - Overrides:
servicein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
newCMSRequest
Create a new CMSRequest object. This should be overriden by servlets implementing different types of request- Returns:
- a new CMSRequest object
-
process
process an HTTP request. Servlets must override this with their own implementation- Throws:
EBaseException- if the servlet was unable to satisfactorily process the requestException
-
renderResult
Output a template. If an error occurs while outputing the template the exception template is used to display the error.- Parameters:
cmsReq- the CS request- Throws:
IOException
-
outputArgBlockAsXML
-
outputXML
protected void outputXML(jakarta.servlet.http.HttpServletResponse httpResp, CMSTemplateParams params) -
renderTemplate
protected void renderTemplate(CMSRequest cmsReq, String templateName, ICMSTemplateFiller filler) throws IOException - Throws:
IOException
-
renderException
Output exception (unexpected error) template This is different from other templates in that if an exception occurs while rendering the exception a message is printed out directly. If the message gets an error an IOException is thrown. In others if an exception occurs while rendering the template the exception template (this) is called.- Parameters:
cmsReq- the CS request to pass to template filler if any.e- the unexpected exception- Throws:
IOException
-
renderFinalError
- Throws:
IOException
-
invalidateSSLSession
protected static void invalidateSSLSession(jakarta.servlet.http.HttpServletRequest httpReq) Invalidates a SSL Session. So client auth will happen again. -
getAuthCreds
public static AuthCredentials getAuthCreds(AuthManager authMgr, ArgBlock argBlock, X509Certificate clientCert) throws EBaseException construct a authentication credentials to pass into authentication manager.- Throws:
EBaseException
-
getSSLClientCertificate
protected X509Certificate getSSLClientCertificate(jakarta.servlet.http.HttpServletRequest httpReq) throws EBaseException get ssl client authenticated certificate- Throws:
EBaseException
-
getSSLClientCertificate
protected X509Certificate getSSLClientCertificate(jakarta.servlet.http.HttpServletRequest httpReq, boolean clientCertRequired) throws EBaseException - Throws:
EBaseException
-
getTemplate
protected CMSTemplate getTemplate(String templateName, jakarta.servlet.http.HttpServletRequest httpReq, Locale[] locale) throws EBaseException, IOException get a template based on result status.- Throws:
EBaseExceptionIOException
-
getDontSaveHttpParams
protected void getDontSaveHttpParams(jakarta.servlet.ServletConfig sc) get http parameters not to save from configuration. -
getSaveHttpHeaders
protected void getSaveHttpHeaders(jakarta.servlet.ServletConfig sc) get http headers to save from configuration. -
saveHttpHeaders
protected void saveHttpHeaders(jakarta.servlet.http.HttpServletRequest httpReq, Request req) throws EBaseException save http headers in a Request.- Throws:
EBaseException
-
saveHttpParams
-
newFillerObject
instantiate a new filler from a class name,- Returns:
- null if can't be instantiated, new instance otherwise.
-
setDefaultTemplates
protected void setDefaultTemplates(jakarta.servlet.ServletConfig sc) set default templates. subclasses can override, and should override at least the success template -
clientIsMSIE
public static boolean clientIsMSIE(jakarta.servlet.http.HttpServletRequest httpReq) handy routine to check if client is msie based on user-agent. -
doCMMFResponse
-
doFullResponse
-
saveAuthToken
-
getAuthToken
-
connectionIsSSL
protected static boolean connectionIsSSL(jakarta.servlet.http.HttpServletRequest httpReq) -
formCRLEntry
protected org.mozilla.jss.netscape.security.x509.RevokedCertImpl formCRLEntry(BigInteger serialNo, org.mozilla.jss.netscape.security.x509.RevocationReason reason) throws EBaseException make a CRL entry from a serial number and revocation reason.- Returns:
- a RevokedCertImpl that can be entered in a CRL.
- Throws:
EBaseException
-
hashPassword
-
getLangFile
public static File getLangFile(jakarta.servlet.http.HttpServletRequest req, File realpathFile, Locale[] locale) throws IOException - Parameters:
req- http servlet requestrealpathFile- the file to get.locale- array of at least one to be filled with locale found.- Throws:
IOException
-
getLocale
-
authenticate
- Throws:
EBaseException
-
authenticate
public AuthToken authenticate(jakarta.servlet.http.HttpServletRequest httpReq) throws EBaseException - Throws:
EBaseException
-
authenticate
- Throws:
EBaseException
-
authenticate
public AuthToken authenticate(jakarta.servlet.http.HttpServletRequest httpReq, String authMgrName) throws EBaseException Authentication- signed.audit LOGGING_SIGNED_AUDIT_AUTH_FAIL used when authentication fails (in case of SSL-client auth, only webserver env can pick up the SSL violation; CS authMgr can pick up cert mis-match, so this event is used)
- signed.audit LOGGING_SIGNED_AUDIT_AUTH_SUCCESS used when authentication succeeded
- Throws:
EBaseException- an error has occurred
-
authorize
public AuthzToken authorize(String authzMgrName, String resource, AuthToken authToken, String exp) throws EBaseException - Throws:
EBaseException
-
authorize
public AuthzToken authorize(String authzMgrName, AuthToken authToken, String resource, String operation) throws EBaseException Authorize must occur after Authenticate- signed.audit LOGGING_SIGNED_AUDIT_AUTHZ_FAIL used when authorization has failed
- signed.audit LOGGING_SIGNED_AUDIT_AUTHZ_SUCCESS used when authorization is successful
- signed.audit LOGGING_SIGNED_AUDIT_ROLE_ASSUME used when user assumes a role (in current CS that's when one accesses a role port)
- Parameters:
authzMgrName- string representing the name of the authorization managerauthToken- the authentication tokenresource- a string representing the ACL resource id as defined in the ACL resource listoperation- a string representing one of the operations as defined within the ACL statement (e. g. - "read" for an ACL statement containing "(read,write)")- Returns:
- the authorization token
- Throws:
EBaseException- an error has occurred
-
auditSubjectID
Signed Audit Log Subject ID This method is inherited by all extended "CMSServlet"s, and is called to obtain the "SubjectID" for a signed audit log message.- Returns:
- id string containing the signed audit log message SubjectID
-
auditGroupID
Signed Audit Log Group ID This method is inherited by all extended "CMSServlet"s, and is called to obtain the "gid" for a signed audit log message.- Returns:
- id string containing the signed audit log message SubjectID
-
getLocale
Retrieves locale based on the request. -
outputResult
protected void outputResult(jakarta.servlet.http.HttpServletResponse httpResp, String contentType, byte[] content) -
outputError
-
outputError
-
outputError
-