asking for help ??

cancel
Showing results for 
Search instead for 
Did you mean: 
laridev
Active Member

asking for help ??

i following this tutorial and it worked but i need some more  informations 

package org.alfresco.tutorial.repo.security.authentication;import net.sf.acegisecurity.Authentication;import org.alfresco.error.AlfrescoRuntimeException;import org.alfresco.repo.security.authentication.AbstractAuthenticationComponent;import org.alfresco.repo.security.authentication.AuthenticationException;import org.apache.commons.codec.binary.StringUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;public class CustomAuthenticationComponentImpl extends AbstractAuthenticationComponent {    private static final Log LOG = LogFactory.getLog(CustomAuthenticationComponentImpl.class);    /**     * Some custom properties that could be used to inject a remote login server hostname and port.     * Not used at the moment but demonstrates property injection in custom authentication component.     */    private String remoteAuthenticatorHostname;    private String remoteAuthenticatorPort;     public void setRemoteAuthenticatorHostname(String remoteAuthenticatorHostname) {        this.remoteAuthenticatorHostname = remoteAuthenticatorHostname;    }     public void setRemoteAuthenticatorPort(String remoteAuthenticatorPort) {        this.remoteAuthenticatorPort = remoteAuthenticatorPort;    }     public void authenticateImpl(String userName, char[] password) throws AuthenticationException {        if (LOG.isDebugEnabled()) {           LOG.debug("Login request(" + remoteAuthenticatorHostname + ":" + remoteAuthenticatorPort +           ") : [userName=" + userName + "][password=" + String.valueOf(password) + "]");        }               // Do your custom authentication here, and then set the current user (in this example we are only allowing        // john to authenticate successfully, and we don't check pwd)        // You would typically connect to the remote authentication mechanism to verify username/pwd...        if (StringUtils.equals(userName, "john") || isGuestUserName(userName) ||                getDefaultAdministratorUserNames().contains(userName)) {            setCurrentUser(userName);        } else {            String msg = "Login request: username not recognized [userName=" + userName + "]";            LOG.error(msg);            throw new AuthenticationException(msg);        }    }     /**      * The default is not to support token base authentication      */    public Authentication authenticate(Authentication token) throws AuthenticationException {        throw new AlfrescoRuntimeException("Authentication via token not supported");    }     /**      * This authentication component implementation allows guest login      * @return      */    @Override    protected boolean implementationAllowsGuestLogin() {        return true;    }}

how to do this

 You would typically connect to the remote authentication mechanism to verify username/pwd...
3 Replies
jpotts
Professional

Re: asking for help ??

You haven't provided enough information for anyone to be able help you with a reasonable amount of effort. Please include things like:

1. Which tutorial?

2. What have you tried so far?

3. Where are you stuck?

laridev
Active Member

Re: asking for help ??

hi Jeff , 

i'm following this : Authentication | Alfresco Documentation  and i'm stuck at this point 

 You would typically connect to the remote authentication mechanism to verify username/pwd...
jpotts
Professional

Re: asking for help ??

What remote authentication mechanism are you trying to connect to? Whatever it is, it must have a Java API. So you'll use that API to validate the username and password in your class.

If you've tried that and are having trouble, please provide the code that shows your custom authentication component.