[java-identity-provider COMMIT] in /trunk/idp-ui/src: main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.j...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Aug 11 07:12:09 EDT 2014
Author: rdw
Date: Mon Aug 11 07:12:09 2014
New Revision: 6411
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6411&view=rev
Log:
IDP-245 Add policing of URLS. Tidy logging, Add ServiceDescription and Email. Fully test all existing Functions.
Added:
trunk/idp-ui/src/test/resources/net/shibboleth/idp/ui/example-metadata2.xml (with props)
trunk/idp-ui/src/test/resources/net/shibboleth/idp/ui/example-metadata3.xml (with props)
Modified:
trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java
trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/SetRPUIInformation.java
trunk/idp-ui/src/test/java/net/shibboleth/idp/ui/context/RelyingPartyUIContextTest.java
trunk/idp-ui/src/test/resources/logback-test.xml
trunk/idp-ui/src/test/resources/net/shibboleth/idp/ui/example-metadata.xml
Modified: trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java?rev=6411&r1=6410&r2=6411&view=diff
==============================================================================
--- trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java (original)
+++ trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java Mon Aug 11 07:12:09 2014
@@ -19,11 +19,13 @@
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -38,6 +40,7 @@
import org.opensaml.saml.saml2.metadata.Organization;
import org.opensaml.saml.saml2.metadata.OrganizationDisplayName;
import org.opensaml.saml.saml2.metadata.OrganizationName;
+import org.opensaml.saml.saml2.metadata.OrganizationURL;
import org.opensaml.saml.saml2.metadata.SPSSODescriptor;
import org.opensaml.saml.saml2.metadata.ServiceDescription;
import org.opensaml.saml.saml2.metadata.ServiceName;
@@ -72,7 +75,7 @@
*
* @return Returns the entity.
*/
- @Nullable public EntityDescriptor getRPEntityDescriptor() {
+ @Nullable protected EntityDescriptor getRPEntityDescriptor() {
return rpEntityDescriptor;
}
@@ -90,7 +93,7 @@
*
* @return Returns the SPSSODescriptor.
*/
- @Nullable public SPSSODescriptor getRPSPSSODescriptor() {
+ @Nullable protected SPSSODescriptor getRPSPSSODescriptor() {
return rpSPSSODescriptor;
}
@@ -108,7 +111,7 @@
*
* @return Returns the SPSSODescriptor.
*/
- @Nullable public AttributeConsumingService getRPAttributeConsumingService() {
+ @Nullable protected AttributeConsumingService getRPAttributeConsumingService() {
return rpAttributeConsumingService;
}
@@ -117,7 +120,7 @@
*
* @return the value or null if there is none.
*/
- @Nullable public UIInfo getRPUInfo() {
+ @Nullable protected UIInfo getRPUInfo() {
return rpUIInfo;
}
@@ -126,7 +129,7 @@
*
* @param what the value to set.
*/
- public void getRPUInfo(@Nullable final UIInfo what) {
+ public void setRPUInfo(@Nullable final UIInfo what) {
rpUIInfo = what;
}
@@ -154,8 +157,64 @@
*
* @return the languages.
*/
- @Nonnull public List<String> getBrowserLanguages() {
+ @Nonnull protected List<String> getBrowserLanguages() {
return browserLanguages;
+ }
+
+ /**
+ * Check to see whether a supplied URL is acceptable, returning the default if it isn't.
+ *
+ * @param url the url to look at
+ * @param acceptableSchemes the schemes to test against
+ * @param defaultValue what to return if the test fails
+ * @return the input or the default as appropriate.
+ */
+ @Nullable private String policeURL(@Nullable final String url,
+ @Nonnull @NotEmpty final List<String> acceptableSchemes, @Nullable final String defaultValue) {
+ if (null == url) {
+ log.trace("Empty Value - returning '{}", defaultValue);
+ return defaultValue;
+ }
+
+ try {
+ final String scheme = new URI(url).getScheme();
+
+ for (final String acceptableScheme : acceptableSchemes) {
+ if (acceptableScheme.equals(scheme)) {
+ log.debug("Acceptable Scheme '{}', returning value '{}'", acceptableScheme, url);
+ return url;
+ }
+ }
+
+ log.warn("The logo URL '{}' contained an invalid scheme (expected '{}'), returning default of '{}'", url,
+ acceptableSchemes, defaultValue);
+ return defaultValue;
[... 495 lines stripped ...]
More information about the commits
mailing list