Reputation: 257
I configured my Oracle Application Express to have a authentication schema based on HTTP Header Variable.
To be more specific, it is based on remote_user, which is set to domain login, thanks to connection with CAS.
Right now i need to get attributes. I know the method in Java how to do it:
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
final Map attributes = principal.getAttributes();
The question are there other possibilities to receive this attributes w/o using java, (code that i can use in Oracle Application Express) e.g. JavaScript...
Or maybe there is a method how to use Java code in APEX? I use APEX-ORDS-TOMCAT system and there is something like:
.../webapps/${app_name}/WEB-INF/classes and .../webapps/${app_name}/WEB-INF/lib
Maybe this is the place i can place some java .class and use it in some way in Oracle APEX?
Great thx for any help
Upvotes: 1
Views: 337
Reputation: 257
I created the solution by myself.
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
final Map attributes = principal.getAttributes();
JSONObject jsonObj = new JSONObject(attributes);
PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
out.print(jsonObj);
Compile .java to .class and put it folder:
${TOMCAT_BASE}/webapps/${APP_NAME}/WEB-INF/classes/${PACKAGE_NAME}
${TOMCAT_BASE}/webapps/${APP_NAME}/WEB-INF/lib
List of the libs (verions can be different):
json-20190722.jar
javax.servlet-api-4.0.1.jar
cas-client-core-3.6.1.jar
cas-client-support-saml-3.4.1.jar
commons-logging-1.1.1.jar
joda-time-2.10.4.jar
log4j-1.2.17.jar
slf4j-api-1.7.28.jar
slf4j-simple-1.7.25.jar
<servlet>
<servlet-name>SERVLET_NAME</servlet-name>
<servlet-class>${PACKAGE_NAME}.{CLASS_NAME}</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SERVLET_NAME</servlet-name>
<url-pattern>/{PATH}</url-pattern>
</servlet-mapping>
and now on the servlet is available on {host}:{port}/{APP_NAME}/{PATH}
function loadJSON(itemName) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(itemName).value = this.responseText
}
};
xhttp.open("GET", "{PATH}", true);
xhttp.send();
}
loadJSON("P1_USER_INFO");
Upvotes: 2