From bdb8a22269184db4f29a8822ca913ab13ebc0ac7 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 21 Jan 2013 16:36:10 +0000 Subject: [PATCH] implements those methods with ldap call git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1436466 13f79535-47bb-0310-9956-ffa450edef68 --- .../redback/rbac/ldap/LdapRbacManager.java | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java index 4ac0fd64e..230091bbf 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java @@ -982,22 +982,46 @@ public class LdapRbacManager closeContext( context ); closeLdapConnection( ldapConnection ); } - - //this.rbacImpl.saveUserAssignment( userAssignment ); - - //return userAssignment; } public boolean userAssignmentExists( String principal ) { - // TODO here - return this.rbacImpl.userAssignmentExists( principal ); + LdapConnection ldapConnection = null; + DirContext context = null; + try + { + ldapConnection = ldapConnectionFactory.getConnection(); + context = ldapConnection.getDirContext(); + List roles = ldapRoleMapper.getRoles( principal, context ); + if ( roles == null || roles.isEmpty() ) + { + return false; + } + return true; + } + catch ( LdapException e ) + { + log.warn( "fail to call userAssignmentExists: {}", e.getMessage() ); + } + catch ( MappingException e ) + { + log.warn( "fail to call userAssignmentExists: {}", e.getMessage() ); + } + finally + { + closeContext( context ); + closeLdapConnection( ldapConnection ); + } + return false; } public boolean userAssignmentExists( UserAssignment assignment ) { - // TODO here - return this.rbacImpl.userAssignmentExists( assignment ); + if ( assignment == null ) + { + return false; + } + return this.userAssignmentExists( assignment.getPrincipal() ); } public RBACManager getRbacImpl() -- 2.39.5