当前位置: 首页>>代码示例>>Java>>正文


Java Verifier类代码示例

本文整理汇总了Java中org.restlet.security.Verifier的典型用法代码示例。如果您正苦于以下问题:Java Verifier类的具体用法?Java Verifier怎么用?Java Verifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Verifier类属于org.restlet.security包,在下文中一共展示了Verifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticate

import org.restlet.security.Verifier; //导入依赖的package包/类
public LoggedInUserImpl authenticate(String userName, String password) {
  LoggedInUserImpl loggedInUser = null;
  if (Verifier.RESULT_VALID == identityService.checkPassword(userName, password)) {
    User user = identityService.createUserQuery().userId(userName).singleResult();
    // Fetch and cache user data
    loggedInUser = new LoggedInUserImpl(user, password);
    List<Group> groups = identityService.createGroupQuery().groupMember(user.getId()).list();
    for (Group group : groups) {
      if (Constants.SECURITY_ROLE.equals(group.getType())) {
        loggedInUser.addSecurityRoleGroup(group);
        if (Constants.SECURITY_ROLE_USER.equals(group.getId())) {
          loggedInUser.setUser(true);
        }
        if (Constants.SECURITY_ROLE_ADMIN.equals(group.getId())) {
          loggedInUser.setAdmin(true);
        }
      } else {
        loggedInUser.addGroup(group);
      }
    }
  }
  
  return loggedInUser;
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:25,代码来源:DefaultLoginHandler.java

示例2: authenticate

import org.restlet.security.Verifier; //导入依赖的package包/类
@Override
protected boolean authenticate(Request request, Response response) {

	Cookie cookie = CookieUtils.extractAuthnCookie(request);

	boolean isTokenValid = false;
	if(CookieUtils.isMachine(cookie)) {
		isTokenValid = CookieUtils.verifyAuthnCookie(cookie) == Verifier.RESULT_VALID;
	} else {
		Map<String, String> claimsInToken = CookieUtils.claimsInToken(cookie);
		isTokenValid = !claimsInToken.isEmpty() && claimsInToken.containsKey(CookieUtils.COOKIE_USERNAME);
	}

	if (isTokenValid) {
		return handleValid(request, cookie);
	} else {
		return handleNotValid(request, response);
	}
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:20,代码来源:CookieAuthenticator.java

示例3: createInboundRoot

import org.restlet.security.Verifier; //导入依赖的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 );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:40,代码来源:PolygeneRestApplication.java

示例4: RestComponent

import org.restlet.security.Verifier; //导入依赖的package包/类
@Inject
public RestComponent(@Hello Application helloApp, @Car Application carApp, Verifier authTokenVerifier) {
    getClients().add(Protocol.HTTPS);
    Server secureServer = getServers().add(Protocol.HTTPS, 8043);
    Series<Parameter> parameters = secureServer.getContext().getParameters();
    parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory");
    parameters.add("keyStorePath", System.getProperty("javax.net.ssl.keyStorePath"));
    getDefaultHost().attach("/api/hello", secure(helloApp, authTokenVerifier, "ame"));
    getDefaultHost().attach("/api/cars", secure(carApp, authTokenVerifier, "ame"));
    replaceConverter(JacksonConverter.class, new JacksonCustomConverter());
}
 
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:12,代码来源:RestComponent.java

示例5: secure

import org.restlet.security.Verifier; //导入依赖的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;
}
 
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:8,代码来源:RestComponent.java

示例6: checkPassword

import org.restlet.security.Verifier; //导入依赖的package包/类
public int checkPassword(String userId, String password) {
  User user = findUserById(userId);
  if ((user != null) && (password != null) && (password.equals(user.getPassword()))) {
    return Verifier.RESULT_VALID;
  }
  return Verifier.RESULT_INVALID;
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:8,代码来源:UserManager.java

示例7: testAuthentication

import org.restlet.security.Verifier; //导入依赖的package包/类
public void testAuthentication() {
  User user = identityService.newUser("johndoe");
  user.setPassword("xxx");
  identityService.saveUser(user);

  assertEquals(Verifier.RESULT_VALID, identityService.checkPassword("johndoe", "xxx"));
  assertEquals(Verifier.RESULT_INVALID, identityService.checkPassword("johndoe", "invalid pwd"));

  identityService.deleteUser("johndoe");
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:11,代码来源:IdentityTest.java

示例8: createVerifier

import org.restlet.security.Verifier; //导入依赖的package包/类
protected Verifier createVerifier()
{
    return null;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:5,代码来源:PolygeneRestApplication.java

示例9: configure

import org.restlet.security.Verifier; //导入依赖的package包/类
@Override
protected void configure() {
    bind(Verifier.class).to(AuthTokenVerifier.class);
}
 
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:5,代码来源:RestletInfraModule.java

示例10: createInboundRoot

import org.restlet.security.Verifier; //导入依赖的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;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:73,代码来源:ActivitiRestApplication.java

示例11: AlterableStatusCodeChallengeAuthenticator

import org.restlet.security.Verifier; //导入依赖的package包/类
public AlterableStatusCodeChallengeAuthenticator(Context context, boolean optional, ChallengeScheme challengeScheme, String realm, Verifier verifier) {
    super(context, optional, challengeScheme, realm, verifier);
}
 
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:4,代码来源:AlterableStatusCodeChallengeAuthenticator.java

示例12: testCheckPasswordNullSafe

import org.restlet.security.Verifier; //导入依赖的package包/类
public void testCheckPasswordNullSafe() {
  assertEquals(Verifier.RESULT_INVALID, identityService.checkPassword("userId", null));
  assertEquals(Verifier.RESULT_INVALID, identityService.checkPassword(null, "passwd"));
  assertEquals(Verifier.RESULT_INVALID, identityService.checkPassword(null, null));
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:6,代码来源:IdentityServiceTest.java

示例13: login

import org.restlet.security.Verifier; //导入依赖的package包/类
@Post
public LoginResponse login(LoginInfo loginInfo) {
  if(loginInfo == null) {
    throw new ActivitiException("No login info supplied");
  }
  
  if(loginInfo.getUserId() == null) {
    throw new ActivitiException("No user id supplied");
  }
  
  if(loginInfo.getPassword() == null) {
    throw new ActivitiException("No password supplied");
  }
  
  ProcessEngine pe = ActivitiUtil.getProcessEngine();
  if (pe != null) {
    if (pe.getIdentityService().checkPassword(loginInfo.getUserId(), loginInfo.getPassword()) != Verifier.RESULT_VALID) {
      throw new ActivitiException("Username and password does not match.");
    }
    return new LoginResponse().setSuccess(true);
  
  } else {
    String message;
    ProcessEngineInfo pei = ActivitiUtil.getProcessEngineInfo();
    if (pei != null) {
      message = pei.getException();
    }
    else {
      message = "Can't find process engine which is needed to authenticate username and password.";
      List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
      if (processEngineInfos.size() > 0) {
        message += "\nHowever " + processEngineInfos.size() + " other process engine(s) were found: ";
      }
      for (ProcessEngineInfo processEngineInfo : processEngineInfos)
      {
        message += "Process engine '" + processEngineInfo.getName() + "' (" + processEngineInfo.getResourceUrl() + "):";
        if (processEngineInfo.getException() != null) {
          message += processEngineInfo.getException();
        }
        else {
          message += "OK";
        }
      }
    }
    throw new ActivitiException(message);
  }
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:48,代码来源:LoginResource.java

示例14: createInboundRoot

import org.restlet.security.Verifier; //导入依赖的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;
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:63,代码来源:SimpleRestApplication.java

示例15: onStart

import org.restlet.security.Verifier; //导入依赖的package包/类
@Override
public void onStart() {
    try {
        super.onStart();
        component = new Component();
        component.getClients().add(Protocol.FILE);
        //TODO: To test with the restlet 2.1 Maybe the maxTotalConnections could be avoided
        // see: http://restlet-discuss.1400322.n2.nabble.com/rejectedExecution-td4513620.html 
        //component.getServers().add(Protocol.HTTP, SERVER_PORT);
        Server server = new Server(Protocol.HTTP, SERVER_PORT);
        component.getServers().add(server);
        server.getContext().getParameters().add("maxTotalConnections", "50");
        //end TODO
        
        // enable SSL 
        Server SSLserver = new Server(Protocol.HTTPS, configuration.getIntProperty("SSL_PORT", SERVER_PORT + 2 ));
        component.getServers().add(SSLserver);
        Series<Parameter> parameters = SSLserver.getContext().getParameters();
        parameters.add("sslContextFactory", "org.restlet.ext.ssl.PkixSslContextFactory");
        // Certificate's data is taken from config file
        parameters.add("keystorePath", new File(this.getFile().getParent() + "/data/" + configuration.getStringProperty("KEYSTORE_FILE", "keystore")).getAbsolutePath());
        parameters.add("keystorePassword", configuration.getStringProperty("KEYSTORE_PASSWORD", "password"));
        parameters.add("keyPassword", configuration.getStringProperty("KEYSTORE_PASSWORD", "password"));
        parameters.add("keystoreType", configuration.getStringProperty("KEYSTORE_TYPE", "JKS")); 
        // end enable SSL
        
        // Engine.getInstance().getRegisteredServers().clear();
        // Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(server));
        // Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(SSLserver));
        component.getClients().add(Protocol.FILE);
        
        OriginFilter originFilter = new OriginFilter(component.getContext().createChildContext(),this);
        Application FDapp =  new FreedomRestServer(Info.PATHS.PATH_RESOURCES_FOLDER.getAbsolutePath(), component.getContext().createChildContext());  
        
        if (getApi().getAuth().isInited()) {
            // Instantiates a Verifier of identifier/secret couples based on Freedomotic Auth
            Verifier v = new SecretVerifier() {
                @Override
                public int verify(String identifier, char[] secret) {
                    if (getApi().getAuth().login(identifier, secret)) {
                        return RESULT_VALID;
                    }
                    return RESULT_INVALID;
                }
            };
            // Guard the restlet with BASIC authentication.
            ChallengeAuthenticator guard = new ChallengeAuthenticator(component.getContext().createChildContext(), false, ChallengeScheme.HTTP_BASIC, "testRealm", v);
            
            // WIP: Guard the restlet with DIGEST authentication.
            DigestAuthenticator dguard = new DigestAuthenticator(component.getContext().createChildContext(), "DigestRealm", configuration.getStringProperty("DIGEST_SECRET", "s3cr3t"));
            dguard.setOptional(true);
            // TODO: set proper verifier before enabling DIGEST AUTH.                
            
            originFilter.setNext(guard);
            guard.setNext(FDapp);
            
        } else {
            originFilter.setNext(FDapp);
        }

        component.getDefaultHost().attachDefault(originFilter);
        component.start();
        freedomoticApi = getApi();
    } catch (Exception ex) {
        Logger.getLogger(RestApi.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:69,代码来源:RestApi.java


注:本文中的org.restlet.security.Verifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。