本文整理汇总了Java中com.sun.jersey.api.core.ScanningResourceConfig类的典型用法代码示例。如果您正苦于以下问题:Java ScanningResourceConfig类的具体用法?Java ScanningResourceConfig怎么用?Java ScanningResourceConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScanningResourceConfig类属于com.sun.jersey.api.core包,在下文中一共展示了ScanningResourceConfig类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import com.sun.jersey.api.core.ScanningResourceConfig; //导入依赖的package包/类
@Override
protected AppDescriptor configure() {
this.requestConfiguration = RequestConfiguration.builder().withApiKeyQueryParamName("passkey")
.withSignatureHttpHeader("duck-duck-signature-header")
.withTimestampHttpHeader("duck-duck-timestamp-header")
.withVersionHttpHeader("duck-duck-version-header")
.build();
final Authenticator<String> authenticator = new Authenticator<String>() {
@Override
public String authenticate(Credentials credentials) {
if (GOOD_API_KEY.equals(credentials.getApiKey())) {
return GOOD_API_KEY;
}
if (INTERNAL_ERROR.equals(credentials.getApiKey())) {
throw new IllegalStateException("An internal error occurred");
}
return null;
}
};
ResourceConfig config = new ScanningResourceConfig();
config.getSingletons().add(new HmacAuthProvider<String>(new DefaultRequestHandler<String>(authenticator, requestConfiguration)));
config.getSingletons().add(new AuthResource());
return new LowLevelAppDescriptor.Builder(config).build();
}