/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 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: AmTomcatRealm.java,v 1.4 2009/05/13 00:54:32 kamna Exp $
*/
/**
* <b>AmTomcatRealm</b> is the facade for an underlying security realm used to
* authenticate Identity server users to Tomcat. Realms can be attached at any
* Container level, but will typically only be attached to a Context, or higher
* level, Container.
*
*/
static {
try {
if ((moduleAccess != null)
&& moduleAccess.isLogMessageEnabled()) {
"AmTomcatRealm: Realm Initialized");
}
if ((moduleAccess != null)
&& moduleAccess.isLogWarningEnabled()) {
"AmTomcatRealm: Realm Instantiation Error: " + ex);
}
}
}
/** Descriptive information about this Realm implementation */
"AmTomcatRealm - Realm implementation for Tomcat ";
/**
* The <code> AmTomcatRealm </code> returns the GenericPrincipal associated with
* the specified username and credentials; otherwise returns
* <code>null</code>.
*
* @param username
* Username of the Principal to look up
* @param credentials
* Password or other credentials to use in authenticating this
* username
*/
try {
if ((moduleAccess != null)
&& moduleAccess.isLogMessageEnabled()) {
"AmTomcatRealm: Authentication FAILED for "
+ username);
}
} else {
if ((moduleAccess != null)
&& moduleAccess.isLogMessageEnabled()) {
"AmTomcatRealm: Authentication SUCCESSFUL for "
+ username);
}
}
if ((moduleAccess != null)
&& moduleAccess.isLogMessageEnabled()) {
"AmTomcatRealm: User " + username
}
}
}
if (moduleAccess != null) {
"AmTomcatRealm: encountered exception "
+ username,
ex);
}
}
return tomcatUser;
}
/**
* Return the Principal associated with the specified username and
* credentials, if there is one; otherwise return <code>null</code>.
*
* @param username
* Username of the Principal to look up
* @param credentials
* Password or other credentials to use in authenticating this
* username
*/
byte[] credentials) {
return authenticate(
password);
}
/**
* Return the GenericPrincipal associated with the specified username and
* credentials, if there is one; otherwise return <code>null</code>.
*
* This is here since Tomcat GenericPrincipal changed the method signature
* between v6 and v7.
*
* @param realm
* Realm for the user
* @param username
* Username of the Principal to look up
* @param credentials
* Password or other credentials to use in authenticating this
* username
* @param rolesList
* list of Roles for the User
*/
boolean isV6 = true;
try {
isV6 = true;
constructor = GenericPrincipal.class.getConstructor(Realm.class, String.class, String.class, List.class);
if (constructor != null) {
}
} else {
isV6 = false;
if (constructor != null) {
}
}
} catch (Exception e) {
}
return retVal;
}
/**
* Return the Principal associated with the specified username, which
* matches the digest calculated using the given parameters using the method
* described in RFC 2069; otherwise return <code>null</code>.
*
* @param username
* Username of the Principal to look up
* @param digest
* Digest which has been submitted by the client
* @param nonce
* Unique (or supposedly unique) token which has been used for
* this request
* @param realm
* Realm name
* @param md5a2
* Second MD5 digest used to calculate the digest : MD5(Method +
* ":" + uri)
*/
throw new UnsupportedOperationException();
}
/**
* Return the Principal associated with the specified chain of X509 client
* certificates. If there is none, return <code>null</code>.
*
* @param certs
* Array of client certificates, with the first one in the array
* being the certificate of the client itself.
*/
throw new UnsupportedOperationException();
}
/**
* Return the Principal associated with the given user name.
*/
}
/**
* Return descriptive information about this Realm implementation and the
* corresponding version number, in the format
* <code><description>/<version></code>.
*/
return info;
}
/**
* Return the password associated with the given principal's user name.
*/
return (null);
}
return amRealm;
}
}
return moduleAccess;
}
}
}