-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ldap_groups_as_scopes' into develop
https://www.pivotaltracker.com/story/show/53029645 [#53029645] Completes LDAP functionality
- Loading branch information
Showing
59 changed files
with
2,164 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...org/cloudfoundry/identity/uaa/authentication/manager/ExternalGroupAuthorizationEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2014] 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.manager; | ||
|
||
import org.cloudfoundry.identity.uaa.user.UaaUser; | ||
import org.springframework.context.ApplicationEvent; | ||
import org.springframework.security.core.GrantedAuthority; | ||
|
||
import java.util.Collection; | ||
|
||
public class ExternalGroupAuthorizationEvent extends NewUserAuthenticatedEvent { | ||
|
||
public Collection<? extends GrantedAuthority> getExternalAuthorities() { | ||
return externalAuthorities; | ||
} | ||
|
||
private Collection<? extends GrantedAuthority> externalAuthorities; | ||
|
||
public ExternalGroupAuthorizationEvent(UaaUser user, Collection<? extends GrantedAuthority> externalAuthorities) { | ||
super(user); | ||
this.externalAuthorities = externalAuthorities; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
common/src/main/java/org/cloudfoundry/identity/uaa/ldap/CommaSeparatedScopesMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* ****************************************************************************** | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2014] 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.ldap; | ||
|
||
import org.cloudfoundry.identity.uaa.ldap.extension.LdapAuthority; | ||
import org.cloudfoundry.identity.uaa.user.UaaAuthority; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class CommaSeparatedScopesMapper implements GrantedAuthoritiesMapper { | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) { | ||
ArrayList<GrantedAuthority> result = new ArrayList<>(); | ||
for (GrantedAuthority authority : authorities) { | ||
LdapAuthority ldapAuthority = (LdapAuthority)authority; | ||
for (String scope : StringUtils.commaDelimitedListToSet(authority.getAuthority())) { | ||
LdapAuthority a = new LdapAuthority(scope, ldapAuthority.getDn(), ldapAuthority.getAttributes()); | ||
result.add(a); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
common/src/main/java/org/cloudfoundry/identity/uaa/ldap/LdapGroupToScopesMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* ****************************************************************************** | ||
* Cloud Foundry | ||
* Copyright (c) [2009-2014] 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.ldap; | ||
|
||
import org.cloudfoundry.identity.uaa.authorization.ExternalGroupMappingAuthorizationManager; | ||
import org.cloudfoundry.identity.uaa.ldap.extension.LdapAuthority; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class LdapGroupToScopesMapper implements GrantedAuthoritiesMapper { | ||
|
||
public ExternalGroupMappingAuthorizationManager getGroupMapper() { | ||
return groupMapper; | ||
} | ||
|
||
public void setGroupMapper(ExternalGroupMappingAuthorizationManager groupMapper) { | ||
this.groupMapper = groupMapper; | ||
} | ||
|
||
private ExternalGroupMappingAuthorizationManager groupMapper; | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) { | ||
return getGroupMapper().findScopesFromAuthorities(new HashSet<>(authorities)); | ||
} | ||
} |
Oops, something went wrong.