List of usage examples for org.springframework.security.web.access.expression DefaultWebSecurityExpressionHandler createEvaluationContext
EvaluationContext createEvaluationContext(Authentication authentication, T invocation);
From source file:it.scoppelletti.programmerpower.web.view.AuthorizeComponent.java
/** * Emette l’apertura del tag e verifica se deve essere emesso il * contenuto del tag stesso.//from w w w .j av a 2 s . c o m * * @param writer Flusso di scrittura. * @return Esito della verifica. */ @Override public boolean start(Writer writer) { Authentication currentUser; FilterInvocation filter; Expression accessExpr; DefaultWebSecurityExpressionHandler exprHandler; if (Strings.isNullOrEmpty(myAccess)) { throw new PropertyNotSetException(toString(), "access"); } currentUser = SecurityContextHolder.getContext().getAuthentication(); if (currentUser == null) { throw new ObjectNotFoundException(Authentication.class.getName()); } exprHandler = getExpressionHandler(); accessExpr = exprHandler.getExpressionParser().parseExpression(myAccess); filter = new FilterInvocation(ServletActionContext.getRequest(), ServletActionContext.getResponse(), new AuthorizeComponent.DummyChain()); if (ExpressionUtils.evaluateAsBoolean(accessExpr, exprHandler.createEvaluationContext(currentUser, filter))) { return true; } return false; }