[java-identity-provider COMMIT] /trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServl...
noreply at shibboleth.net
noreply at shibboleth.net
Wed May 28 12:24:48 EDT 2014
Author: scantor
Date: Wed May 28 12:24:48 2014
New Revision: 5981
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5981&view=rev
Log:
Add header and attribute support in addition to REMOTE_USER
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServlet.java
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServlet.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServlet.java?rev=5981&r1=5980&r2=5981&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServlet.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/RemoteUserAuthServlet.java Wed May 28 12:24:48 2014
@@ -18,6 +18,8 @@
package net.shibboleth.idp.authn.impl;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
import javax.annotation.Nonnull;
import javax.servlet.ServletConfig;
@@ -28,10 +30,16 @@
import net.shibboleth.idp.authn.ExternalAuthentication;
import net.shibboleth.idp.authn.ExternalAuthenticationException;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
/**
* Extracts REMOTE_USER and places it in a request attribute to be used by the IdP's external authentication
@@ -42,15 +50,92 @@
/** Serial UID. */
private static final long serialVersionUID = -3162057736238514851L;
+ /** Init parameter controlling whether to check for REMOTE_USER. */
+ @Nonnull @NotEmpty private static final String CHECK_REMOTE_USER_PARAM = "checkRemoteUser";
+
+ /** Init parameter controlling what attributes to check. */
+ @Nonnull @NotEmpty private static final String CHECK_ATTRIBUTES_PARAM = "checkAttributes";
+
+ /** Init parameter controlling what headers to check. */
+ @Nonnull @NotEmpty private static final String CHECK_HEADERS_PARAM = "checkHeaders";
+
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(RemoteUserAuthServlet.class);
+
+ /** Whether to check REMOTE_USER for an identity. Defaults to true. */
+ private boolean checkRemoteUser;
+
+ /** List of request attributes to check for an identity. */
+ @Nonnull @NonnullElements private Collection<String> checkAttributes;
+ /** List of request headers to check for an identity. */
+ @Nonnull @NonnullElements private Collection<String> checkHeaders;
+
+ /** Constructor. */
+ public RemoteUserAuthServlet() {
+ checkRemoteUser = true;
+ checkAttributes = Collections.emptyList();
+ checkHeaders = Collections.emptyList();
+ }
+
+ /**
+ * Set whether to check REMOTE_USER for an identity.
+ *
+ * @param flag value to set
+ */
+ public void setCheckRemoteUser(final boolean flag) {
+ checkRemoteUser = flag;
+ }
+
+ /**
+ * Set the list of request attributes to check for an identity.
+ *
+ * @param attributes list of request attributes to check
+ */
+ public void setCheckAttributes(@Nonnull @NonnullElements final Collection<String> attributes) {
+ checkAttributes = Lists.newArrayList(Collections2.filter(attributes, Predicates.notNull()));
+ }
+
+ /**
+ * Set the list of request headers to check for an identity.
+ *
+ * @param headers list of request headers to check
+ */
+ public void setCheckHeaders(@Nonnull @NonnullElements final Collection<String> headers) {
+ checkHeaders = Lists.newArrayList(Collections2.filter(headers, Predicates.notNull()));
+ }
+
/** {@inheritDoc} */
@Override
- public void init(ServletConfig config) throws ServletException {
+ public void init(final ServletConfig config) throws ServletException {
super.init(config);
+
+ String param = config.getInitParameter(CHECK_REMOTE_USER_PARAM);
+ if (param != null) {
+ checkRemoteUser = Boolean.parseBoolean(param);
+ }
+
+ param = config.getInitParameter(CHECK_ATTRIBUTES_PARAM);
+ if (param != null) {
+ final String[] attrs = param.split(" ");
+ if (attrs != null) {
+ checkAttributes = StringSupport.normalizeStringCollection(Lists.newArrayList(attrs));
+ }
+ }
+
+ param = config.getInitParameter(CHECK_HEADERS_PARAM);
+ if (param != null) {
+ final String[] headers = param.split(" ");
+ if (headers != null) {
[... 66 lines stripped ...]
More information about the commits
mailing list