/**
* Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.glite.security.voms.admin.taglib;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
public class AuthorizedTag extends TagSupport {
String context;
String permission;
String message;
String style;
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getPermission() {
return permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
public int doStartTag() throws JspException {
if (TagUtils.isAuthorized(pageContext, context, permission))
return EVAL_BODY_INCLUDE;
if (message != null) {
if (style == null)
style = "";
String content = "<div class=\"" + style + "\">" + message + "</div>";
try {
pageContext.getOut().write(content);
} catch (IOException e) {
throw new JspTagException("Error writing jsp page content: "
+ e.getMessage());
}
}
return SKIP_BODY;
}
}