cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid valid security context Exception

rutaveejshah
Champ in-the-making
Champ in-the-making
Hello Everyone!

I am creating a web script to get alfresco session ticket.When i call that web script without user authentication it was giving me error like net.sf.acegisecurity.AuthenticationCredentialsNotFoundException - A valid SecureContext was not provided in the RequestContext.

Is there anyway to avoid this exception?

for e.g

<webscript>
  <shortname>Get Alfresco User Ticket</shortname>
  <description>This method is used to get userinformation ticket.</description>
  <url>/alfresco/user/ticket</url>
  <authentication>user</authentication>
  <transaction>required</transaction>
  <format default="json">extension</format>
</webscript>


if i use the above description file it is not provide me any exception.

But if I use the  webscript like below it will provide me error.Is there any way to avoid valid security Exception?


<webscript>
  <shortname>Get Alfresco User Ticket</shortname>
  <description>This method is used to get useri nformation ticket.</description>
  <url>/alfresco/user/ticket</url>
  <format default="json">extension</format>
</webscript>


Please reply if any one have any idea.
Thanks.



3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
Why do you write a custom webscript to get user ticket? I didn't think it would be necessary.
After you login with any user using webscript api,you can get the ticket,and during the session you can use it do whatever you want to.

Thanks for your reply.
But when i used the alfresco webscript api i have to pass the username and password and I am using single sign on functionality.So it is not possible for me to get usename or password.
Is there any solution to get user ticket withour providing username and password.
Thanks.

niketapatel
Star Contributor
Star Contributor
Hi rutaveejshah,

I believe, In your SSO once user is authenticated you must be executing your webscript with - "wcservice" so script gets executed with same/current user's session.

You can get ticket in your script with js api
${session.ticket}
which calls  ServiceRegistry.getAuthenticationService().getCurrentTicket();

Hope it helps!