相关疑难解决方法(0)

DropWizard Auth by Example

我试图了解DropWizard中的身份验证和授权是如何工作的.我已经阅读了他们的auth指南以及GitHub上的dropwizard-security项目,但感觉我仍然缺少一些重要的概念.

public class SimpleCredential {
    private String password;

    public SimpleCredential(String password) {
        super();

        this.password = password;
    }
}

public class SimplePrincipal {
    pivate String username;

    public SimplePrincipal(String username) {
        super();

        this.username = username;
    }
}

public class SimpleAuthenticator implements Authenticator<SimpleCredential, SimplePrincipal> {
    @Override
    public Optional<SimplePrincipal> authenticate(SimpleCredential credential) throws AuthenticationException {
        if(!"12345".equals(credential.getPassword())) {
            throw new AuthenticationException("Sign in failed.");
        }

        Optional.fromNullable(new SimplePrincipal("simple_user"));
    }
}
Run Code Online (Sandbox Code Playgroud)

然后在我的Application子类中:

@Override
public void run(BackendConfiguration configuration, Environment environment) throws Exception …
Run Code Online (Sandbox Code Playgroud)

java jax-rs jersey basic-authentication dropwizard

21
推荐指数
1
解决办法
2万
查看次数

在泽西岛获得休息服务

我对Web服务非常陌生.我已经使用Jersey 2与Spring集成了一些REST服务.现在我需要使用用户名/密码进行身份验证来保护这些休息服务.我被告知不要使用Spring安全性.

我不知道该怎么做.我在网上搜索,但各种链接显示各种实现,我无法决定如何继续它.

我知道这是一个模糊的问题,但请在这方面提供帮助.

java rest jax-rs jersey jersey-2.0

4
推荐指数
1
解决办法
3914
查看次数