// Path: framework/src/main/java/org/demoiselle/security/InvalidCredentialsException.java
// public class InvalidCredentialsException extends AuthenticationException {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public InvalidCredentialsException() {
// 		super(CDI.current().select(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")).get().getString("invalid-credentials"));
// 	}
// 
// 	/**
// 	 * <p>
// 	 * Constructs an <code>InvalidCredentialsException</code> with a message.
// 	 * </p>
// 	 *
// 	 * @param message exception message.
// 	 */
// 	public InvalidCredentialsException(String message) {
// 		super(message);
// 	}
// 
// 	/**
// 	 * <p>
// 	 * Constructor with message and cause.
// 	 * </p>
// 	 *
// 	 * @param message exception message.
// 	 * @param cause exception cause.
// 	 */
// 	public InvalidCredentialsException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


import org.demoiselle.annotation.Priority;
import org.demoiselle.security.Authenticator;
import org.demoiselle.security.InvalidCredentialsException;
import org.demoiselle.servlet.security.Credentials;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.spi.CDI;
import java.security.Principal;
package br.gov.serpro.demoiselle.bookmark.security;



/**
 * @author SERPRO
 */
@SessionScoped
@Priority(Priority.L3_PRIORITY)
public class BookmarkAuthenticator implements Authenticator {

	private static final long serialVersionUID = -118515447020255993L;

	private Principal principal;

    /**
     * Authenticates any user since that password be "secret".
     *
     * @throws Exception
     */
    @Override
    public void authenticate() throws Exception {

        Credentials credentials = CDI.current().select(Credentials.class).get();

        if (credentials.getPassword().equals("secret")) {
            this.principal = credentials::getUsername;
        } else {
// Path: framework/src/main/java/org/demoiselle/security/InvalidCredentialsException.java
// public class InvalidCredentialsException extends AuthenticationException {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public InvalidCredentialsException() {
// 		super(CDI.current().select(ResourceBundle.class, new NameQualifier("demoiselle-core-bundle")).get().getString("invalid-credentials"));
// 	}
// 
// 	/**
// 	 * <p>
// 	 * Constructs an <code>InvalidCredentialsException</code> with a message.
// 	 * </p>
// 	 *
// 	 * @param message exception message.
// 	 */
// 	public InvalidCredentialsException(String message) {
// 		super(message);
// 	}
// 
// 	/**
// 	 * <p>
// 	 * Constructor with message and cause.
// 	 * </p>
// 	 *
// 	 * @param message exception message.
// 	 * @param cause exception cause.
// 	 */
// 	public InvalidCredentialsException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


// Path: bookmark/src/main/java/br/gov/serpro/demoiselle/bookmark/security/BookmarkAuthenticator.java
import org.demoiselle.annotation.Priority;
import org.demoiselle.security.Authenticator;
import org.demoiselle.security.InvalidCredentialsException;
import org.demoiselle.servlet.security.Credentials;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.spi.CDI;
import java.security.Principal;

package br.gov.serpro.demoiselle.bookmark.security;



/**
 * @author SERPRO
 */
@SessionScoped
@Priority(Priority.L3_PRIORITY)
public class BookmarkAuthenticator implements Authenticator {

	private static final long serialVersionUID = -118515447020255993L;

	private Principal principal;

    /**
     * Authenticates any user since that password be "secret".
     *
     * @throws Exception
     */
    @Override
    public void authenticate() throws Exception {

        Credentials credentials = CDI.current().select(Credentials.class).get();

        if (credentials.getPassword().equals("secret")) {
            this.principal = credentials::getUsername;
        } else {
            throw new InvalidCredentialsException();