@Test void evaluateWhenNotAuthorized() { DocumentReference reference = new DocumentReference("wiki", "space", "page"); when(this.dab.getCurrentUserReference()).thenReturn(new DocumentReference("userwiki", "userspace", "userpage")); Throwable exception = assertThrows(MessagingException.class, () -> { this.mailTemplateManager.evaluate(reference, "property", Collections.emptyMap()); }); assertEquals("Current user [userwiki:userspace.userpage] has no permission to view Mail Template " + "Document [wiki:space.page]", exception.getMessage()); }
@Override public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, Object localeValue) throws MessagingException { if (!this.authorizationManager.hasAccess( Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) { throw new MessagingException( String.format("Current user [%s] has no permission to view Mail Template Document [%s]", this.documentBridge.getCurrentUserReference(), templateReference)); } return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); }
SecureMailTemplateManager implements MailTemplateManager { @Override public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, Object localeValue) throws MessagingException { if (!this.authorizationManager.hasAccess( Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) { throw new MessagingException( String.format("Current user [%s] has no permission to view Mail Template Document [%s]", this.documentBridge.getCurrentUserReference(), templateReference)); } return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); } }
SecureMailTemplateManager implements MailTemplateManager { @Override public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, Object localeValue) throws MessagingException { if (!this.authorizationManager.hasAccess( Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) { throw new MessagingException( String.format("Current user [%s] has no permission to view Mail Template Document [%s]", this.documentBridge.getCurrentUserReference(), templateReference)); } return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); }  }
SecureMailTemplateManager implements MailTemplateManager { @Override public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, Object localeValue) throws MessagingException { if (!this.authorizationManager.hasAccess( Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) { throw new MessagingException( String.format("Current user [%s] has no permission to view Mail Template Document [%s]", this.documentBridge.getCurrentUserReference(), templateReference)); } return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); }  @Override String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables,
        Object localeValue); @Override String evaluate(DocumentReference documentReference, String property,
        Map<String, Object> velocityVariables); }
SecureMailTemplateManager implements MailTemplateManager { @Override public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, Object localeValue) throws MessagingException { if (!this.authorizationManager.hasAccess( Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) { throw new MessagingException( String.format("Current user [%s] has no permission to view Mail Template Document [%s]", this.documentBridge.getCurrentUserReference(), templateReference)); } return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); }  @Override String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables,
        Object localeValue); @Override String evaluate(DocumentReference documentReference, String property,
        Map<String, Object> velocityVariables);  }