com.nepxion.discovery.console.authentication.AuthenticationResourceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-console Show documentation
Show all versions of discovery-console Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
package com.nepxion.discovery.console.authentication;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import com.nepxion.discovery.common.entity.UserEntity;
public class AuthenticationResourceImpl implements AuthenticationResource {
@Autowired
private Environment environment;
@Override
public boolean authenticate(UserEntity userEntity) throws Exception {
String userId = userEntity.getUserId().trim();
String password = userEntity.getPassword().trim();
String passwordValue = environment.getProperty(userId);
if (StringUtils.isNotEmpty(passwordValue)) {
return StringUtils.equals(password, passwordValue);
} else {
throw new IllegalArgumentException("Not exists for [" + userId + "]");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy