本文整理汇总了Java中org.restlet.security.ChallengeAuthenticator.setVerifier方法的典型用法代码示例。如果您正苦于以下问题:Java ChallengeAuthenticator.setVerifier方法的具体用法?Java ChallengeAuthenticator.setVerifier怎么用?Java ChallengeAuthenticator.setVerifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.security.ChallengeAuthenticator
的用法示例。
在下文中一共展示了ChallengeAuthenticator.setVerifier方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
public static void main( String[] args )
throws Exception
{
Energy4Java polygene = new Energy4Java( );
Server server = new Server( Protocol.HTTP, 8888 );
Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() );
app.activate();
ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() );
ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
MapVerifier mapVerifier = new MapVerifier();
mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray());
guard.setVerifier(mapVerifier);
guard.setNext(restlet);
server.setNext( restlet );
server.start();
}
示例2: initializeAuthentication
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
public void initializeAuthentication() {
if(verifier == null){
verifier = new DefaultSecretVerifier();
}
authenticator = new ChallengeAuthenticator(null, false, ChallengeScheme.HTTP_BASIC, "Foxbpm Realm") {
protected boolean authenticate(Request request, Response response) {
if (restAuthenticator != null && !restAuthenticator.requestRequiresAuthentication(request)) {
return true;
}
if (request.getChallengeResponse() == null) {
response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
return false;
} else {
boolean authenticated = super.authenticate(request, response);
if (authenticated && restAuthenticator != null) {
authenticated = restAuthenticator.isRequestAuthorized(request);
}
return authenticated;
}
}
};
authenticator.setVerifier(verifier);
}
示例3: createInboundRoot
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
@Override
public Restlet createInboundRoot()
{
Context context = getContext();
Engine.getInstance().getRegisteredConverters().add( new PolygeneConverter( objectFactory ) );
if( polygeneApplication.mode() == Application.Mode.development )
{
setDebugging( true );
}
router = new Router( context );
addRoutes( router );
router.attach( basePath, newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) );
Verifier verifier = createVerifier();
Enroler enroler = createEnroler();
if( verifier == null && enroler == null )
{
return createInterceptors(new Filter()
{
} );
}
else
{
ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, getName() + " Realm" );
if( verifier != null )
{
guard.setVerifier( verifier );
}
if( enroler != null )
{
guard.setEnroler( enroler );
}
return createInterceptors( guard );
}
}
示例4: getAdminGuard
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private ChallengeAuthenticator getAdminGuard() {
// Create a simple password verifier
// MapVerifier verifier = new MapVerifier();
// verifier.getLocalSecrets().put("mitko", "qwepoi".toCharArray());
// Create a guard
ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(),
ChallengeScheme.HTTP_BASIC, "FP Admin");
guard.setVerifier(new AdminVerifier());
return guard;
}
示例5: getUserGuard
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private ChallengeAuthenticator getUserGuard() {
// Create a guard
ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(),
ChallengeScheme.HTTP_BASIC, "FP User");
guard.setVerifier(new UserVerifier());
guard.setOptional(getAppProperties().getProperty("DisableAnonymous", "1").equals("1")?false:true);
return guard;
}
示例6: createAuthenticator
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private ChallengeAuthenticator createAuthenticator() {
ChallengeAuthenticator auth= new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "mcrest");
MapVerifier mapVerifier = new MapVerifier();
mapVerifier.getLocalSecrets().put(authpara.getUserId(), authpara.getPassword().toCharArray());
auth.setVerifier(mapVerifier);
return auth;
}
示例7: secure
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private Restlet secure(Application app, Verifier verifier, String realm) {
ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext().createChildContext(),
ChallengeScheme.HTTP_OAUTH_BEARER, realm);
guard.setVerifier(verifier);
guard.setNext(app);
return guard;
}
示例8: createAuthenticator
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private ChallengeAuthenticator createAuthenticator() {
// ChallengeAuthenticator extends Authenticator extends Filter extens Restlet
ChallengeAuthenticator bearerAuthenticator = new ChallengeAuthenticator(application.getContext(),ChallengeScheme.HTTP_OAUTH_BEARER, ObixServiceImpl.REALM);
// do not propose new challenge if authorisation fails.
bearerAuthenticator.setRechallenging(false);
//bearerAuthenticator.setVerifier( new TokenVerifier(new Reference( "http://localhost:8080" + oautLocalServerPath + Oauth2ApplicationFactory.TOKENAUTHENTICATORURI)));
bearerAuthenticator.setVerifier( new TokenVerifier(new Reference( "riap://component" + oautLocalServerPath + Oauth2ApplicationFactory.TOKENAUTHENTICATORURI)));
return bearerAuthenticator;
}
示例9: createInboundRoot
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
/**
* Creates a root Restlet that will receive all incoming calls.
*/
@Override
public synchronized Restlet createInboundRoot() {
Verifier verifier = new SecretVerifier() {
@Override
public boolean verify(String username, char[] password) throws IllegalArgumentException {
boolean verified = ActivitiUtil.getIdentityService().checkPassword(username, new String(password));
return verified;
}
};
authenticator = new ChallengeAuthenticator(null, true, ChallengeScheme.HTTP_BASIC,
"Activiti Realm") {
@Override
protected boolean authenticate(Request request, Response response) {
if (request.getChallengeResponse() == null) {
return false;
} else {
return super.authenticate(request, response);
}
}
};
authenticator.setVerifier(verifier);
Router router = new Router(getContext());
router.attachDefault(DefaultResource.class);
router.attach("/process-engine", ProcessEngineResource.class);
router.attach("/login", LoginResource.class);
router.attach("/user/{userId}", UserResource.class);
router.attach("/user/{userId}/groups", UserGroupsResource.class);
router.attach("/group/{groupId}", GroupResource.class);
router.attach("/groups/{groupId}/users", GroupUsersResource.class);
router.attach("/process-definitions", ProcessDefinitionsResource.class);
router.attach("/process-instances", ProcessInstancesResource.class);
router.attach("/process-instance", ProcessInstanceResource.class);
router.attach("/processInstance/{processInstanceId}/diagram", ProcessInstanceDiagramResource.class);
router.attach("/process-definition/{processDefinitionId}/form", ProcessDefinitionFormResource.class);
router.attach("/tasks", TasksResource.class);
router.attach("/tasks-summary", TasksSummaryResource.class);
router.attach("/task/{taskId}", TaskResource.class);
router.attach("/task/{taskId}/form", TaskFormResource.class);
router.attach("/task/{taskId}/{operation}", TaskOperationResource.class);
router.attach("/form/{taskId}/properties", TaskPropertiesResource.class);
router.attach("/deployments", DeploymentsResource.class);
router.attach("/deployment", DeploymentUploadResource.class);
router.attach("/deployments/delete", DeploymentsDeleteResource.class);
router.attach("/deployment/{deploymentId}", DeploymentDeleteResource.class);
router.attach("/management/jobs", JobsResource.class);
router.attach("/management/job/{jobId}", JobResource.class);
router.attach("/management/job/{jobId}/execute", JobExecuteResource.class);
router.attach("/management/jobs/execute", JobsExecuteResource.class);
router.attach("/management/tables", TablesResource.class);
router.attach("/management/table/{tableName}", TableResource.class);
router.attach("/management/table/{tableName}/data", TableDataResource.class);
authenticator.setNext(router);
return authenticator;
}
示例10: createInboundRoot
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
@Override
public synchronized Restlet createInboundRoot() {
Router router = new Router(getContext());
System.setProperty("http.keepAlive", "true");
getMetadataService().setDefaultMediaType(MediaType.TEXT_HTML);
router.attach("/rootcommunities", RootCommunitiesResource.class);
router.attach("/collections", AllCollectionsResource.class);
router.attach("/items", AllItemsResource.class);
router.attach("/community/{communityId}", CommunityResource.class);
router.attach("/community/{communityId}/logo",
CommunityLogoResource.class);
router.attach("/community/{communityId}/communities",
CommunitiesResource.class);
router.attach("/community/{communityId}/collections",
CollectionsResource.class);
router.attach("/collection/{collectionId}", CollectionResource.class);
router.attach("/collection/{collectionId}/logo",
CollectionLogoResource.class);
router.attach("/collection/{collectionId}/items", ItemsResource.class);
router.attach("/item/{itemId}", ItemResource.class);
router.attach("/bundle/{bundleId}", BundleResource.class);
router.attach("/bitstream/{bitstreamIdDotFormat}",
BitstreamResource.class);
router.attach("/metadataschemas", MetadataSchemasResource.class);
router.attach("/metadataschema/{metadataSchemaId}",
MetadataSchemaResource.class);
router.attach("/metadatafields", MetadataFieldsResource.class);
router.attach("/metadatafield/{metadataFieldId}",
MetadataFieldResource.class);
router.attach("/users", UsersResource.class);
router.attach("/user/{userId}", UserResource.class);
router.attach("/groups", GroupsResource.class);
router.attach("/group/{groupId}", GroupResource.class);
Series<Parameter> params = getContext().getParameters();
String username = params.getFirstValue("username");
String password = params.getFirstValue("password");
if (password == null || password.equals("")) {
log.fatal("No password defined - you have to set it!!!");
return null;
}
// Needs HTTPS!
ChallengeAuthenticator authenticator = new ChallengeAuthenticator(
getContext(), ChallengeScheme.HTTP_BASIC,
"Authentication for SimpleRest");
Verifier verifier = new MyVerifier();
authenticator.setVerifier(verifier);
authenticator.setNext(router);
router.attach("", RootResource.class);
router.attach("/handle/{handle}", HandleResource.class);
return authenticator;
}
示例11: make
import org.restlet.security.ChallengeAuthenticator; //导入方法依赖的package包/类
private void make(){
application = new Application(new Context());
Router router = new Router(application.getContext());
application.getContext().getAttributes().put(TokenManager.class.getName(), tokenManager);
application.getContext().getAttributes().put(ClientManager.class.getName(), clientManager);
application.getContext().getAttributes().put(ResourceOwnerManager.class.getName(), ownerManager);
application.getContext().getAttributes().put(OAuthServerResource.PARAMETER_DEFAULT_SCOPE, OAUTHDEFAULTSCOPE);
// Setup Authorize Endpoint - used by the client to obtain authorization from the resource owner via user-agent redirection
router.attach(AUTHORIZEENDPOINTURI, AuthorizationServerResource.class);
// Setup Token Endpoint - used by the client to exchange an authorization grant for an access token, typically with client authentication
ChallengeAuthenticator clientAuthenticator = new ChallengeAuthenticator(application.getContext(), ChallengeScheme.HTTP_BASIC, ObixServiceImpl.REALM);
BugFixClientVerifier clientVerifier = new BugFixClientVerifier(application.getContext());
clientVerifier.setAcceptBodyMethod(true);
clientAuthenticator.setVerifier(clientVerifier);
clientAuthenticator.setNext(AccessTokenServerResource.class);
router.attach(CLIENTTOKENENDPOINTURI, clientAuthenticator);
// Setup Token Auth for Resources Server
router.attach(TOKENAUTHENTICATORURI, TokenAuthServerResource.class);
application.setInboundRoot(router);
}