Java tutorial
/* * 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.saml.profile.config.saml1; import java.security.Principal; import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import net.shibboleth.idp.profile.config.AuthenticationProfileConfiguration; import net.shibboleth.idp.saml.authn.principal.AuthenticationMethodPrincipal; import net.shibboleth.idp.saml.profile.config.AbstractSAMLProfileConfiguration; import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements; import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty; import net.shibboleth.utilities.java.support.annotation.constraint.NotLive; import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable; import net.shibboleth.utilities.java.support.logic.Constraint; /** Configuration for SAML 1 Browser SSO profile requests. */ public class BrowserSSOProfileConfiguration extends AbstractSAMLProfileConfiguration implements SAML1ProfileConfiguration, AuthenticationProfileConfiguration { /** ID for this profile configuration. */ public static final String PROFILE_ID = "http://shibboleth.net/ns/profiles/saml1/sso/browser"; /** * Whether responses to the authentication request should include an attribute statement. * * <p>Default value: false</p> */ private boolean includeAttributeStatement; /** Selects, and limits, the authentication methods to use for requests. */ @Nonnull @NonnullElements private List<AuthenticationMethodPrincipal> defaultAuthenticationMethods; /** Precedence of name identifier formats to use for requests. */ @Nonnull @NonnullElements private List<String> nameIDFormatPrecedence; /** Constructor. */ public BrowserSSOProfileConfiguration() { this(PROFILE_ID); } /** * Constructor. * * @param profileId unique ID for this profile */ protected BrowserSSOProfileConfiguration(@Nonnull @NotEmpty final String profileId) { super(profileId); includeAttributeStatement = false; defaultAuthenticationMethods = Collections.emptyList(); nameIDFormatPrecedence = Collections.emptyList(); } /** * Get whether responses to the authentication request should include an attribute statement. * * @return whether responses to the authentication request should include an attribute statement */ public boolean includeAttributeStatement() { return includeAttributeStatement; } /** * Set whether responses to the authentication request should include an attribute statement. * * @param include whether responses to the authentication request should include an attribute statement */ public void setIncludeAttributeStatement(final boolean include) { includeAttributeStatement = include; } /** {@inheritDoc} */ @Override @Nonnull @NonnullElements @NotLive @Unmodifiable public List<Principal> getDefaultAuthenticationMethods() { return ImmutableList.<Principal>copyOf(defaultAuthenticationMethods); } /** * Set the default authentication methods to use, expressed as custom principals. * * @param methods default authentication methods to use */ public void setDefaultAuthenticationMethods( @Nonnull @NonnullElements final List<AuthenticationMethodPrincipal> methods) { Constraint.isNotNull(methods, "List of methods cannot be null"); defaultAuthenticationMethods = Lists.newArrayList(Collections2.filter(methods, Predicates.notNull())); } /** {@inheritDoc} */ @Override @Nonnull @NonnullElements @NotLive @Unmodifiable public List<String> getNameIDFormatPrecedence() { return ImmutableList.copyOf(nameIDFormatPrecedence); } /** * Set the name identifier formats to use. * * @param formats name identifier formats to use */ public void setNameIDFormatPrecedence(@Nonnull @NonnullElements final List<String> formats) { Constraint.isNotNull(formats, "List of formats cannot be null"); nameIDFormatPrecedence = Lists.newArrayList(Collections2.filter(formats, Predicates.notNull())); } }