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


Java Auth类代码示例

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


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

示例1: heartbeat

import io.dropwizard.auth.Auth; //导入依赖的package包/类
/**
 * Agent和Server之间的心跳,可以1分钟或更长时间一次,传回Monitor的信息,返回MonitorJob信息
 *
 * @param monitorId
 * @param monitor
 * @return
 */
@POST
@Path("/monitor/{monitorId}/heartbeat")
public RestfulReturnResult heartbeat(@Auth OAuthUser user, @PathParam("monitorId") String monitorId, @NotNull @Valid Monitor monitor) {
    if (!monitorId.equals(monitor.getMonitorId())) {
        log.error("monitor id in path {} and json {} and parameter not match error.", monitorId, monitor.getMonitorId());
        return new RestfulReturnResult(new NiPingException(MonitoridNotMatchError), null);
    }

    monitor.setMonitorId(monitorId);
    monitor.setAccountId(user.getAccountId());

    log.info("user {} monitorId {} send heartbeat {}", user, monitorId, monitor);
    monitorService.heartbeat(monitor);
    Optional<MonitorJob> job = Optional.empty();
    try {
        monitorService.saveMonitor(monitor);
        job = taskService.getNextJob(monitorId, monitor.getRunningTaskIds());
        if (log.isInfoEnabled() && job.isPresent()) {
            log.info("user {} monitorId {} get next job {}", user, monitorId, job.get());
        }
    } catch (NiPingException e) {
        return new RestfulReturnResult(e, job.orElse(null));
    }
    return new RestfulReturnResult(SUCCESS, job.orElse(null));
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:33,代码来源:MonitorResource.java

示例2: result

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@POST
@Path("/monitor/{monitorId}/result")
public RestfulReturnResult result(@Auth OAuthUser user, @PathParam("monitorId") String monitorId, @NotNull @Valid MonitorNiPingResult
        monitorNiPingResult) {
    if (!monitorId.equals(monitorNiPingResult.getMonitorId())) {
        log.error("monitor id in path {} and json {} and parameter not match error.", monitorId, monitorNiPingResult.getMonitorId());
        return new RestfulReturnResult(new NiPingException(MonitoridNotMatchError), null);
    }

    monitorNiPingResult.setAccountId(user.getAccountId());
    monitorNiPingResult.setMonitorId(monitorId);
    try {
        log.info("user {} save monitor NiPing result {}", user, monitorNiPingResult);
        taskService.saveMonitorNiPingResult(monitorNiPingResult);
    } catch (NiPingException e) {
        return new RestfulReturnResult(e, null);
    }
    return new RestfulReturnResult(SUCCESS, null);
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:20,代码来源:DatabusResource.java

示例3: search

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@POST
@Path(SEARCH_ENDPOINT)
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Timed
@UnitOfWork
public Response search(
        @NotNull @Auth User user,
        @NotNull @Valid SearchRequest searchRequest) {
    LOGGER.debug("Received search request");

    return performWithAuthorisation(
            user,
            searchRequest.getQuery().getDataSource(),
            () -> Response.ok(hBaseClient.query(searchRequest)).build());
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:17,代码来源:QueryResource.java

示例4: list

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@Override
@GET
@Produces(MediaType.APPLICATION_JSON)
/*@ApiOperation(httpMethod = "GET",
        value = "list all users",
        response = User.class,
        responseContainer = "List",
        nickname="list")*/
public List<User> list(@Auth PrincipalUser user, @QueryParam("filter") String filter) throws InternalErrorException {
    try {
        if(filter == null) {
            return userDAO.fetchById(null);
        } else {
            return userDAO.fetch(filter, User.class);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Error in getting users", e);
        throw new BadRequestException(e);
    }
}
 
开发者ID:sjsucohort6,项目名称:amigo-chatbot,代码行数:21,代码来源:UserResource.java

示例5: delete

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@Override
@DELETE
@Path("/{id}")
/*@ApiOperation(httpMethod = "DELETE",
        value = "delete a user",
        response = Response.class,
        nickname="delete")*/
@Produces(MediaType.APPLICATION_JSON)
public Response delete(@Auth PrincipalUser user, @PathParam("id") String id) throws ResourceNotFoundException, InternalErrorException {
    try {
        userDAO.deleteById(id);
        return Response.ok()
                .entity(Entity.json(id))
                .build();
    } catch (Exception e) {
        log.log(Level.SEVERE, "Error in getting users", e);
        throw new BadRequestException(e);
    }
}
 
开发者ID:sjsucohort6,项目名称:amigo-chatbot,代码行数:20,代码来源:UserResource.java

示例6: getByKey

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@GET
@Path("/{group}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "getByKey")
public Response getByKey(
    @Auth AuthPrincipal authPrincipal,
    @PathParam("group") String group
) throws AuthenticationException {

  final long start = System.currentTimeMillis();
  final Optional<Group> maybe = findGroup(group);

  if (maybe.isPresent()) {
    accessControlSupport.throwUnlessGrantedFor(authPrincipal, maybe.get());
    return headers.enrich(Response.ok(maybe.get()), start).build();
  }

  return headers.enrich(Response.status(404).entity(
      Problem.clientProblem(GroupResource.TITLE_NOT_FOUND, "", 404)), start).build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:22,代码来源:GroupResource.java

示例7: removeService

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@DELETE
@Path("/{group}/access/services/{service_key}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "removeService")
public Response removeService(
    @Auth AuthPrincipal authPrincipal,
    @PathParam("group") String groupKey,
    @PathParam("service_key") String serviceKey
) throws AuthenticationException {
  final long start = System.currentTimeMillis();

  final Optional<Group> maybe = findGroup(groupKey);

  if (maybe.isPresent()) {
    final Group group = maybe.get();
    accessControlSupport.throwUnlessGrantedFor(authPrincipal, group);
    final Group updated = groupService.removeServiceAccess(group, serviceKey);

    return headers.enrich(Response.ok(updated), start).build();
  }

  return headers.enrich(Response.status(404).entity(
      Problem.clientProblem(TITLE_NOT_FOUND, "", 404)), start).build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:26,代码来源:GroupResource.java

示例8: removeMember

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@DELETE
@Path("/{group}/access/members/{member_key}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "removeMember")
public Response removeMember(
    @Auth AuthPrincipal authPrincipal,
    @PathParam("group") String groupKey,
    @PathParam("member_key") String memberKey
) throws AuthenticationException {
  final long start = System.currentTimeMillis();

  final Optional<Group> maybe = findGroup(groupKey);

  if (maybe.isPresent()) {
    final Group group = maybe.get();
    accessControlSupport.throwUnlessGrantedFor(authPrincipal, group);
    final Group updated = groupService.removeMemberAccess(group, memberKey);

    return headers.enrich(Response.ok(updated), start).build();
  }

  return headers.enrich(Response.status(404).entity(
      Problem.clientProblem(TITLE_NOT_FOUND, "", 404)), start).build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:26,代码来源:GroupResource.java

示例9: updateFeature

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@POST
@Path("/{group}/{feature_key}")
@PermitAll
@Timed(name = "updateFeature")
public Response updateFeature(
    @Auth AuthPrincipal principal,
    @PathParam("group") String group,
    @PathParam("feature_key") String featureKey,
    Feature feature,
    @Context HttpHeaders httpHeaders
) throws AuthenticationException {

  final long start = System.currentTimeMillis();

  grantedGuard(principal, group);
  groupValidGuard(group, featureKey, feature);

  final Optional<String> maybeSeen = idempotencyChecker.extractKey(httpHeaders);
  if (maybeSeen.isPresent() && idempotencyChecker.seen(maybeSeen.get())) {
    return alreadyUpdated(feature, start, maybeSeen);
  }

  return headers.enrich(Response.ok(update(group, feature)), start).build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:25,代码来源:FeatureResource.java

示例10: getFeatureByKey

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@GET
@Path("/{group}/{feature_key}")
@PermitAll
@Timed(name = "getFeatureByKey")
public Response getFeatureByKey(
    @Auth AuthPrincipal principal,
    @PathParam("group") String group,
    @PathParam("feature_key") String featureKey
) throws AuthenticationException {

  final long start = System.currentTimeMillis();
  grantedGuard(principal, group);
  return headers.enrich(
      featureService.loadFeatureByKey(group, featureKey)
          .map(Response::ok)
          .orElseGet(this::featureNotFound), start).build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:18,代码来源:FeatureResource.java

示例11: subscribe

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@PermitAll
@GET
/**
 * Handle MQTT Subscribe Request in RESTful style
 * Granted QoS Levels will send back to client.
 * Retain Messages matched the subscriptions will NOT send back to client.
 */
public ResultEntity<List<Subscription>> subscribe(@PathParam("clientId") String clientId, @Auth UserPrincipal user) {
    List<Subscription> subscriptions = new ArrayList<>();

    // HTTP interface require valid Client Id
    if (!this.validator.isClientIdValid(clientId)) {
        logger.debug("Protocol violation: Client id {} not valid based on configuration", clientId);
        throw new ValidateException(new ErrorEntity(ErrorCode.INVALID));
    }

    // Read client's subscriptions from storage
    Map<String, MqttQoS> map = this.redis.getClientSubscriptions(clientId);
    map.forEach((topic, qos) -> subscriptions.add(new Subscription(topic, qos.value())));

    return new ResultEntity<>(subscriptions);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:23,代码来源:MqttSubscribeResource.java

示例12: tagStubs

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@Path("/tagStubs")
@GET
public Response tagStubs(@Auth Optional<User> user) {
    List<Source> sources;
    if (user.isPresent()) {
        User present = user.get();
        if (!articleDao.hasSubscriptions(present.getId())) {
            return Response.status(Response.Status.OK)
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(Collections.EMPTY_LIST)
                .build();
        } else {
            sources = articleDao.getSources(userDao.findByEmail(present.getEmail()).getId());
        }
    } else {
        sources = articleDao.getPublicSources();
    }

    Set<String> tags = sources.stream()
            .map(Source::getTags)
            .filter(Objects::nonNull)
            .flatMap(List::stream)
            .collect(Collectors.toSet());

    return Response.ok(tags).build();
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:27,代码来源:ArticleResource.java

示例13: profileWatches

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@GET
@Path("/watches")
public Collection<Watch> profileWatches(@Auth final User authUser) {
    return userRepo.findWatchesOfUser(authUser.getId()).stream()
            .map(Watch::new)
            .collect(toList());
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:8,代码来源:ProfileResource.java

示例14: removeProfileWatch

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@DELETE
@Path("/watches/{deviceId}")
public void removeProfileWatch(
        @Auth final User authUser,
        @PathParam("deviceId") final long deviceId
) {
    userRepo.removeWatch(deviceId, authUser.getId());
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:9,代码来源:ProfileResource.java

示例15: claimDevice

import io.dropwizard.auth.Auth; //导入依赖的package包/类
@POST
@Path("{deviceId:\\d+}/claims")
public Claim claimDevice(
        @PathParam("deviceId") final long deviceId,
        @Auth User user
) {
    final Device device = deviceRepo.findById(deviceId);
    final Claim newClaim = Claim.startingNow(device, user);
    return claimRepo.create(newClaim);
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:11,代码来源:DeviceClaimResource.java


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