Skip to content

Commit fc56717

Browse files
committed
Merge branch 'releases/2.6.1'
2 parents 82dc8fe + 94745a7 commit fc56717

File tree

44 files changed

+1035
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1035
-414
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
dependencies {
1313
classpath group: 'org.gradle.api.plugins', name: 'gradle-cargo-plugin', version: '1.5'
1414
classpath group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.4'
15-
classpath group: 'net.saliman', name: 'gradle-cobertura-plugin', version: '2.2.2'
15+
classpath group: 'net.saliman', name: 'gradle-cobertura-plugin', version: '2.2.8'
1616
classpath group: 'org.kt3k.gradle.plugin', name: 'coveralls-gradle-plugin', version: '0.4.1'
1717
classpath group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version:'1.1.8'
1818
classpath group: 'postgresql', name: 'postgresql', version:'9.1-901.jdbc3'

common/src/main/java/org/cloudfoundry/identity/uaa/authentication/SessionResetFilter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.servlet.http.HttpServletResponse;
3232
import javax.servlet.http.HttpSession;
3333
import java.io.IOException;
34+
import java.util.Date;
3435

3536
public class SessionResetFilter extends OncePerRequestFilter {
3637

@@ -64,12 +65,15 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
6465
try {
6566
logger.debug("Evaluating user-id for session reset:"+userId);
6667
UaaUser user = userDatabase.retrieveUserById(userId);
67-
long lastAuthTime = authentication.getAuthenticatedTime();
68-
long passwordModTime = user.getPasswordLastModified().getTime() ;
69-
//if the password has changed after authentication time
70-
if (hasPasswordChangedAfterAuthentication(lastAuthTime, passwordModTime)) {
71-
logger.debug(String.format("Resetting user session for user ID: %s Auth Time: %s Password Change Time: %s",userId, lastAuthTime, passwordModTime));
72-
redirect = true;
68+
Date lastModified;
69+
if ((lastModified = user.getPasswordLastModified()) != null) {
70+
long lastAuthTime = authentication.getAuthenticatedTime();
71+
long passwordModTime = lastModified.getTime();
72+
//if the password has changed after authentication time
73+
if (hasPasswordChangedAfterAuthentication(lastAuthTime, passwordModTime)) {
74+
logger.debug(String.format("Resetting user session for user ID: %s Auth Time: %s Password Change Time: %s",userId, lastAuthTime, passwordModTime));
75+
redirect = true;
76+
}
7377
}
7478
} catch (UsernameNotFoundException x) {
7579
logger.info("Authenticated user ["+userId+"] was not found in DB.");

common/src/main/java/org/cloudfoundry/identity/uaa/ldap/LdapIdentityProviderDefinition.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.springframework.core.env.MapPropertySource;
1919

2020
import java.util.HashMap;
21+
import java.util.List;
2122
import java.util.Map;
2223

2324
public class LdapIdentityProviderDefinition {
@@ -38,6 +39,7 @@ public class LdapIdentityProviderDefinition {
3839
private boolean groupSearchSubTree;
3940
private int maxGroupSearchDepth;
4041
private boolean skipSSLVerification;
42+
private List<String> emailDomain;
4143

4244
public static LdapIdentityProviderDefinition searchAndBindMapGroupToScopes(
4345
String baseUrl,
@@ -289,6 +291,14 @@ public int hashCode() {
289291
return result;
290292
}
291293

294+
public void setEmailDomain(List<String> emailDomain) {
295+
this.emailDomain = emailDomain;
296+
}
297+
298+
public List<String> getEmailDomain() {
299+
return emailDomain;
300+
}
301+
292302
public static class LdapConfigEnvironment extends AbstractEnvironment {
293303
public LdapConfigEnvironment(MapPropertySource source) {
294304
getPropertySources().addFirst(source);

common/src/main/java/org/cloudfoundry/identity/uaa/login/saml/ComparableProvider.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,51 @@
1313
*/
1414
package org.cloudfoundry.identity.uaa.login.saml;
1515

16-
public interface ComparableProvider {
17-
public String getAlias();
18-
public String getZoneId();
16+
import org.opensaml.saml2.metadata.EntitiesDescriptor;
17+
import org.opensaml.saml2.metadata.EntityDescriptor;
18+
import org.opensaml.saml2.metadata.provider.MetadataProviderException;
19+
import org.opensaml.xml.XMLObject;
20+
21+
public interface ComparableProvider extends Comparable<ComparableProvider> {
22+
23+
String getAlias();
24+
String getZoneId();
25+
26+
XMLObject doGetMetadata() throws MetadataProviderException;
27+
byte[] fetchMetadata() throws MetadataProviderException;
28+
29+
default String getEntityID() throws MetadataProviderException {
30+
fetchMetadata();
31+
XMLObject metadata = doGetMetadata();
32+
if (metadata instanceof EntityDescriptor) {
33+
EntityDescriptor entityDescriptor = (EntityDescriptor) metadata;
34+
return entityDescriptor.getEntityID();
35+
} else if (metadata instanceof EntitiesDescriptor) {
36+
EntitiesDescriptor desc = (EntitiesDescriptor)metadata;
37+
if (desc.getEntityDescriptors().size()!=1) {
38+
throw new MetadataProviderException("Invalid metadata. Number of descriptors must be 1, but is "+desc.getEntityDescriptors().size());
39+
} else {
40+
return desc.getEntityDescriptors().get(0).getEntityID();
41+
}
42+
} else {
43+
throw new MetadataProviderException("Unknown descriptor class:"+metadata.getClass().getName());
44+
}
45+
}
46+
47+
default int compareTo(ComparableProvider that) {
48+
if (this == that) return 0;
49+
int result = this.getAlias().compareTo(that.getAlias());
50+
if (0!=result) return result;
51+
result = this.getZoneId().compareTo(that.getZoneId());
52+
if (0!=result) return result;
53+
return 0;
54+
}
55+
56+
default int getHashCode() {
57+
int result = getZoneId().hashCode();
58+
result = 31 * result + getAlias().hashCode();
59+
return result;
60+
}
61+
62+
1963
}

common/src/main/java/org/cloudfoundry/identity/uaa/login/saml/ConfigMetadataProvider.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ public ConfigMetadataProvider(String zoneId, String alias, String metadata) {
2525
this.zoneId = zoneId;
2626
}
2727

28+
public byte[] fetchMetadata() throws MetadataProviderException {
29+
return metadata.getBytes(StandardCharsets.UTF_8);
30+
}
31+
2832
@Override
29-
protected XMLObject doGetMetadata() throws MetadataProviderException {
33+
public XMLObject doGetMetadata() throws MetadataProviderException {
3034

3135
InputStream stream = new ByteArrayInputStream(metadata.getBytes(StandardCharsets.UTF_8));
3236

@@ -42,20 +46,12 @@ protected XMLObject doGetMetadata() throws MetadataProviderException {
4246
public boolean equals(Object o) {
4347
if (this == o) return true;
4448
if (o == null || !(o instanceof ComparableProvider)) return false;
45-
46-
ComparableProvider that = (ComparableProvider) o;
47-
48-
if (!alias.equals(that.getAlias())) return false;
49-
if (!zoneId.equals(that.getZoneId())) return false;
50-
51-
return true;
49+
return this.compareTo((ComparableProvider)o) == 0;
5250
}
5351

5452
@Override
5553
public int hashCode() {
56-
int result = zoneId.hashCode();
57-
result = 31 * result + alias.hashCode();
58-
return result;
54+
return getHashCode();
5955
}
6056

6157
@Override

common/src/main/java/org/cloudfoundry/identity/uaa/login/saml/FilesystemMetadataProvider.java

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,14 @@
1818
import java.io.File;
1919
import java.util.Timer;
2020

21-
public class FilesystemMetadataProvider extends org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider implements ComparableProvider {
21+
public class FilesystemMetadataProvider extends org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider {
2222

23-
private final String zoneId;
24-
private final String alias;
25-
26-
public FilesystemMetadataProvider(String zoneId, String alias, Timer backgroundTaskTimer, File metadata) throws MetadataProviderException {
23+
public FilesystemMetadataProvider(Timer backgroundTaskTimer, File metadata) throws MetadataProviderException {
2724
super(backgroundTaskTimer, metadata);
28-
this.zoneId = zoneId;
29-
this.alias = alias;
30-
}
31-
32-
@Override
33-
public boolean equals(Object o) {
34-
if (this == o) return true;
35-
if (o == null || !(o instanceof ComparableProvider)) return false;
36-
37-
ComparableProvider that = (ComparableProvider) o;
38-
39-
if (!alias.equals(that.getAlias())) return false;
40-
if (!zoneId.equals(that.getZoneId())) return false;
41-
42-
return true;
43-
}
44-
45-
@Override
46-
public int hashCode() {
47-
int result = zoneId.hashCode();
48-
result = 31 * result + alias.hashCode();
49-
return result;
50-
}
51-
52-
@Override
53-
public String getAlias() {
54-
return alias;
5525
}
5626

5727
@Override
58-
public String getZoneId() {
59-
return zoneId;
28+
public byte[] fetchMetadata() throws MetadataProviderException {
29+
return super.fetchMetadata();
6030
}
6131
}

common/src/main/java/org/cloudfoundry/identity/uaa/login/saml/FixedHttpMetaDataProvider.java

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Cloud Foundry
2+
* Cloud Foundry
33
* Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
44
*
55
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -13,40 +13,45 @@
1313

1414
package org.cloudfoundry.identity.uaa.login.saml;
1515

16-
import java.net.URISyntaxException;
17-
import java.util.Timer;
18-
1916
import org.apache.commons.httpclient.HttpClient;
2017
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
2118
import org.opensaml.saml2.metadata.provider.HTTPMetadataProvider;
2219
import org.opensaml.saml2.metadata.provider.MetadataProviderException;
2320

21+
import java.net.URISyntaxException;
22+
import java.util.Timer;
23+
2424
/**
2525
* This class works around the problem described in <a href="http://issues.apache.org/jira/browse/HTTPCLIENT-646">http://issues.apache.org/jira/browse/HTTPCLIENT-646</a> when a socket factory is set
2626
* on the OpenSAML
2727
* {@link HTTPMetadataProvider#setSocketFactory(ProtocolSocketFactory)} all
2828
* subsequent GET Methods should be executed using a relative URL, otherwise the
2929
* HttpClient
3030
* resets the underlying socket factory.
31-
*
31+
*
3232
* @author Filip Hanik
33-
*
33+
*
3434
*/
35-
public class FixedHttpMetaDataProvider extends HTTPMetadataProvider implements ComparableProvider {
35+
public class FixedHttpMetaDataProvider extends HTTPMetadataProvider {
3636

3737
/**
3838
* Track if we have a custom socket factory
3939
*/
4040
private boolean socketFactorySet = false;
41-
private final String zoneId;
42-
private final String alias;
41+
private byte[] metadata;
4342

4443

45-
public FixedHttpMetaDataProvider(String zoneId, String alias, Timer backgroundTaskTimer, HttpClient client,
46-
String metadataURL) throws MetadataProviderException {
44+
public FixedHttpMetaDataProvider(Timer backgroundTaskTimer, HttpClient client, String metadataURL) throws MetadataProviderException {
4745
super(backgroundTaskTimer, client, metadataURL);
48-
this.alias = alias;
49-
this.zoneId = zoneId;
46+
}
47+
48+
49+
@Override
50+
public byte[] fetchMetadata() throws MetadataProviderException {
51+
if (metadata==null) {
52+
metadata = super.fetchMetadata();
53+
}
54+
return metadata;
5055
}
5156

5257
/**
@@ -92,34 +97,4 @@ public String getMetadataURI() {
9297
public boolean isSocketFactorySet() {
9398
return socketFactorySet;
9499
}
95-
96-
@Override
97-
public boolean equals(Object o) {
98-
if (this == o) return true;
99-
if (o == null || !(o instanceof ComparableProvider)) return false;
100-
101-
ComparableProvider that = (ComparableProvider) o;
102-
103-
if (!alias.equals(that.getAlias())) return false;
104-
if (!zoneId.equals(that.getZoneId())) return false;
105-
106-
return true;
107-
}
108-
109-
@Override
110-
public int hashCode() {
111-
int result = zoneId.hashCode();
112-
result = 31 * result + alias.hashCode();
113-
return result;
114-
}
115-
116-
@Override
117-
public String getAlias() {
118-
return alias;
119-
}
120-
121-
@Override
122-
public String getZoneId() {
123-
return zoneId;
124-
}
125100
}

0 commit comments

Comments
 (0)