1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.internet2.middleware.shibboleth.idp.ui;
18
19 import java.io.IOException;
20
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.JspWriter;
23 import javax.servlet.jsp.tagext.BodyContent;
24
25 import org.opensaml.samlext.saml2mdui.InformationURL;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29
30 public class ServiceInformationURLTag extends ServiceTagSupport {
31
32
33 private static final long serialVersionUID = 5601822745575892676L;
34
35 private static Logger log = LoggerFactory.getLogger(ServiceInformationURLTag.class);
36
37
38 private static String linkText;
39
40
41
42
43 public void setLinkText(String text) {
44 linkText = text;
45 }
46
47
48
49
50
51 private String getInformationURLFromUIIinfo() {
52 String lang = getBrowserLanguage();
53
54 if (getSPUIInfo() != null && getSPUIInfo().getInformationURLs() != null) {
55 for (InformationURL infoURL:getSPUIInfo().getInformationURLs()) {
56 if (log.isDebugEnabled()){
57 log.debug("Found InformationURL in UIInfo, language=" + infoURL.getXMLLang());
58 }
59 if (infoURL.getXMLLang().equals(lang)) {
60
61
62
63 if (log.isDebugEnabled()){
64 log.debug("returning URL from UIInfo " + infoURL.getURI().getLocalString());
65 }
66 return infoURL.getURI().getLocalString();
67 }
68 }
69 if (log.isDebugEnabled()){
70 log.debug("No relevant InformationURL in UIInfo");
71 }
72 }
73 return null;
74 }
75 @Override
76
77 public int doEndTag() throws JspException {
78
79 String infoURL = getInformationURLFromUIIinfo();
80
81 try {
82 if (null == infoURL) {
83 BodyContent bc = getBodyContent();
84 if (null != bc) {
85 JspWriter ew= bc.getEnclosingWriter();
86 if (ew != null) {
87 bc.writeOut(ew);
88 }
89 }
90 } else {
91 pageContext.getOut().print(buildHyperLink(infoURL, linkText));
92 }
93 } catch (IOException e) {
94 log.warn("Error generating Description");
95 throw new JspException("EndTag", e);
96 }
97 return super.doEndTag();
98 }
99
100
101 }