mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SWIFT to HEAD
25629: ALF-7069: - changed getNodes to a POST request - beefed up unit tests + some performance tests ALF-7070: - initial checkin, works end-to-end, still work-in-progress - unit + performance tests 25630: ALF-7069: removed files that are no longer needed 25640: Merged BRANCHES\DEV\SOLR to BRANCHES\DEV\SWIFT 25079: SOLR check point: ALF-4259: SOLR Integration 25217: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming 25315: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming 25577: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming 25604: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming 25610: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming 25651: - enabled OpenCMIS server ticket authentication - added OpenCMIS client API (incomplete) 25667: Merged BRANCHES/DEV/BM to BRANCHES/DEV/SWIFT: 25030: Repo BM Sprint 1 - example using JMeter (WebDAV & CMIS) 25054: Repo BM Sprint 1 - milestone 2 25078: Repo BM sprint 1 - milestone 3 (ALF-6794) 25675: ALF-7068: SOLR 075 Improved cache rebuild performance - delta + query cache warming - fix queries against un-optimized index 25676: Merged BRANCHES/DEV/BM to BRANCHES/DEV/SWIFT: commit mergeinfo 25683: RepoBM: OpenCMIS - use shared libs (from 3rd-party project) - change default url (from ".../alfresco/opencmis-atom" to ".../alfresco/cmisatom") 25767: ALF-7339: SOLR 020 Index track and build from SOLR - Initial hook up point and proto type for config 25787: ALF-7070: - owner, associations, type conversions SOLR Client-side API to call into repository SOLR APIs 25818: added webscripts root object as an entry point to OpenCMIS client sessions (local and remote) 25855: Bug fix: keep CMIS connection manager reference git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28089 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.security.authentication;
|
||||
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Helper to process username / password pairs passed to the remote tier
|
||||
*
|
||||
* Identifies whether username / password is a ticket.
|
||||
*
|
||||
* Is ticket, if one of the following is true:
|
||||
*
|
||||
* a) Username == "ROLE_TICKET" (in any case) b) Username is not specified (i.e.
|
||||
* null) c) Username is zero length
|
||||
*/
|
||||
public class Authorization
|
||||
{
|
||||
public static String TICKET_USERID = PermissionService.ROLE_PREFIX + "TICKET";
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
private String ticket;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param authorization
|
||||
*/
|
||||
public Authorization(String authorization)
|
||||
{
|
||||
ParameterCheck.mandatoryString("authorization", authorization);
|
||||
int idx = authorization.indexOf(':');
|
||||
|
||||
if (idx == -1)
|
||||
{
|
||||
setUser(null, authorization);
|
||||
} else
|
||||
{
|
||||
setUser(authorization.substring(0, idx), authorization.substring(idx + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public Authorization(String username, String password)
|
||||
{
|
||||
setUser(username, password);
|
||||
}
|
||||
|
||||
private void setUser(String username, String password)
|
||||
{
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
if (username == null || username.length() == 0 || username.equalsIgnoreCase(TICKET_USERID))
|
||||
{
|
||||
this.ticket = password;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public char[] getPasswordCharArray()
|
||||
{
|
||||
return password == null ? null : password.toCharArray();
|
||||
}
|
||||
|
||||
public boolean isTicket()
|
||||
{
|
||||
return ticket != null;
|
||||
}
|
||||
|
||||
public String getTicket()
|
||||
{
|
||||
return ticket;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.security.authentication;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Test Authorization
|
||||
*/
|
||||
public class AuthorizationTest extends TestCase
|
||||
{
|
||||
private static String USER = "user";
|
||||
private static String PASSWORD = "pass";
|
||||
|
||||
public void testInvalidAuthorization()
|
||||
{
|
||||
try
|
||||
{
|
||||
new Authorization(null);
|
||||
fail();
|
||||
}
|
||||
catch(IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
new Authorization("username:password:invalid");
|
||||
fail();
|
||||
}
|
||||
catch(IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void testAuthorization()
|
||||
{
|
||||
Authorization auth1 = new Authorization(USER, PASSWORD);
|
||||
assertUserPass(USER, PASSWORD, auth1);
|
||||
Authorization auth2 = new Authorization("", PASSWORD);
|
||||
assertTicket("", PASSWORD, auth2);
|
||||
Authorization auth3 = new Authorization(null, PASSWORD);
|
||||
assertTicket(null, PASSWORD, auth3);
|
||||
Authorization auth4 = new Authorization(Authorization.TICKET_USERID, PASSWORD);
|
||||
assertTicket(Authorization.TICKET_USERID, PASSWORD, auth4);
|
||||
Authorization auth5 = new Authorization(Authorization.TICKET_USERID.toLowerCase(), PASSWORD);
|
||||
assertTicket(Authorization.TICKET_USERID.toLowerCase(), PASSWORD, auth5);
|
||||
}
|
||||
|
||||
public void testUserPass()
|
||||
{
|
||||
Authorization auth1 = new Authorization(USER + ":" + PASSWORD);
|
||||
assertUserPass(USER, PASSWORD, auth1);
|
||||
Authorization auth2 = new Authorization(":" + PASSWORD);
|
||||
assertTicket("", PASSWORD, auth2);
|
||||
Authorization auth3 = new Authorization(PASSWORD);
|
||||
assertTicket(null, PASSWORD, auth3);
|
||||
Authorization auth4 = new Authorization(Authorization.TICKET_USERID + ":" + PASSWORD);
|
||||
assertTicket(Authorization.TICKET_USERID, PASSWORD, auth4);
|
||||
Authorization auth5 = new Authorization(Authorization.TICKET_USERID.toLowerCase() + ":" + PASSWORD);
|
||||
assertTicket(Authorization.TICKET_USERID.toLowerCase(), PASSWORD, auth5);
|
||||
}
|
||||
|
||||
private void assertUserPass(String user, String pass, Authorization auth)
|
||||
{
|
||||
assertEquals(user, auth.getUserName());
|
||||
assertEquals(pass, auth.getPassword());
|
||||
assertFalse(auth.isTicket());
|
||||
assertNull(auth.getTicket());
|
||||
}
|
||||
|
||||
private void assertTicket(String user, String pass, Authorization auth)
|
||||
{
|
||||
assertEquals(user, auth.getUserName());
|
||||
assertEquals(pass, auth.getPassword());
|
||||
assertTrue(auth.isTicket());
|
||||
assertEquals(pass, auth.getTicket());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user