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