[java-identity-provider] branch main updated: IDP-2065 - Remediate UserAgentUtils library out of codebase
Scott Cantor
cantor.2 at osu.edu
Mon Jan 23 18:37:08 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=3f649eef9ae6bc3ee9015b83a8eaf45804bd32aa
The following commit(s) were added to refs/heads/main by this push:
new 3f649eef9 IDP-2065 - Remediate UserAgentUtils library out of codebase
3f649eef9 is described below
commit 3f649eef9ae6bc3ee9015b83a8eaf45804bd32aa
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jan 23 13:37:05 2023 -0500
IDP-2065 - Remediate UserAgentUtils library out of codebase
https://shibboleth.atlassian.net/browse/IDP-2065
Remove IE cases from logout views.
Remove rich methods from UserAgentContext.
---
idp-authn-api/pom.xml | 4 --
.../idp/authn/context/UserAgentContext.java | 51 +---------------------
.../idp/authn/context/UserAgentContextTest.java | 51 ----------------------
.../idp/flows/logout/logout-propagation-flow.xml | 4 +-
.../flows/saml/saml2/slo-front-abstract-flow.xml | 4 +-
5 files changed, 3 insertions(+), 111 deletions(-)
diff --git a/idp-authn-api/pom.xml b/idp-authn-api/pom.xml
index fd2524be6..d469d21c4 100644
--- a/idp-authn-api/pom.xml
+++ b/idp-authn-api/pom.xml
@@ -84,10 +84,6 @@
<groupId>${spring-webflow.groupId}</groupId>
<artifactId>spring-webflow</artifactId>
</dependency>
- <dependency>
- <groupId>eu.bitwalker</groupId>
- <artifactId>UserAgentUtils</artifactId>
- </dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/UserAgentContext.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/UserAgentContext.java
index 244d22547..54f18e876 100644
--- a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/UserAgentContext.java
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/UserAgentContext.java
@@ -22,11 +22,6 @@ import java.net.InetAddress;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import eu.bitwalker.useragentutils.Browser;
-import eu.bitwalker.useragentutils.OperatingSystem;
-import eu.bitwalker.useragentutils.UserAgent;
-import net.shibboleth.shared.logic.Constraint;
-
import org.opensaml.messaging.context.BaseContext;
/**
@@ -42,10 +37,6 @@ public final class UserAgentContext extends BaseContext {
/** An identification string (such as a User-Agent header). */
@Nullable private String identifier;
- /** Parsed User-Agent. */
- @Nullable private UserAgent userAgent;
-
-
/**
* Get the address of the user-agent host.
*
@@ -77,8 +68,7 @@ public final class UserAgentContext extends BaseContext {
}
/**
- * Set the user agent identifier. The parsed user agent is available via {@link #getUserAgent()} upon calling
- * this method.
+ * Set the user agent identifier.
*
* @param id identifier for the user agent
*
@@ -86,46 +76,7 @@ public final class UserAgentContext extends BaseContext {
*/
@Nonnull public UserAgentContext setIdentifier(@Nullable final String id) {
identifier = id;
- userAgent = new UserAgent(id);
return this;
}
- /**
- * Gets the parsed user agent.
- *
- * @return Parsed user agent or null if {@link #setIdentifier(String)} has not been called.
- */
- @Nullable public UserAgent getUserAgent() {
- return userAgent;
- }
-
- /**
- * Determines whether this user agent is an instance of the given browser.
- *
- * @param browser browser to check.
- *
- * @return True if this user agent is an instance of the given browser, false otherwise.
- */
- public boolean isInstance(@Nonnull final Browser browser) {
- Constraint.isNotNull(browser, "Browser cannot be null");
- if (userAgent == null) {
- return false;
- }
- return userAgent.getBrowser().getGroup().equals(browser) || userAgent.getBrowser().equals(browser);
- }
-
- /**
- * Determines whether this user agent is an instance of the given operating system.
- *
- * @param os operating system to check.
- *
- * @return True if this user agent is an instance of the given operating system, false otherwise.
- */
- public boolean isInstance(@Nonnull final OperatingSystem os) {
- Constraint.isNotNull(os, "OperatingSystem cannot be null");
- if (userAgent == null) {
- return false;
- }
- return userAgent.getOperatingSystem().getGroup().equals(os) || userAgent.getOperatingSystem().equals(os);
- }
}
\ No newline at end of file
diff --git a/idp-authn-api/src/test/java/net/shibboleth/idp/authn/context/UserAgentContextTest.java b/idp-authn-api/src/test/java/net/shibboleth/idp/authn/context/UserAgentContextTest.java
deleted file mode 100644
index 3cd154277..000000000
--- a/idp-authn-api/src/test/java/net/shibboleth/idp/authn/context/UserAgentContextTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.authn.context;
-
-import eu.bitwalker.useragentutils.Browser;
-import eu.bitwalker.useragentutils.OperatingSystem;
-import org.testng.annotations.Test;
-
-import org.testng.Assert;
-
-/**
- * Unit test for {@link UserAgentContext}.
- */
-public class UserAgentContextTest {
-
- @Test
- public void testIsInstanceOfBrowser() throws Exception {
- final UserAgentContext ie9Win7Ctx = new UserAgentContext();
- ie9Win7Ctx.setIdentifier("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)");
- Assert.assertNotNull(ie9Win7Ctx.getUserAgent(), "Expected non-null user agent");
- Assert.assertTrue(ie9Win7Ctx.isInstance(Browser.IE), "Expected instance of IE");
- Assert.assertTrue(ie9Win7Ctx.isInstance(Browser.IE9), "Expected instance of IE9");
- Assert.assertFalse(ie9Win7Ctx.isInstance(Browser.FIREFOX), "Unexpected instance of Firefox");
- }
-
- @Test
- public void testIsInstanceOfOperatingSystem() throws Exception {
- final UserAgentContext chrome41Win7 = new UserAgentContext();
- chrome41Win7.setIdentifier(
- "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
- Assert.assertNotNull(chrome41Win7.getUserAgent(), "Expected non-null user agent");
- Assert.assertTrue(chrome41Win7.isInstance(OperatingSystem.WINDOWS), "Expected instance of Windows");
- Assert.assertTrue(chrome41Win7.isInstance(OperatingSystem.WINDOWS_7), "Expected instance of Windows 7");
- Assert.assertFalse(chrome41Win7.isInstance(OperatingSystem.MAC_OS), "Unexpected instance of Mac OS");
- }
-}
\ No newline at end of file
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
index 0c7f88689..1cb71ca3b 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
@@ -37,9 +37,7 @@
<on-entry>
<evaluate expression="opensamlProfileRequestContext.getSubcontext(T(net.shibboleth.idp.session.context.LogoutPropagationContext))" result="requestScope.logoutPropCtx" />
<evaluate expression="opensamlProfileRequestContext.getSubcontext(T(net.shibboleth.idp.authn.context.UserAgentContext))" result="requestScope.userAgentContext" />
- <evaluate expression="userAgentContext.isInstance(T(eu.bitwalker.useragentutils.Browser).IE)
- ? externalContext.nativeResponse.setContentType('text/plain')
- : externalContext.nativeResponse.setContentType('application/json')" />
+ <evaluate expression="externalContext.nativeResponse.setContentType('application/json')" />
<evaluate expression="T(net.shibboleth.shared.codec.HTMLEncoder)" result="requestScope.encoder" />
<evaluate expression="WriteAuditLog" />
</on-entry>
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/slo-front-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/slo-front-abstract-flow.xml
index 3753bbf8a..3c45931e3 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/slo-front-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml2/slo-front-abstract-flow.xml
@@ -264,9 +264,7 @@
<evaluate expression="flowRequestContext.getExternalContext().getNativeResponse()" result="requestScope.response" />
<evaluate expression="flowRequestContext.getActiveFlow().getApplicationContext().containsBean('shibboleth.CustomViewContext') ? flowRequestContext.getActiveFlow().getApplicationContext().getBean('shibboleth.CustomViewContext') : null" result="requestScope.custom" />
<evaluate expression="opensamlProfileRequestContext.getSubcontext(T(net.shibboleth.idp.authn.context.UserAgentContext))" result="requestScope.userAgentContext" />
- <evaluate expression="userAgentContext.isInstance(T(eu.bitwalker.useragentutils.Browser).IE)
- ? externalContext.nativeResponse.setContentType('text/plain')
- : externalContext.nativeResponse.setContentType('application/json')" />
+ <evaluate expression="externalContext.nativeResponse.setContentType('application/json')" />
</on-entry>
</end-state>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list