mirror of https://github.com/apache/archiva.git
service to provide available rbacmanager implementations informations
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8a34bce31c
commit
8364c17d3a
|
@ -44,50 +44,60 @@ public class TestRBACManager implements RBACManager
|
||||||
|
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFinalImplementation()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescriptionKey()
|
||||||
|
{
|
||||||
|
return "archiva.redback.rbacmanager.test";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener( RBACManagerListener listener )
|
public void addListener( RBACManagerListener listener )
|
||||||
{
|
{
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener( RBACManagerListener listener )
|
public void removeListener( RBACManagerListener listener )
|
||||||
{
|
{
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role createRole( String name )
|
public Role createRole( String name )
|
||||||
{
|
{
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean roleExists( String name )
|
public boolean roleExists( String name )
|
||||||
{
|
{
|
||||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean roleExists( Role role )
|
public boolean roleExists( Role role )
|
||||||
{
|
{
|
||||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role saveRole( Role role )
|
public Role saveRole( Role role )
|
||||||
throws RbacObjectInvalidException, RbacManagerException
|
throws RbacObjectInvalidException, RbacManagerException
|
||||||
{
|
{
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveRoles( Collection<Role> roles )
|
public void saveRoles( Collection<Role> roles )
|
||||||
throws RbacObjectInvalidException, RbacManagerException
|
throws RbacObjectInvalidException, RbacManagerException
|
||||||
{
|
{
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role getRole( String roleName )
|
public Role getRole( String roleName )
|
||||||
throws RbacObjectNotFoundException, RbacManagerException
|
throws RbacObjectNotFoundException, RbacManagerException
|
||||||
{
|
{
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Role> getRoles( Collection<String> roleNames )
|
public Map<String, Role> getRoles( Collection<String> roleNames )
|
||||||
|
|
|
@ -25,15 +25,11 @@ import java.io.Serializable;
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 1.4-M4
|
* @since 1.4-M4
|
||||||
*/
|
*/
|
||||||
@XmlRootElement ( name = "userManagerImplementationInformation" )
|
@XmlRootElement(name = "userManagerImplementationInformation")
|
||||||
public class UserManagerImplementationInformation
|
public class UserManagerImplementationInformation
|
||||||
|
extends AbstractImplementationInformation
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
private String beanId;
|
|
||||||
|
|
||||||
private String descriptionKey;
|
|
||||||
|
|
||||||
private boolean readOnly;
|
|
||||||
|
|
||||||
public UserManagerImplementationInformation()
|
public UserManagerImplementationInformation()
|
||||||
{
|
{
|
||||||
|
@ -42,77 +38,7 @@ public class UserManagerImplementationInformation
|
||||||
|
|
||||||
public UserManagerImplementationInformation( String beanId, String descriptionKey, boolean readOnly )
|
public UserManagerImplementationInformation( String beanId, String descriptionKey, boolean readOnly )
|
||||||
{
|
{
|
||||||
this.beanId = beanId;
|
super( beanId, descriptionKey, readOnly );
|
||||||
this.descriptionKey = descriptionKey;
|
|
||||||
this.readOnly = readOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBeanId()
|
|
||||||
{
|
|
||||||
return beanId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeanId( String beanId )
|
|
||||||
{
|
|
||||||
this.beanId = beanId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescriptionKey()
|
|
||||||
{
|
|
||||||
return descriptionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescriptionKey( String descriptionKey )
|
|
||||||
{
|
|
||||||
this.descriptionKey = descriptionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReadOnly()
|
|
||||||
{
|
|
||||||
return readOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadOnly( boolean readOnly )
|
|
||||||
{
|
|
||||||
this.readOnly = readOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append( "UserManagerImplementationInformation" );
|
|
||||||
sb.append( "{beanId='" ).append( beanId ).append( '\'' );
|
|
||||||
sb.append( ", descriptionKey='" ).append( descriptionKey ).append( '\'' );
|
|
||||||
sb.append( '}' );
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals( Object o )
|
|
||||||
{
|
|
||||||
if ( this == o )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ( !( o instanceof UserManagerImplementationInformation ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserManagerImplementationInformation that = (UserManagerImplementationInformation) o;
|
|
||||||
|
|
||||||
if ( !beanId.equals( that.beanId ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return beanId.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services;
|
||||||
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
||||||
import org.apache.archiva.admin.model.beans.LdapConfiguration;
|
import org.apache.archiva.admin.model.beans.LdapConfiguration;
|
||||||
import org.apache.archiva.redback.authorization.RedbackAuthorization;
|
import org.apache.archiva.redback.authorization.RedbackAuthorization;
|
||||||
|
import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation;
|
||||||
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
|
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
|
|
||||||
|
@ -55,13 +56,20 @@ public interface RedbackRuntimeConfigurationService
|
||||||
Boolean updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
|
Boolean updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
@Path("userManagerImplementationInformation")
|
@Path("userManagerImplementationInformations")
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
|
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
|
||||||
List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
|
List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path("rbacManagerImplementationInformations")
|
||||||
|
@GET
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
|
||||||
|
List<RBACManagerImplementationInformation> getRbacManagerImplementationInformations()
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
|
||||||
@Path( "checkLdapConnection" )
|
@Path( "checkLdapConnection" )
|
||||||
@GET
|
@GET
|
||||||
|
|
|
@ -33,7 +33,9 @@ import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
||||||
import org.apache.archiva.redback.components.cache.Cache;
|
import org.apache.archiva.redback.components.cache.Cache;
|
||||||
import org.apache.archiva.redback.policy.CookieSettings;
|
import org.apache.archiva.redback.policy.CookieSettings;
|
||||||
import org.apache.archiva.redback.policy.PasswordRule;
|
import org.apache.archiva.redback.policy.PasswordRule;
|
||||||
|
import org.apache.archiva.redback.rbac.RBACManager;
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
|
import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation;
|
||||||
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
|
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||||
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
|
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
|
||||||
|
@ -199,6 +201,34 @@ public class DefaultRedbackRuntimeConfigurationService
|
||||||
return informations;
|
return informations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RBACManagerImplementationInformation> getRbacManagerImplementationInformations()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
Map<String, RBACManager> beans = applicationContext.getBeansOfType( RBACManager.class );
|
||||||
|
|
||||||
|
if ( beans.isEmpty() )
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<RBACManagerImplementationInformation> informations =
|
||||||
|
new ArrayList<RBACManagerImplementationInformation>( beans.size() );
|
||||||
|
|
||||||
|
for ( Map.Entry<String, RBACManager> entry : beans.entrySet() )
|
||||||
|
{
|
||||||
|
UserManager userManager = applicationContext.getBean( entry.getKey(), UserManager.class );
|
||||||
|
if ( userManager.isFinalImplementation() )
|
||||||
|
{
|
||||||
|
RBACManagerImplementationInformation information = new RBACManagerImplementationInformation();
|
||||||
|
information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) );
|
||||||
|
information.setDescriptionKey( userManager.getDescriptionKey() );
|
||||||
|
information.setReadOnly( userManager.isReadOnly() );
|
||||||
|
informations.add( information );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return informations;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean checkLdapConnection()
|
public Boolean checkLdapConnection()
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
|
|
|
@ -329,4 +329,15 @@ public class ArchivaRbacManager
|
||||||
{
|
{
|
||||||
log.warn( "eraseDatabase not implemented" );
|
log.warn( "eraseDatabase not implemented" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFinalImplementation()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescriptionKey()
|
||||||
|
{
|
||||||
|
return "archiva.redback.rbacmanager.archiva";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1217,7 +1217,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
|
|
||||||
RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
|
RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
|
||||||
,useUsersCache,cacheConfiguration){
|
,useUsersCache,cacheConfiguration,rbacManagerImpls){
|
||||||
$.log("new RedbackRuntimeConfiguration");
|
$.log("new RedbackRuntimeConfiguration");
|
||||||
var self=this;
|
var self=this;
|
||||||
this.modified=ko.observable(false);
|
this.modified=ko.observable(false);
|
||||||
|
@ -1226,6 +1226,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
this.userManagerImpls=ko.observableArray(userManagerImpls);
|
this.userManagerImpls=ko.observableArray(userManagerImpls);
|
||||||
this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
|
this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
|
||||||
|
|
||||||
|
this.rbacManagerImpls=ko.observableArray(rbacManagerImpls);
|
||||||
|
this.rbacManagerImpls.subscribe(function(newValue){self.modified(true)});
|
||||||
|
|
||||||
this.ldapConfiguration=ko.observable(ldapConfiguration);
|
this.ldapConfiguration=ko.observable(ldapConfiguration);
|
||||||
this.ldapConfiguration.subscribe(function(newValue){self.modified(true)});
|
this.ldapConfiguration.subscribe(function(newValue){self.modified(true)});
|
||||||
|
|
||||||
|
@ -1270,7 +1273,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
var redbackRuntimeConfiguration =
|
var redbackRuntimeConfiguration =
|
||||||
new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[]
|
new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[]
|
||||||
,data.useUsersCache,mapCacheConfiguration(data.usersCacheConfiguration));
|
,data.useUsersCache,mapCacheConfiguration(data.usersCacheConfiguration),data.rbacManagerImpls);
|
||||||
|
|
||||||
|
|
||||||
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
|
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
|
||||||
|
@ -1372,6 +1375,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
this.usedUserManagerImpls=ko.observableArray([]);
|
this.usedUserManagerImpls=ko.observableArray([]);
|
||||||
|
|
||||||
|
this.rbacManagerImpls=ko.observableArray([]);
|
||||||
|
|
||||||
this.modifiesLdapGroupMappings=ko.observableArray([]);
|
this.modifiesLdapGroupMappings=ko.observableArray([]);
|
||||||
|
|
||||||
this.allRoleNames=[];
|
this.allRoleNames=[];
|
||||||
|
@ -1692,7 +1697,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
var mainContent = $("#main-content");
|
var mainContent = $("#main-content");
|
||||||
mainContent.html(mediumSpinnerImg());
|
mainContent.html(mediumSpinnerImg());
|
||||||
|
|
||||||
$.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/userManagerImplementationInformation", {
|
$.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/userManagerImplementationInformations", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
@ -1706,7 +1711,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
||||||
|
|
||||||
var groups=[];
|
var groups=[];
|
||||||
|
var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.usedUserManagerImpls)>0
|
||||||
|
||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls)>0;
|
||||||
|
$.log("useLdap:"+useLdap);
|
||||||
// load ldap roles
|
// load ldap roles
|
||||||
$.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
|
$.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
@ -1716,7 +1723,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
$.log("groups number:"+groups.length);
|
$.log("groups number:"+groups.length);
|
||||||
redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
|
redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
|
||||||
}
|
}
|
||||||
} ).always(
|
} )
|
||||||
|
.always(
|
||||||
function() {
|
function() {
|
||||||
$.log("complete");
|
$.log("complete");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue