remove this ugly Object getPrincipal method

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412689 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-22 21:57:18 +00:00
parent 9eafbcc85a
commit a8544147e1
5 changed files with 11 additions and 91 deletions

View File

@ -63,7 +63,7 @@ public abstract class AbstractRepositoryAdmin
{
User user = auditInformation == null ? null : auditInformation.getUser();
AuditEvent event =
new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action );
new AuditEvent( repositoryId, user == null ? "null" : user.getUsername(), resource, action );
event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() );
for ( AuditListener listener : getAuditListeners() )

View File

@ -96,15 +96,7 @@ public abstract class AbstractRepositoryAdminTest
protected User getFakeUser()
{
SimpleUser user = new SimpleUser()
{
@Override
public Object getPrincipal()
{
return "root";
}
};
SimpleUser user = new SimpleUser();
user.setUsername( "root" );
user.setFullName( "The top user" );

View File

@ -1,64 +0,0 @@
package org.apache.archiva.security;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.Map;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.system.SecuritySystemConstants;
import org.apache.archiva.redback.users.User;
/**
* ArchivaXworkUser
*
*
*/
public final class ArchivaXworkUser
{
private ArchivaXworkUser()
{
// no touchy
}
public static String getActivePrincipal( Map<String, ?> sessionMap )
{
if ( sessionMap == null )
{
return UserManager.GUEST_USERNAME;
}
SecuritySession securitySession =
(SecuritySession) sessionMap.get( SecuritySystemConstants.SECURITY_SESSION_KEY );
if ( securitySession == null )
{
return UserManager.GUEST_USERNAME;
}
User user = securitySession.getUser();
if ( user == null )
{
return UserManager.GUEST_USERNAME;
}
return (String) user.getPrincipal();
}
}

View File

@ -139,11 +139,11 @@ public abstract class AbstractSecurityTest
// Setup Admin User.
User adminUser = createUser( USER_ADMIN, "Admin User" );
roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() );
roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getUsername() );
// Setup Guest User.
User guestUser = createUser( USER_GUEST, "Guest User" );
roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() );
roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getUsername() );
}
protected void restoreGuestInitialValues( String userId )

View File

@ -160,24 +160,20 @@ public class SecuritySystemStub
{
return new User()
{
public Object getPrincipal()
public String getUsername()
{
return "guest";
}
public String getUsername()
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public void setUsername( String name )
{
//To change body of implemented methods use File | Settings | File Templates.
}
public String getFullName()
{
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
public void setFullName( String name )
@ -349,19 +345,15 @@ public class SecuritySystemStub
{
return new User()
{
public Object getPrincipal()
public String getUsername()
{
return "guest";
}
public String getUsername()
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public void setUsername( String name )
{
//To change body of implemented methods use File | Settings | File Templates.
}
public String getFullName()