/**
* 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: AMClientDetector.java,v 1.8 2008/09/04 16:16:34 dillidorai Exp $
*
*/
/*
* Portions Copyrighted [2010-2011] [ForgeRock AS]
*/
/**
* This is an utility to get the client type. This utility executes Client
* Detection Class provided in Client Detection Module Service and gets the
* client type. Default client type will be returned if there is no Client
* Detection Implementation provided
* @supported.all.api
*/
public class AMClientDetector {
private static boolean detectionEnabled;
"iplanet-am-client-detection-class";
"iplanet-am-client-types-manager-class";
"iplanet-am-client-detection-enabled";
private static boolean servicePassed = true;
static {
if (servicePassed) {
if (detectionEnabled) {
}
}
}
/**
* Constructs a <code>AMClientDetector</code> instance.
*/
public AMClientDetector() {
}
/**
* Applications can provide client detector implementation class
*
* @param className
* the name of the implementation class
*/
try {
}
} else {
}
}
/**
* Application provide custom detection class.
*
* @param cd
* class that implements <code>ClientDetectionInterface</code>.
*/
clientDetector = cd;
}
/**
* Returns the client type by executing client
* detector class provided in Client Detection Service.
*
* @param request
* HTTP Servlet Request.
* @return client type . Default client type will be returned if either the
* client detection is not enabled or the client detector class is
* not provided in <code>cdm</code> service. If it throws any
* exception by executing this class, this method will just return
* null .
*/
// Check whether the client detection is enabled or not
if (detectionEnabled) {
try {
if (clientDetector != null) {
}
if (debug.messageEnabled()) {
+ clientType);
}
}
}
clientType = "genericHTML";
if (debug.messageEnabled()) {
+ clientType);
}
return clientType;
}
/**
* Returns <code>true</code> if the client detection is enabled.
*
* @return <code>true</code> if the client detection is enabled.
*/
public boolean isDetectionEnabled() {
return detectionEnabled;
}
/**
* Returns the <code>ClientTypesManager</code> Instance.
*
* @return the <code>ClientTypesManager</code> Instance.
*/
return clientManager;
}
/* create instance of ClientTypesManager */
private static void initClientTypesManager() {
if ((ClientTypesManagerImpl != null)
try {
clientManager = new DefaultClientTypesManager();
}
} else {
clientManager = new DefaultClientTypesManager();
}
if (debug.warningEnabled()) {
+ " no client types found, "
+ " setting detectionEnabled to false");
}
detectionEnabled = false;
}
return;
}
/* retrieve client attributes from the ClientDetection service */
private static void getServiceSchemaManager() {
try {
} catch (Exception e) {
servicePassed = false;
return;
}
}
private static void getClientAttributes() {
detectionEnabled = true;
} else {
detectionEnabled = false;
}
if (debug.messageEnabled()) {
+ detectionEnabled);
}
}
}
private static void executeClientDetector() {
if ((clientDetectionClass != null)
try {
} catch (ClassNotFoundException ex) {
} catch (InstantiationException ex) {
+ " not able to instantiate: " + clientDetectionClass);
} catch (IllegalAccessException ex) {
}
}
}
/**
* Returns true if the client detection service is present or false if the
* client detection service is not present and the client attributes could
* not be retrieved.
*
* @return false if no Service is present. The default value is true.
*/
public static boolean isServicePassed() {
return servicePassed;
}
}