Search in sources :

Example 1 with RepositoryEventImpl

use of org.alfresco.sync.events.types.RepositoryEventImpl in project alfresco-remote-api by Alfresco.

the class AbstractLoginBean method login.

protected Map<String, Object> login(final String username, String password) {
    try {
        // get ticket
        authenticationService.authenticate(username, password.toCharArray());
        eventPublisher.publishEvent(new EventPreparator() {

            @Override
            public Event prepareEvent(String user, String networkId, String transactionId) {
                // TODO need to fix up to pass correct seqNo and alfrescoClientId
                return new RepositoryEventImpl(-1l, "login", transactionId, networkId, new Date().getTime(), username, null);
            }
        });
        // add ticket to model for javascript and template access
        Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
        model.put("username", username);
        model.put("ticket", authenticationService.getCurrentTicket());
        return model;
    } catch (AuthenticationException e) {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Login failed");
    } finally {
        AuthenticationUtil.clearCurrentSecurityContext();
    }
}
Also used : EventPreparator(org.alfresco.sync.repo.events.EventPreparator) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) AuthenticationException(org.alfresco.repo.security.authentication.AuthenticationException) Event(org.alfresco.sync.events.types.Event) RepositoryEventImpl(org.alfresco.sync.events.types.RepositoryEventImpl) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 AuthenticationException (org.alfresco.repo.security.authentication.AuthenticationException)1 Event (org.alfresco.sync.events.types.Event)1 RepositoryEventImpl (org.alfresco.sync.events.types.RepositoryEventImpl)1 EventPreparator (org.alfresco.sync.repo.events.EventPreparator)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1