Browse Source

remove this ugly Object getPrincipal method

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412689 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.4-M4
Olivier Lamy 11 years ago
parent
commit
a8544147e1

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java 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() )

+ 1
- 9
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java 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" );

+ 0
- 64
archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaXworkUser.java 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();
}
}

+ 2
- 2
archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java 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 )

+ 5
- 13
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java View File

@@ -160,24 +160,20 @@ public class SecuritySystemStub
{
return new User()
{
public Object getPrincipal()
{
return "guest";
}

public String getUsername()
{
return null; //To change body of implemented methods use File | Settings | File Templates.
return "guest";
}

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()
{
return "guest";
}

public String getUsername()
{
return null; //To change body of implemented methods use File | Settings | File Templates.
return "guest";
}

public void setUsername( String name )
{
//To change body of implemented methods use File | Settings | File Templates.
}

public String getFullName()

Loading…
Cancel
Save