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 )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public void removeListener( RBACManagerListener listener )
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
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 )
{
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ return false;
}
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 )
throws RbacObjectInvalidException, RbacManagerException
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
public void saveRoles( Collection<Role> roles )
throws RbacObjectInvalidException, RbacManagerException
{
- //To change body of implemented methods use File | Settings | File Templates.
+
}
public Role getRole( String roleName )
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 )
* @author Olivier Lamy
* @since 1.4-M4
*/
-@XmlRootElement ( name = "userManagerImplementationInformation" )
+@XmlRootElement(name = "userManagerImplementationInformation")
public class UserManagerImplementationInformation
+ extends AbstractImplementationInformation
implements Serializable
{
- private String beanId;
-
- private String descriptionKey;
-
- private boolean readOnly;
public UserManagerImplementationInformation()
{
public UserManagerImplementationInformation( String beanId, String descriptionKey, boolean readOnly )
{
- this.beanId = beanId;
- this.descriptionKey = descriptionKey;
- this.readOnly = readOnly;
- }
-
- public String getBeanId()
- {
- return beanId;
- }
-
- public void setBeanId( String beanId )
- {
- this.beanId = beanId;
+ super( beanId, descriptionKey, readOnly );
}
- 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();
- }
}
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.LdapConfiguration;
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.security.common.ArchivaRoleConstants;
Boolean updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
throws ArchivaRestServiceException;
- @Path("userManagerImplementationInformation")
+ @Path("userManagerImplementationInformations")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
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" )
@GET
import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.redback.policy.CookieSettings;
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.rest.api.model.RBACManagerImplementationInformation;
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
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()
throws ArchivaRestServiceException
{
log.warn( "eraseDatabase not implemented" );
}
+
+ @Override
+ public boolean isFinalImplementation()
+ {
+ return false;
+ }
+
+ public String getDescriptionKey()
+ {
+ return "archiva.redback.rbacmanager.archiva";
+ }
}
RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
- ,useUsersCache,cacheConfiguration){
+ ,useUsersCache,cacheConfiguration,rbacManagerImpls){
$.log("new RedbackRuntimeConfiguration");
var self=this;
this.modified=ko.observable(false);
this.userManagerImpls=ko.observableArray(userManagerImpls);
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.subscribe(function(newValue){self.modified(true)});
var redbackRuntimeConfiguration =
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){
this.usedUserManagerImpls=ko.observableArray([]);
+ this.rbacManagerImpls=ko.observableArray([]);
+
this.modifiesLdapGroupMappings=ko.observableArray([]);
this.allRoleNames=[];
var mainContent = $("#main-content");
mainContent.html(mediumSpinnerImg());
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/userManagerImplementationInformation", {
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/userManagerImplementationInformations", {
type: "GET",
dataType: 'json',
success: function(data) {
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
var groups=[];
-
+ var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.usedUserManagerImpls)>0
+ ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls)>0;
+ $.log("useLdap:"+useLdap);
// load ldap roles
$.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
type: "GET",
$.log("groups number:"+groups.length);
redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
}
- } ).always(
+ } )
+ .always(
function() {
$.log("complete");