cancel
Showing results for 
Search instead for 
Did you mean: 

Get Username in Java from API

emelbye
Champ on-the-rise
Champ on-the-rise
Hi….

My Project
I've a Netbeans project called ReporteBC.
- reporte.jsp
- reporte.jasper (made by iReport)
- reporte.jasper contains data from CMIS (a simple query like: select * from ld:legajos)… In the report I made a group and count.

Then, I generate Reporte.war from ReporteBC and I put this file into /alfresco/tomcat/webapps folder
I can access via http://127.0.0.1/ReporteBC/reporte.jsp. The report is a PDF file and its OK (with data and graphics)…..

How can I get the username of the current user?

I have something like:
String nombreDeUsuario = org.alfresco.repo.security.authentication.AuthenticationUtil.getFullyAuthenticatedUser();
// reporte.setParameter(nombreDeUsuario);
in the reporte.jsp, but nombreDeUsuario is NULL.

Im doing something wrong with AuthenticationUtil.getFullyAuthenticatedUser();?…. I have to use other class? Other method? Cookie? Session? What?
The only thing I need is the current username in my reporte.jsp

Help me please!!!…
Im using Alfresco Community 3.4d
-
Sorry my english and
Thank you for your help!…
2 REPLIES 2

abarisone
Star Contributor
Star Contributor
Hi,
you should consider this topic https://forums.alfresco.com/en/viewtopic.php?f=47&t=20466 since it may give you the answer you're looking for.

Regards,
Andrea

emelbye
Champ on-the-rise
Champ on-the-rise
Hi… I solved it…

I read and implement the example: (http://docs.alfresco.com/4.0/topic/com. … rials.html)

In my webview i can see the report with the username included in the pdf file..
My custom webview.get.js

if (model.isDefault ==  true )   
{       
   model.webviewTitle =  "Reporte";   
   model.uri = "http://localhost:8080/reportebcsa/index.jsp?usr='+person.properties.userName;       
   model.isDefault =  false;  
}

Now, security. If someone try to type http://localhost:8080/reportebcsa/index.jsp in the browser, i want to see the login or error page…

I saw some samples in http://docs.alfresco.com/4.0/topic/com. … -page.html
I know we can set something like
<?xml version="1.0" encoding="UTF-8"?>
<template-type>
        <title>Site index landing page template type</title>
        <description>Site index landing page JSP Template Type</description>

        <!– Define the rendering processors for this template type –>
        <processor mode="view">
                <id>jsp</id>
                <jsp-path>/my-page.jsp</jsp-path>
        </processor>
</template-type>

helllpppp!!….

suggestion?
Thanks again….