Example usage for org.aspectj.lang JoinPoint getStaticPart

List of usage examples for org.aspectj.lang JoinPoint getStaticPart

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint getStaticPart.

Prototype

StaticPart getStaticPart();

Source Link

Usage

From source file:cn.org.once.cstack.aspects.SecurityAnnotationAspect.java

License:Open Source License

@Before("@annotation(CloudUnitSecurable) && args(applicationName)")
public void verifyRelationBetweenUserAndApplication(JoinPoint joinPoint, String applicationName) {

    UserDetails principal = null;/*  w ww . jav a 2s.  c o m*/
    JsonInput jsonInput = null;
    try {
        principal = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        User user = userService.findByLogin(principal.getUsername());

        if (joinPoint.getArgs() == null) {
            logger.error("Error on annotation aspect : " + joinPoint.getStaticPart().getSignature());
        } else {
            if (joinPoint.getArgs()[0] instanceof JsonInput) {
                jsonInput = (JsonInput) joinPoint.getArgs()[0];
                applicationName = jsonInput.getApplicationName();
            }
            Application application = applicationService.findByNameAndUser(user, applicationName);
            if (application == null) {
                throw new IllegalArgumentException(
                        "This application does not exist on this account : " + applicationName + "," + user);
            }
        }

    } catch (ServiceException | CheckException e) {
        logger.error(principal.toString() + ", " + jsonInput, e);
    }

}

From source file:com.alejandroszlv.mock.repository.aop.MockAopRepository.java

@Before("within(com.alejandroszlv.mock.repository..*)")
public void inRestController(JoinPoint joinPoint) {
    LOGGER.info("Start {}", joinPoint.getStaticPart().toString());
}

From source file:com.alejandroszlv.mock.repository.aop.MockAopRepository.java

@After("within(com.alejandroszlv.mock.repository..*)")
public void afterRestController(JoinPoint joinPoint) {
    LOGGER.info("End {}", joinPoint.getStaticPart().toString());
}

From source file:com.alejandroszlv.mock.srv.aop.MockAopService.java

@Before("within(com.alejandroszlv.mock.srv..*)")
public void inRestController(JoinPoint joinPoint) {
    LOGGER.info("Start {}", joinPoint.getStaticPart().toString());
}

From source file:com.alejandroszlv.mock.srv.aop.MockAopService.java

@After("within(com.alejandroszlv.mock.srv..*)")
public void afterRestController(JoinPoint joinPoint) {
    LOGGER.info("End {}", joinPoint.getStaticPart().toString());
}

From source file:com.alejandroszlv.mock.web.aop.LoggerAopController.java

@Before("within(com.alejandroszlv.mock.web.controller..*)")
public void before(JoinPoint joinPoint) {
    LOGGER.info("Start {}", joinPoint.getStaticPart().toString());
}

From source file:com.alejandroszlv.mock.web.aop.LoggerAopController.java

@After("within(com.alejandroszlv.mock.web.controller..*)")
public void after(JoinPoint joinPoint) {
    LOGGER.info("End {}", joinPoint.getStaticPart().toString());
}

From source file:com.er.moc.eca.aspect.SecurityAspect.java

@Before("execution(* com.er.moc.eca.controller..* (..))")
public void checkVoucher(JoinPoint point) {
    boolean isSecurity = false;
    for (String str : ((CodeSignature) point.getStaticPart().getSignature()).getParameterNames()) {
        System.out.println("nome: " + str);
        if (str.equals("key")) {
            isSecurity = true;/*  www  . j ava 2  s.c  o  m*/
        }
    }
    if (!isSecurity) {
        return;
    }

    for (Object obj : point.getArgs()) {

        if (AuthControl.vouchers.containsKey(obj.toString())) {
            AuthControl.vouchers.get(obj.toString()).newInteraction();
            return;
        }

    }
    throw new ForbiddenException();
}

From source file:com.eurodyn.qlack2.fuse.idm.api.aspects.ValidateTicketAspect.java

License:EUPL

@Before("validateTicketPointCut()")
public void ticketRequiredAction(JoinPoint pjp) throws Throwable {
    ValidateTicket annotation = ((MethodSignature) pjp.getStaticPart().getSignature()).getMethod()
            .getAnnotation(ValidateTicket.class);
    int requestIndex = annotation.requestIndex();
    String idmServiceField = annotation.idmServiceField();
    QSignedRequest sreq = (QSignedRequest) pjp.getArgs()[requestIndex];

    if (sreq.getSignedTicket() != null) {
        LOGGER.log(Level.FINEST, "Validating ticket {0}", sreq.getSignedTicket().toString());
        Field idmField = pjp.getTarget().getClass().getDeclaredField(idmServiceField);
        idmField.setAccessible(true);/*from   w  w w . j  av  a2s .  c  o  m*/
        IDMService idmService = (IDMService) idmField.get(pjp.getTarget());
        if (!idmService.validateTicket(new ValidateTicketRequest(sreq.getSignedTicket())).isValid()) {
            throw new QInvalidTicketException(sreq.getSignedTicket());
        }
    } else {
        LOGGER.log(Level.FINEST, "No ticket found.");
        throw new QInvalidTicketException(sreq.getSignedTicket());
    }
}

From source file:com.eurodyn.qlack2.util.validator.util.aspect.ValidateSingleArgumentAspect.java

License:EUPL

@Before("validateObjectPointCut()")
public void validateObjectAroundAction(JoinPoint jp) throws Throwable {
    ValidateSingleArgument annotation = ((MethodSignature) jp.getStaticPart().getSignature()).getMethod()
            .getAnnotation(ValidateSingleArgument.class);
    int requestIndex = annotation.requestIndex();
    // Get a reference to the object to be validated.
    Object obj = (jp.getArgs()[requestIndex]);

    // Validate.//from   ww w. j a v  a  2  s. c o m
    ValidationErrors errors = validationUtil.validate(obj);

    if (errors.getValidationErrors().size() > 0) {
        throw new QValidationException(errors);
    }
}