我正在使用 Java 8 和 Spring Boot 制作一个项目,我想在其中添加 Wss4jSecurityInterceptor 以进行登录。
到目前为止,这是我在 WebServiceConfig 类中所做的
@Bean
public AuthorizationCallBackHandler authorizationCallBackHandler(){
AuthorizationCallBackHandler callbackHandler = new AuthorizationCallBackHandler();
return callbackHandler;
}
@Bean
public Wss4jSecurityInterceptor securityInterceptor(){
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setValidationActions("UsernameToken");
securityInterceptor.setValidationCallbackHandler(authorizationCallBackHandler());
return securityInterceptor;
}
@Override
public void addInterceptors(List interceptors) {
interceptors.add(securityInterceptor());
//interceptors.add(endPointInterceptor());
}
因此,这样,到达我的 Web 服务的每个请求都将被 Wss4jSecurityInterceptor 拦截,并由我的自定义回调处理,定义如下
public class AuthorizationCallBackHandler implements CallbackHandler{
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
VnWsCredentialRepository credentialsRepo;
@Autowired
AuthUtility authUtil;
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
if (callbacks[0] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
String username = pc.getIdentifier();
VnWsCredential credentials = credentialsRepo.findByUsername(username);
logger.info("Request of authentication for username" + username);
String p = pc.getPassword();
// set the password on the callback. This will be compared to the
// password which was sent from the client.
if (credentials == null) {
pc.setPassword(null);
这是我的问题:当 Callback 被调用时,它会收到一个数组,该数组只包含 1 个具有“CleanupCallback”类型的回调,当然,我不能用它做任何事情。
我在以下设置中缺少什么?
万千封印
相关分类