Skip to content

Commit

Permalink
Refactor all identity provider definition to extend AbstractIdentityP…
Browse files Browse the repository at this point in the history
…roviderDefinition

This allows them all to share the emailDomain list
  • Loading branch information
fhanik committed Sep 8, 2015
1 parent a175847 commit 1f38a46
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 40 deletions.
@@ -0,0 +1,29 @@
/*
* *****************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
* *****************************************************************************
*/

package org.cloudfoundry.identity.uaa;

import java.util.List;

public abstract class AbstractIdentityProviderDefinition {
private List<String> emailDomain;

public List<String> getEmailDomain() {
return emailDomain;
}

public void setEmailDomain(List<String> emailDomain) {
this.emailDomain = emailDomain;
}
}
@@ -1,3 +1,15 @@
/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
package org.cloudfoundry.identity.uaa.authentication;

import org.cloudfoundry.identity.uaa.oauth.RemoteUserAuthentication;
Expand All @@ -7,9 +19,6 @@

import java.lang.reflect.Method;

/**
* Created by fhanik on 6/4/14.
*/
public class Origin {

public static final String ORIGIN = "origin";
Expand All @@ -19,6 +28,7 @@ public class Origin {
public static final String KEYSTONE = "keystone";
public static final String SAML = "saml";
public static final String NotANumber = "NaN";
public static final String UNKNOWN = "unknown";


public static String getUserId(Authentication authentication) {
Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.cloudfoundry.identity.uaa.ldap;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
Expand All @@ -21,7 +22,7 @@
import java.util.List;
import java.util.Map;

public class LdapIdentityProviderDefinition {
public class LdapIdentityProviderDefinition extends AbstractIdentityProviderDefinition {

private String baseUrl;
private String bindUserDn;
Expand All @@ -39,7 +40,6 @@ public class LdapIdentityProviderDefinition {
private boolean groupSearchSubTree;
private int maxGroupSearchDepth;
private boolean skipSSLVerification;
private List<String> emailDomain;

public static LdapIdentityProviderDefinition searchAndBindMapGroupToScopes(
String baseUrl,
Expand Down Expand Up @@ -291,14 +291,6 @@ public int hashCode() {
return result;
}

public void setEmailDomain(List<String> emailDomain) {
this.emailDomain = emailDomain;
}

public List<String> getEmailDomain() {
return emailDomain;
}

public static class LdapConfigEnvironment extends AbstractEnvironment {
public LdapConfigEnvironment(MapPropertySource source) {
getPropertySources().addFirst(source);
Expand Down
@@ -1,6 +1,6 @@
/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
Expand All @@ -13,14 +13,15 @@
package org.cloudfoundry.identity.uaa.login.saml;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition;
import org.cloudfoundry.identity.uaa.login.util.FileLocator;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SamlIdentityProviderDefinition {
public class SamlIdentityProviderDefinition extends AbstractIdentityProviderDefinition {

public static final String DEFAULT_HTTP_SOCKET_FACTORY = "org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory";
public static final String DEFAULT_HTTPS_SOCKET_FACTORY = "org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory";
Expand All @@ -42,7 +43,6 @@ public enum MetadataLocation {
private String socketFactoryClassName;
private String linkText;
private String iconUrl;
private List<String> emailDomain;
private boolean addShadowUserOnLogin = true;

public SamlIdentityProviderDefinition() {}
Expand Down Expand Up @@ -70,7 +70,7 @@ public SamlIdentityProviderDefinition(String metaDataLocation, String idpEntityA
this.iconUrl = iconUrl;
this.zoneId = zoneId;
this.addShadowUserOnLogin = addShadowUserOnLogin;
this.emailDomain = emailDomain;
setEmailDomain(emailDomain);
}

@JsonIgnore
Expand Down Expand Up @@ -208,16 +208,8 @@ public void setAddShadowUserOnLogin(boolean addShadowUserOnLogin) {
this.addShadowUserOnLogin = addShadowUserOnLogin;
}

public List<String> getEmailDomain() {
return emailDomain;
}

public void setEmailDomain(List<String> emailDomain) {
this.emailDomain = emailDomain;
}

public SamlIdentityProviderDefinition clone() {
return new SamlIdentityProviderDefinition(metaDataLocation, idpEntityAlias, nameID, assertionConsumerIndex, metadataTrustCheck, showSamlLink, linkText, iconUrl, zoneId, addShadowUserOnLogin, emailDomain!=null ? new ArrayList<>(emailDomain) : null);
return new SamlIdentityProviderDefinition(metaDataLocation, idpEntityAlias, nameID, assertionConsumerIndex, metadataTrustCheck, showSamlLink, linkText, iconUrl, zoneId, addShadowUserOnLogin, getEmailDomain()!=null ? new ArrayList<>(getEmailDomain()) : null);
}

@Override
Expand Down
@@ -1,25 +1,25 @@
/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
package org.cloudfoundry.identity.uaa.zone;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition;
import org.cloudfoundry.identity.uaa.authentication.manager.AccountLoginPolicy;
import org.cloudfoundry.identity.uaa.authentication.manager.PeriodLockoutPolicy;
import org.cloudfoundry.identity.uaa.config.LockoutPolicy;
import org.cloudfoundry.identity.uaa.config.PasswordPolicy;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
@JsonIgnoreProperties(ignoreUnknown = true)
public class UaaIdentityProviderDefinition {
public class UaaIdentityProviderDefinition extends AbstractIdentityProviderDefinition {

private PasswordPolicy passwordPolicy;
private LockoutPolicy lockoutPolicy;
Expand Down

0 comments on commit 1f38a46

Please sign in to comment.