Error import import br.gov.frameworkdemoiselle.security.User

1

Error importing interface User :

import br.gov.frameworkdemoiselle.security.User;

demoiselle version used: 2.5.0-RC1

According to GrepCode, in version 2.5.0-BETA2, this interface existed ( link ), but from 2.5.0-BETA3 onwards it disappeared (< a link =).

Does anyone know which interface replaces the 'User'?

I'm implementing the Authenticator interface:

import br.gov.frameworkdemoiselle.security.Authenticator;
import br.gov.frameworkdemoiselle.security.User;

public class Autenticador implements Authenticator {
    ...
    @Override
    public User getUser() {
        return new User() {
            private static final long serialVersionUID = 1L;

            @Override
            public void setAttribute(Object arg0, Object arg1) {

            }

            @Override
            public String getId() {
                return "usuario X";
            }

            @Override
            public Object getAttribute(Object arg0) {
                return null;
            }
        };
    }

}
    
asked by anonymous 24.04.2015 / 16:30

1 answer

1

This interface has been deprecated and instead we recommend using java.security.Principal which makes the solution more compatible with other Java standards like JAAS for example.

Remembering that Demoiselle 2.5 is not yet in the final version, while we are doing tests in the example application: link

ex:

....

@Override
public  Principal getUser() {

    if (authenticated) {

        return new Principal() {

            @Override
            public String getName() {
                return credentials.getUsername();
            }

        };
    }else{
        return null;
    }

}

@Override
public void unauthenticate() throws Exception {
    credentials.clear();
    authenticated = false;
}
    
27.04.2015 / 14:50