org.ligoj.app.http.security.TrustedAuthenticationProvider.java Source code

Java tutorial

Introduction

Here is the source code for org.ligoj.app.http.security.TrustedAuthenticationProvider.java

Source

/*
 * Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
 */
package org.ligoj.app.http.security;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;

/**
 * Always authenticated provider.
 */
public class TrustedAuthenticationProvider extends AbstractAuthenticationProvider {

    @Override
    public Authentication authenticate(final Authentication authentication) {
        final String userName = StringUtils.lowerCase(authentication.getPrincipal().toString());
        return new UsernamePasswordAuthenticationToken(userName, "N/A", authentication.getAuthorities());
    }

}