Search in sources :

Example 1 with TokenExtractionMode

use of org.sklsft.commons.rest.security.tokens.TokenExtractionMode in project skeleton-commons by skeleton-software-community.

the class AccessControlAspect method handleHandshake.

@Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
public Object handleHandshake(ProceedingJoinPoint joinPoint) throws Throwable {
    try {
        AccessControlType accessControlType = getAccessControlType(joinPoint);
        TokenExtractionMode tokenExtractionMode = getTokenExtractionMode(joinPoint);
        accessController.handshake(accessControlType, tokenExtractionMode);
        return joinPoint.proceed();
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        throw t;
    } finally {
        securityContextProvider.clearSecurityContext();
    }
}
Also used : TokenExtractionMode(org.sklsft.commons.rest.security.tokens.TokenExtractionMode) AccessControlType(org.sklsft.commons.rest.security.access.AccessControlType) Around(org.aspectj.lang.annotation.Around)

Example 2 with TokenExtractionMode

use of org.sklsft.commons.rest.security.tokens.TokenExtractionMode in project skeleton-commons by skeleton-software-community.

the class AccessControlAspect method getTokenExtractionMode.

private TokenExtractionMode getTokenExtractionMode(ProceedingJoinPoint joinPoint) {
    TokenExtractionMode tokenExtractionMode = TokenExtractionMode.HEADER;
    Method proxiedMethod = ((MethodSignature) joinPoint.getSignature()).getMethod();
    AccessControl accessControl = proxiedMethod.getAnnotation(AccessControl.class);
    if (accessControl != null) {
        tokenExtractionMode = accessControl.tokenExtractionMode();
    }
    return tokenExtractionMode;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) TokenExtractionMode(org.sklsft.commons.rest.security.tokens.TokenExtractionMode) Method(java.lang.reflect.Method) AccessControl(org.sklsft.commons.rest.security.annotations.AccessControl)

Aggregations

TokenExtractionMode (org.sklsft.commons.rest.security.tokens.TokenExtractionMode)2 Method (java.lang.reflect.Method)1 Around (org.aspectj.lang.annotation.Around)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1 AccessControlType (org.sklsft.commons.rest.security.access.AccessControlType)1 AccessControl (org.sklsft.commons.rest.security.annotations.AccessControl)1