/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ClientDetectionDefaultImpl.java,v 1.5 2008/06/25 05:41:32 qcheng Exp $
*
*/
/**
* The <code>ClientDetectionInterface</code> interface needs to be implemented
* by services and applications serving multiple clients, to determine the
* client from which the request has originated. This interface detects the
* client type from the client request.
* @supported.all.api
*/
/**
* Creates a client detection default implementation instance.
*/
public ClientDetectionDefaultImpl() {
}
/**
* This is the method used by the interface to set the client-type.
* <code>ClientDetectionDefaultImpl</code> currently uses the following
* algorithm.
*
* <pre>
* if userAgent equals a known user-agent then
* compare userAgent length and store the longest match
* if clientType not found
* return the default clientType
* </pre>
*
* @param request
* The calling object passes in the
* <code>HTTPServletRequest</code>.
* @return The string corresponding to the client type.
* @throws ClientDetectionException
* if a default client type cannot be found
*/
throws ClientDetectionException {
int prevClientUALen = 0;
if (debug.messageEnabled()) {
}
//
// Perf: We wont have to iterate thro' all clients
//
if (debug.messageEnabled()) {
}
return clientType;
} else
{
if (debug.messageEnabled()) {
}
return clientType;
}
// Iterate through Clients, find and save the longest match
int i = 0;
while (knownClients.hasNext()) {
i++;
if (curClientUA != null) {
if (debug.messageEnabled()) {
+ curClientUA + " :: clientType = "
+ clientInstance.getClientType());
}
// We have a match
.getProperty("clientType");
// Check length
if (curClientUALen > prevClientUALen) {
if (debug.messageEnabled()) {
"type = " + clientType);
}
}
}
}
}
// If we don't have a single match, get the default clientType
if (clientType == null) {
if (debug.messageEnabled()) {
}
} else {
//
// Found a partial map - add it so our Map,
// so our next search is faster
//
}
// If we can't get the default clientType
if (clientType == null) {
throw new ClientDetectionException(CDMBundle
.getString("null_clientType"));
}
if (debug.messageEnabled()) {
}
return clientType;
}
/**
* This method contains the algorithm used to compare the
* <CODE>HTTPServletRequest</CODE>
* user-agent versus the <CODE>Client</CODE> user-agent.
*
* @param httpUA
* The HTTPServletRequest user-agent
* @param clientUA
* The Client userAgent
* @return True or false if they match
*/
return false;
}
return true;
} else {
return false;
}
}
}