1 17 package org.alfresco.repo.webservice.authentication; 18 19 import java.rmi.RemoteException ; 20 21 import org.alfresco.repo.security.authentication.AuthenticationException; 22 import org.alfresco.service.cmr.security.AuthenticationService; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 33 public class AuthenticationWebService implements AuthenticationServiceSoapPort 34 { 35 private static Log logger = LogFactory.getLog(AuthenticationWebService.class); 36 37 private AuthenticationService authenticationService; 38 39 45 public void setAuthenticationService(AuthenticationService authenticationSvc) 46 { 47 this.authenticationService = authenticationSvc; 48 } 49 50 54 public AuthenticationResult startSession(String username, String password) 55 throws RemoteException , AuthenticationFault 56 { 57 try 58 { 59 this.authenticationService.authenticate(username, password.toCharArray()); 60 String ticket = this.authenticationService.getCurrentTicket(); 61 62 if (logger.isDebugEnabled()) 63 { 64 logger.debug("Issued ticket '" + ticket + "' for '" + username + "'"); 65 } 66 67 return new AuthenticationResult(username, ticket); 68 } 69 catch (AuthenticationException ae) 70 { 71 throw new AuthenticationFault(100, ae.getMessage()); 72 } 73 catch (Throwable e) 74 { 75 throw new AuthenticationFault(0, e.getMessage()); 76 } 77 } 78 79 82 public void endSession(String ticket) throws RemoteException , AuthenticationFault 83 { 84 try 85 { 86 if (ticket != null) 87 { 88 this.authenticationService.validate(ticket); 89 this.authenticationService.invalidateTicket(ticket); 90 this.authenticationService.clearCurrentSecurityContext(); 91 92 if (logger.isDebugEnabled()) 93 { 94 logger.debug("Session ended for ticket '" + ticket + "'"); 95 } 96 } 97 } 98 catch (Throwable e) 99 { 100 throw new AuthenticationFault(0, e.getMessage()); 101 } 102 } 103 } 104 | Popular Tags |