Java 类com.codahale.metrics.annotation.Counted 实例源码

项目:springboot-shiro-cas-mybatis    文件:CentralAuthenticationServiceImpl.java   
@Audit(
    action="TICKET_GRANTING_TICKET",
    actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER",
    resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER")
@Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public TicketGrantingTicket createTicketGrantingTicket(final AuthenticationContext context)
        throws AuthenticationException, AbstractTicketException {

    final Authentication authentication = context.getAuthentication();
    final TicketGrantingTicketFactory factory = this.ticketFactory.get(TicketGrantingTicket.class);
    final TicketGrantingTicket ticketGrantingTicket = factory.create(authentication);

    this.ticketRegistry.addTicket(ticketGrantingTicket);

    doPublishEvent(new CasTicketGrantingTicketCreatedEvent(this, ticketGrantingTicket));

    return ticketGrantingTicket;
}
项目:springboot-shiro-cas-mybatis    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 * Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
 * Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
 * {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
 *
 * @param ticketGrantingTicketId the id of the ticket we want to destroy
 * @return the logout requests.
 */
@Audit(
        action="TICKET_GRANTING_TICKET_DESTROYED",
        actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
        resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
    try {
        logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
        final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
        logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
        final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
        this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
        return logoutRequests;
    } catch (final InvalidTicketException e) {
        logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
    }
    return Collections.emptyList();
}
项目:springboot-shiro-cas-mybatis    文件:CentralAuthenticationServiceImpl.java   
@Audit(
    action="SERVICE_TICKET",
    actionResolverName="GRANT_SERVICE_TICKET_RESOLVER",
    resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER")
@Timed(name = "GRANT_SERVICE_TICKET_TIMER")
@Metered(name="GRANT_SERVICE_TICKET_METER")
@Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true)
@Override
public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId,
    final Service service) throws TicketException {
    try {
        return this.grantServiceTicket(ticketGrantingTicketId, service, (Credential[]) null);
    } catch (final AuthenticationException e) {
        throw new IllegalStateException("Unexpected authentication exception", e);
    }
}
项目:springboot-shiro-cas-mybatis    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
项目:cas-5.1.0    文件:AbstractAuthenticationManager.java   
@Override
@Audit(
        action = "AUTHENTICATION",
        actionResolverName = "AUTHENTICATION_RESOLVER",
        resourceResolverName = "AUTHENTICATION_RESOURCE_RESOLVER")
@Timed(name = "AUTHENTICATE_TIMER")
@Metered(name = "AUTHENTICATE_METER")
@Counted(name = "AUTHENTICATE_COUNT", monotonic = true)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {
    AuthenticationCredentialsLocalBinder.bindCurrent(transaction.getCredentials());
    final AuthenticationBuilder builder = authenticateInternal(transaction);
    final Authentication authentication = builder.build();
    final Principal principal = authentication.getPrincipal();
    if (principal instanceof NullPrincipal) {
        throw new UnresolvedPrincipalException(authentication);
    }
    addAuthenticationMethodAttribute(builder, authentication);
    LOGGER.info("Authenticated principal [{}] with attributes [{}] via credentials [{}].",
            principal.getId(), principal.getAttributes(), transaction.getCredentials());
    populateAuthenticationMetadataAttributes(builder, transaction);
    final Authentication a = builder.build();
    AuthenticationCredentialsLocalBinder.bindCurrent(a);
    return a;
}
项目:cas-server-4.2.1    文件:PolicyBasedAuthenticationManager.java   
@Override
@Audit(
    action="AUTHENTICATION",
    actionResolverName="AUTHENTICATION_RESOLVER",
    resourceResolverName="AUTHENTICATION_RESOURCE_RESOLVER")
@Timed(name="AUTHENTICATE_TIMED")
@Metered(name="AUTHENTICATE_METER")
@Counted(name="AUTHENTICATE_COUNT", monotonic=true)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {

    final AuthenticationBuilder builder = authenticateInternal(transaction.getCredentials());
    final Authentication authentication = builder.build();
    final Principal principal = authentication.getPrincipal();
    if (principal instanceof NullPrincipal) {
        throw new UnresolvedPrincipalException(authentication);
    }

    addAuthenticationMethodAttribute(builder, authentication);

    logger.info("Authenticated {} with credentials {}.", principal, transaction.getCredentials());
    logger.debug("Attribute map for {}: {}", principal.getId(), principal.getAttributes());

    populateAuthenticationMetadataAttributes(builder, transaction.getCredentials());

    return builder.build();
}
项目:cas-server-4.2.1    文件:AbstractCentralAuthenticationService.java   
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
项目:cas-server-4.2.1    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 * Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
 * Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
 * {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
 *
 * @param ticketGrantingTicketId the id of the ticket we want to destroy
 * @return the logout requests.
 */
@Audit(
        action="TICKET_GRANTING_TICKET_DESTROYED",
        actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
        resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
    try {
        logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
        final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
        logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
        final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
        this.ticketRegistry.deleteTicket(ticketGrantingTicketId);

        doPublishEvent(new CasTicketGrantingTicketDestroyedEvent(this, ticket));

        return logoutRequests;
    } catch (final InvalidTicketException e) {
        logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
    }
    return Collections.emptyList();
}
项目:cas-server-4.2.1    文件:CentralAuthenticationServiceImpl.java   
@Audit(
    action="TICKET_GRANTING_TICKET",
    actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER",
    resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER")
@Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public TicketGrantingTicket createTicketGrantingTicket(final AuthenticationContext context)
        throws AuthenticationException, AbstractTicketException {

    final Authentication authentication = context.getAuthentication();
    final TicketGrantingTicketFactory factory = this.ticketFactory.get(TicketGrantingTicket.class);
    final TicketGrantingTicket ticketGrantingTicket = factory.create(authentication);

    this.ticketRegistry.addTicket(ticketGrantingTicket);

    doPublishEvent(new CasTicketGrantingTicketCreatedEvent(this, ticketGrantingTicket));

    return ticketGrantingTicket;
}
项目:referenceapp    文件:DeviceUiApplication.java   
@Timed(name = "deviceUI-addDevice")
@Counted(name = "deviceUI-Counter")
@RequestMapping(value = "/addDevice", method = RequestMethod.POST)
public
@ResponseBody
void addDevice(@ModelAttribute("devices") List<Device> devices, @RequestBody Device device) {

    //Archaius Dynamic Property Loading
    Boolean gatherStatistics = dynamicBooleanProperty.get();
    if (gatherStatistics) {
        requestsAddDeviceMetric.mark();
        timerAddDevice.time();
    }

    String identifier = idGeneratorService.generateIdentifier(serviceUrl() + "/device/idGenerator");
    device.setIdentifier(identifier);
    devices.add(device);

    if (gatherStatistics) { timerAddDevice.time().stop(); };
}
项目:cas4.1.9    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 * Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
 * Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an
 * {@link IllegalArgumentException} if the TicketGrantingTicket ID is null.
 *
 * @param ticketGrantingTicketId the id of the ticket we want to destroy
 * @return the logout requests.
 */
@Audit(
        action="TICKET_GRANTING_TICKET_DESTROYED",
        actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
        resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER")
@Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER")
@Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) {
    try {
        logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId);
        final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
        logger.debug("Ticket found. Processing logout requests and then deleting the ticket...");
        final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket);
        this.ticketRegistry.deleteTicket(ticketGrantingTicketId);

        return logoutRequests;
    } catch (final InvalidTicketException e) {
        logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId);
    }
    return Collections.emptyList();
}
项目:cas4.1.9    文件:CentralAuthenticationServiceImpl.java   
@Audit(
    action="SERVICE_TICKET",
    actionResolverName="GRANT_SERVICE_TICKET_RESOLVER",
    resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER")
@Timed(name = "GRANT_SERVICE_TICKET_TIMER")
@Metered(name="GRANT_SERVICE_TICKET_METER")
@Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true)
@Override
public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId,
    final Service service) throws TicketException {
    try {
        return this.grantServiceTicket(ticketGrantingTicketId, service, (Credential[]) null);
    } catch (final AuthenticationException e) {
        throw new IllegalStateException("Unexpected authentication exception", e);
    }
}
项目:cas4.1.9    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
项目:nikita-noark5-core    文件:AdministrativeUnitController.java   
@ApiOperation(value = "Retrieves all AdministrativeUnit ", response = AdministrativeUnit.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "AdministrativeUnit found",
                response = AdministrativeUnit.class),
        @ApiResponse(code = 404, message = "No AdministrativeUnit found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = ADMINISTRATIVE_UNIT)
public ResponseEntity<AdministrativeUnitHateoas> findAll(HttpServletRequest request) {
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(
            (ArrayList<INikitaEntity>) (ArrayList) administrativeUnitService.findAll());
    administrativeUnitHateoasHandler.addLinks(adminHateoas, request, new Authorisation());

    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(adminHateoas);
}
项目:nikita-noark5-core    文件:AdministrativeUnitController.java   
@ApiOperation(value = "Creates a suggested AdministrativeUnit", response = AdministrativeUnit.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "AdministrativeUnit codes found",
                response = AdministrativeUnit.class),
        @ApiResponse(code = 404, message = "No AdministrativeUnit found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = NEW_ADMINISTRATIVE_UNIT)
public ResponseEntity<AdministrativeUnitHateoas> getAdministrativeUnitTemplate(HttpServletRequest request) {
    AdministrativeUnit administrativeUnit = new AdministrativeUnit();
    administrativeUnit.setShortName("kortnavn på administrativtenhet");
    administrativeUnit.setAdministrativeUnitName("Formell navn på administrativtenhet");
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(administrativeUnit);
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(adminHateoas);
}
项目:nikita-noark5-core    文件:RegistryEntryHateoasController.java   
@ApiOperation(value = "Retrieves a single RegistryEntry entity given a systemId", response = RegistryEntry.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "RegistryEntry returned", response = RegistryEntry.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findOneRegistryEntrybySystemId(
        HttpServletRequest request,
        @ApiParam(name = "systemID",
                value = "systemID of the registryEntry to retrieve",
                required = true)
        @PathVariable("systemID") final String registryEntrySystemId) {
    RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(registryEntrySystemId);

    RegistryEntryHateoas registryEntryHateoas = new
            RegistryEntryHateoas(registryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .eTag(registryEntry.getVersion().toString())
            .body(registryEntryHateoas);
}
项目:nikita-noark5-core    文件:RegistryEntryHateoasController.java   
@ApiOperation(value = "Retrieves multiple RegistryEntry entities limited by ownership rights", notes = "The field skip" +
        "tells how many RegistryEntry rows of the result set to ignore (starting at 0), while  top tells how many rows" +
        " after skip to return. Note if the value of top is greater than system value " +
        " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ",
        response = RegistryEntryHateoas.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "RegistryEntry found",
                response = RegistryEntryHateoas.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findAllRegistryEntry(
        HttpServletRequest request,
        @RequestParam(name = "top", required = false) Integer top,
        @RequestParam(name = "skip", required = false) Integer skip) {
    RegistryEntryHateoas registryEntryHateoas = new
            RegistryEntryHateoas((ArrayList<INikitaEntity>) (ArrayList)
            registryEntryService.findRegistryEntryByOwnerPaginated(top, skip));
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(registryEntryHateoas);
}
项目:nikita-noark5-core    文件:RegistryEntryHateoasController.java   
@ApiOperation(value = "Deletes a single RegistryEntry entity identified by systemID", response = String.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = String.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS,
        method = RequestMethod.DELETE)
public ResponseEntity<String> deleteRecordBySystemId(HttpServletRequest request,
                                                     @ApiParam(name = "systemID",
                value = "systemID of the record to delete",
                required = true)
        @PathVariable("systemID") final String systemID) {

    RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(systemID);
    registryEntryService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, registryEntry));
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(CommonUtils.WebUtils.getSuccessStatusStringForDelete());
}
项目:nikita-noark5-core    文件:CorrespondencePartHateoasController.java   
@ApiOperation(value = "Deletes a single CorrespondencePartUnit entity identified by kode")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartUnit deleted"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + CODE + RIGHT_PARENTHESIS,
        method = RequestMethod.DELETE)
public ResponseEntity<String> deleteCorrespondencePartUnit(
        @ApiParam(name = "kode",
                value = "kode of the correspondencePartUnit to delete",
                required = true)
        @PathVariable("kode") final String kode) {
    correspondencePartService.deleteCorrespondencePartUnit(kode);
    return ResponseEntity.status(HttpStatus.OK)
            .body("{\"status\" : \"Success\"}");
}
项目:nikita-noark5-core    文件:CorrespondencePartHateoasController.java   
@ApiOperation(value = "Deletes a single CorrespondencePartPerson entity identified by kode")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartPerson deleted"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_PERSON + SLASH + LEFT_PARENTHESIS + CODE + RIGHT_PARENTHESIS,
        method = RequestMethod.DELETE)
public ResponseEntity<String> deleteCorrespondencePartPerson(
        @ApiParam(name = "kode",
                value = "kode of the correspondencePartPerson to delete",
                required = true)
        @PathVariable("kode") final String kode) {
    correspondencePartService.deleteCorrespondencePartPerson(kode);
    return ResponseEntity.status(HttpStatus.OK)
            .body("{\"status\" : \"Success\"}");
}
项目:nikita-noark5-core    文件:CorrespondencePartHateoasController.java   
@ApiOperation(value = "Deletes a single CorrespondencePartInternal entity identified by kode")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartInternal deleted"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_INTERNAL + SLASH + LEFT_PARENTHESIS + CODE + RIGHT_PARENTHESIS,
        method = RequestMethod.DELETE)
public ResponseEntity<String> deleteCorrespondencePartInternal(
        @ApiParam(name = "kode",
                value = "kode of the correspondencePartInternal to delete",
                required = true)
        @PathVariable("kode") final String kode) {
    correspondencePartService.deleteCorrespondencePartInternal(kode);
    return ResponseEntity.status(HttpStatus.OK)
            .body("{\"status\" : \"Success\"}");
}
项目:nikita-noark5-core    文件:DocumentMediumController.java   
@ApiOperation(value = "Retrieves all DocumentMedium ", response = DocumentMedium.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "DocumentMedium codes found",
                response = DocumentMedium.class),
        @ApiResponse(code = 404, message = "No DocumentMedium found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    //ArrayList <DocumentMedium> documentMediumList = (ArrayList<DocumentMedium>) documentMediumService.findAll2();
    MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(documentMediumService.findAll2()), DOCUMENT_MEDIUM);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:DocumentMediumController.java   
@ApiOperation(value = "Gets documentMedium identified by its systemId", notes = "Returns the requested " +
        " documentMedium object", response = DocumentMedium.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "DocumentMedium " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = DocumentMedium.class),
        @ApiResponse(code = 201, message = "DocumentMedium " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED,
                response = DocumentMedium.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR),
        @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED)})
@Counted
@Timed
@RequestMapping(value = DOCUMENT_MEDIUM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId,
                                                                     HttpServletRequest request) {
    DocumentMedium documentMedium = documentMediumService.findBySystemIdOrderBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentMedium);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .eTag(documentMedium.getVersion().toString())
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:DocumentMediumController.java   
@ApiOperation(value = "Creates a suggested DocumentMedium", response = DocumentMedium.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "DocumentMedium codes found",
                response = DocumentMedium.class),
        @ApiResponse(code = 404, message = "No DocumentMedium found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = NEW_DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> getDocumentMediumTemplate(HttpServletRequest request) {
    DocumentMedium documentMedium = new DocumentMedium();
    documentMedium.setCode(TEMPLATE_DOCUMENT_MEDIUM_CODE);
    documentMedium.setDescription(TEMPLATE_DOCUMENT_MEDIUM_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentMedium);
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:DocumentMediumController.java   
@ApiOperation(value = "Updates a DocumentMedium object", notes = "Returns the newly" +
        " updated DocumentMedium object after it is persisted to the database", response = DocumentMedium.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "DocumentMedium " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = DocumentMedium.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = DOCUMENT_MEDIUM + SLASH + DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> updateDocumentMedium(@RequestBody DocumentMedium documentMedium,
                                                            HttpServletRequest request)
        throws NikitaException {
    DocumentMedium newDocumentMedium = documentMediumService.update(documentMedium);
    MetadataHateoas metadataHateoas = new MetadataHateoas(documentMedium);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:CorrespondencePartTypeController.java   
@ApiOperation(value = "Retrieves all CorrespondencePartType ", response = CorrespondencePartType.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartType codes found",
                response = CorrespondencePartType.class),
        @ApiResponse(code = 404, message = "No CorrespondencePartType found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(correspondencePartTypeService.findAllAsList()),
            CORRESPONDENCE_PART_TYPE);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:CorrespondencePartTypeController.java   
@ApiOperation(value = "Creates a suggested CorrespondencePartType", response = CorrespondencePartType.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartType codes found",
                response = CorrespondencePartType.class),
        @ApiResponse(code = 404, message = "No CorrespondencePartType found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = NEW_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> getCorrespondencePartTypeTemplate(HttpServletRequest request) {
    CorrespondencePartType correspondencePartType = new CorrespondencePartType();
    correspondencePartType.setCode(TEMPLATE_FONDS_STATUS_CODE);
    correspondencePartType.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:CorrespondencePartTypeController.java   
@ApiOperation(value = "Updates a CorrespondencePartType object", notes = "Returns the newly" +
        " updated CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = CorrespondencePartType.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = CORRESPONDENCE_PART_TYPE + UNIT + SLASH + LEFT_PARENTHESIS +
        SYSTEM_ID + RIGHT_PARENTHESIS)
public ResponseEntity<MetadataHateoas> updateCorrespondencePartTypeUnit(
        @RequestBody CorrespondencePartType correspondencePartType,
        HttpServletRequest request)
        throws NikitaException {
    CorrespondencePartType updatedCorrespondencePartType = correspondencePartTypeService.update(correspondencePartType);
    MetadataHateoas metadataHateoas = new MetadataHateoas(updatedCorrespondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .eTag(correspondencePartType.getVersion().toString())
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:CorrespondencePartTypeController.java   
@ApiOperation(value = "Deletes a single CorrespondencePartType entity identified by kode")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "CorrespondencePartType deleted"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + CODE + RIGHT_PARENTHESIS,
        method = RequestMethod.DELETE)
public ResponseEntity<String> deletecorrespondencePartTypeByCode(
        @ApiParam(name = "kode",
                value = "kode of the correspondencePartType to delete",
                required = true)
        @PathVariable("kode") final String kode) {
    correspondencePartTypeService.deleteEntity(kode);
    return ResponseEntity.status(HttpStatus.OK)
            .body("{\"status\" : \"Success\"}");
}
项目:nikita-noark5-core    文件:FondsStatusController.java   
@ApiOperation(value = "Retrieves all FondsStatus ", response = FondsStatus.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "FondsStatus codes found",
                response = FondsStatus.class),
        @ApiResponse(code = 404, message = "No FondsStatus found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = FONDS_STATUS)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(fondsStatusService.findAllAsList()),
            FONDS_STATUS);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());

    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:FondsStatusController.java   
@ApiOperation(value = "Gets fondsStatus identified by its systemId", notes = "Returns the requested " +
        " fondsStatus object", response = FondsStatus.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "FondsStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = FondsStatus.class),
        @ApiResponse(code = 201, message = "FondsStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED,
                response = FondsStatus.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR),
        @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED)})
@Counted
@Timed
@RequestMapping(value = FONDS_STATUS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId,
                                                                     HttpServletRequest request) {
    FondsStatus fondsStatus = fondsStatusService.findBySystemIdOrderBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .eTag(fondsStatus.getVersion().toString())
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:FondsStatusController.java   
@ApiOperation(value = "Creates a suggested FondsStatus", response = FondsStatus.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "FondsStatus codes found",
                response = FondsStatus.class),
        @ApiResponse(code = 404, message = "No FondsStatus found"),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = NEW_FONDS_STATUS)
public ResponseEntity<MetadataHateoas> getFondsStatusTemplate(HttpServletRequest request) {
    FondsStatus fondsStatus = new FondsStatus();
    fondsStatus.setCode(TEMPLATE_FONDS_STATUS_CODE);
    fondsStatus.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:FondsStatusController.java   
@ApiOperation(value = "Updates a FondsStatus object", notes = "Returns the newly" +
        " updated FondsStatus object after it is persisted to the database", response = FondsStatus.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "FondsStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = FondsStatus.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = FONDS_STATUS + SLASH + FONDS_STATUS)
public ResponseEntity<MetadataHateoas> updateFondsStatus(@RequestBody FondsStatus fondsStatus,
                                                         HttpServletRequest request)
        throws NikitaException {
    FondsStatus newFondsStatus = fondsStatusService.update(fondsStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK)
            .allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
            .body(metadataHateoas);
}
项目:nikita-noark5-core    文件:FondsImportController.java   
@ApiOperation(value = "Persists a Fonds object", notes = "Returns the newly" +
        " created Fonds object after it is persisted to the database", response = FondsHateoas.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED,
                response = FondsHateoas.class),
        @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED,
                response = FondsHateoas.class),
        @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER),
        @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER),
        @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type Fonds"),
        @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT),
        @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR)})
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = NEW_FONDS)
public ResponseEntity<FondsHateoas> createFonds(
        @ApiParam(name = "fonds",
                value = "Incoming fonds object",
                required = true)
        @RequestBody Fonds fonds)  throws NikitaException {
    Fonds createdFonds = fondsImportService.createNewFonds(fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(createdFonds);
    return new ResponseEntity<> (fondsHateoas, HttpStatus.CREATED);
}
项目:cas-mfa    文件:MultiFactorAwareCentralAuthenticationService.java   
@Override
@Audit(
        action="TICKET_GRANTING_TICKET",
        actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER",
        resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER")
@Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER")
@Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
public TicketGrantingTicket createTicketGrantingTicket(final Credential... credentials) throws TicketException {
    final MultiFactorCredentials mfaCredentials = (MultiFactorCredentials) credentials[0];
    final Authentication authentication = mfaCredentials.getAuthentication();

    if (authentication == null) {
        throw new TicketCreationException(new RuntimeException("Authentication cannot be null"));
    }
    final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(
            this.ticketGrantingTicketUniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX),
            authentication,
            this.ticketGrantingTicketExpirationPolicy);

    this.ticketRegistry.addTicket(ticketGrantingTicket);
    return ticketGrantingTicket;
}
项目:metrics-cdi    文件:MetricsInterceptor.java   
private <E extends Member & AnnotatedElement> void registerMetrics(Class<?> bean, E element) {
    MetricResolver.Of<Counted> counted = resolver.counted(bean, element);
    if (counted.isPresent())
        registry.counter(counted.metricName());

    MetricResolver.Of<ExceptionMetered> exceptionMetered = resolver.exceptionMetered(bean, element);
    if (exceptionMetered.isPresent())
        registry.meter(exceptionMetered.metricName());

    MetricResolver.Of<Metered> metered = resolver.metered(bean, element);
    if (metered.isPresent())
        registry.meter(metered.metricName());

    MetricResolver.Of<Timed> timed = resolver.timed(bean, element);
    if (timed.isPresent())
        registry.timer(timed.metricName());
}
项目:metrics-cdi    文件:MetricResolver.java   
private String metricName(Annotation annotation) {
    if (CachedGauge.class.isInstance(annotation))
        return ((CachedGauge) annotation).name();
    else if (Counted.class.isInstance(annotation))
        return ((Counted) annotation).name();
    else if (ExceptionMetered.class.isInstance(annotation))
        return ((ExceptionMetered) annotation).name();
    else if (Gauge.class.isInstance(annotation))
        return ((Gauge) annotation).name();
    else if (Metered.class.isInstance(annotation))
        return ((Metered) annotation).name();
    else if (Timed.class.isInstance(annotation))
        return ((Timed) annotation).name();
    else
        throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]");
}
项目:metrics-cdi    文件:MetricResolver.java   
private boolean isMetricAbsolute(Annotation annotation) {
    if (extension.getParameters().contains(MetricsParameter.useAbsoluteName))
        return true;

    if (CachedGauge.class.isInstance(annotation))
        return ((CachedGauge) annotation).absolute();
    else if (Counted.class.isInstance(annotation))
        return ((Counted) annotation).absolute();
    else if (ExceptionMetered.class.isInstance(annotation))
        return ((ExceptionMetered) annotation).absolute();
    else if (Gauge.class.isInstance(annotation))
        return ((Gauge) annotation).absolute();
    else if (Metered.class.isInstance(annotation))
        return ((Metered) annotation).absolute();
    else if (Timed.class.isInstance(annotation))
        return ((Timed) annotation).absolute();
    else
        throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]");
}
项目:springboot-shiro-cas-mybatis    文件:PolicyBasedAuthenticationManager.java   
@Override
@Audit(
    action="AUTHENTICATION",
    actionResolverName="AUTHENTICATION_RESOLVER",
    resourceResolverName="AUTHENTICATION_RESOURCE_RESOLVER")
@Timed(name="AUTHENTICATE_TIMED")
@Metered(name="AUTHENTICATE_METER")
@Counted(name="AUTHENTICATE_COUNT", monotonic=true)
public Authentication authenticate(final AuthenticationTransaction transaction) throws AuthenticationException {

    final AuthenticationBuilder builder = authenticateInternal(transaction.getCredentials());
    final Authentication authentication = builder.build();
    final Principal principal = authentication.getPrincipal();
    if (principal instanceof NullPrincipal) {
        throw new UnresolvedPrincipalException(authentication);
    }

    addAuthenticationMethodAttribute(builder, authentication);

    logger.info("Authenticated {} with credentials {}.", principal, transaction.getCredentials());
    logger.debug("Attribute map for {}: {}", principal.getId(), principal.getAttributes());

    populateAuthenticationMetadataAttributes(builder, transaction.getCredentials());

    return builder.build();
}
项目:springboot-shiro-cas-mybatis    文件:AbstractCentralAuthenticationService.java   
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Transactional(readOnly = true, transactionManager = "ticketTransactionManager")
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}