diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java | 109 |
1 files changed, 52 insertions, 57 deletions
diff --git a/pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java b/pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java index 39084395d..bb3937670 100644 --- a/pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java +++ b/pki/base/common/src/com/netscape/cms/authentication/TokenAuthentication.java @@ -46,12 +46,14 @@ import com.netscape.cmsutil.http.JssSSLSocketFactory; import com.netscape.cmsutil.xml.XMLObject; /** - * Token authentication. Checked if the given token is valid. + * Token authentication. + * Checked if the given token is valid. * <P> - * + * * @version $Revision$, $Date$ */ -public class TokenAuthentication implements IAuthManager, IProfileAuthenticator { +public class TokenAuthentication implements IAuthManager, + IProfileAuthenticator { /* result auth token attributes */ public static final String TOKEN_UID = "uid"; @@ -77,22 +79,21 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator /** * initializes the TokenAuthentication auth manager * <p> - * called by AuthSubsystem init() method, when initializing all available - * authentication managers. - * + * called by AuthSubsystem init() method, when initializing + * all available authentication managers. * @param name The name of this authentication manager instance. * @param implName The name of the authentication manager plugin. * @param config The configuration store for this authentication manager. */ public void init(String name, String implName, IConfigStore config) - throws EBaseException { + throws EBaseException { mName = name; mImplName = implName; mConfig = config; mUGSub = (IUGSubsystem) CMS.getSubsystem(CMS.SUBSYSTEM_UG); } - + /** * Gets the name of this authentication manager. */ @@ -106,7 +107,7 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator public String getImplName() { return mImplName; } - + public boolean isSSLClientRequired() { return false; } @@ -114,22 +115,21 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator /** * authenticates user(agent) by certificate * <p> - * called by other subsystems or their servlets to authenticate users - * (agents) - * - * @param authCred - authentication credential that contains an - * usrgrp.Certificates of the user (agent) + * called by other subsystems or their servlets to authenticate + * users (agents) + * @param authCred - authentication credential that contains + * an usrgrp.Certificates of the user (agent) * @return the authentication token that contains the following - * @exception EMissingCredential If a required credential for this - * authentication manager is missing. + * @exception EMissingCredential If a required credential for this + * authentication manager is missing. * @exception EInvalidCredentials If credentials cannot be authenticated. * @exception EBaseException If an internal error occurred. * @see com.netscape.certsrv.authentication.AuthToken * @see com.netscape.certsrv.usrgrp.Certificates */ public IAuthToken authenticate(IAuthCredentials authCred) - throws EMissingCredential, EInvalidCredentials, EBaseException { - + throws EMissingCredential, EInvalidCredentials, EBaseException { + CMS.debug("TokenAuthentication: start"); // force SSL handshake @@ -141,8 +141,8 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator // get group name from configuration file IConfigStore sconfig = CMS.getConfigStore(); - String sessionId = (String) authCred.get(CRED_SESSION_ID); - String givenHost = (String) authCred.get("clientHost"); + String sessionId = (String)authCred.get(CRED_SESSION_ID); + String givenHost = (String)authCred.get("clientHost"); String auth_host = sconfig.getString("securitydomain.host"); int auth_port = sconfig.getInteger("securitydomain.httpseeport"); @@ -151,8 +151,7 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator try { JssSSLSocketFactory factory = new JssSSLSocketFactory(); httpclient = new HttpClient(factory); - String content = CRED_SESSION_ID + "=" + sessionId + "&hostname=" - + givenHost; + String content = CRED_SESSION_ID+"="+sessionId+"&hostname="+givenHost; CMS.debug("TokenAuthentication: content=" + content); httpclient.connect(auth_host, auth_port); HttpRequest httprequest = new HttpRequest(); @@ -166,23 +165,21 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator HttpResponse httpresponse = httpclient.send(httprequest); c = httpresponse.getContent(); - } catch (Exception e) { - CMS.debug("TokenAuthentication authenticate Exception=" - + e.toString()); + } catch (Exception e) { + CMS.debug("TokenAuthentication authenticate Exception="+e.toString()); } if (c != null) { try { - ByteArrayInputStream bis = new ByteArrayInputStream( - c.getBytes()); + ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); XMLObject parser = null; try { parser = new XMLObject(bis); } catch (Exception e) { - CMS.debug("TokenAuthentication::authenticate() - " - + "Exception=" + e.toString()); - throw new EBaseException(e.toString()); + CMS.debug( "TokenAuthentication::authenticate() - " + + "Exception="+e.toString() ); + throw new EBaseException( e.toString() ); } String status = parser.getValue("Status"); @@ -198,15 +195,13 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator authToken.set(TOKEN_UID, uid); authToken.set(TOKEN_GID, gid); - if (context != null) { - CMS.debug("SessionContext.USER_ID " + uid - + " SessionContext.GROUP_ID " + gid); - context.put(SessionContext.USER_ID, uid); - context.put(SessionContext.GROUP_ID, gid); + if(context != null) { + CMS.debug("SessionContext.USER_ID " + uid + " SessionContext.GROUP_ID " + gid); + context.put(SessionContext.USER_ID, uid ); + context.put(SessionContext.GROUP_ID, gid ); } - CMS.debug("TokenAuthentication: authenticated uid=" + uid - + ", gid=" + gid); + CMS.debug("TokenAuthentication: authenticated uid="+uid+", gid="+gid); } catch (EBaseException e) { throw e; } catch (Exception e) { @@ -217,12 +212,11 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator } /** - * get the list of authentication credential attribute names required by - * this authentication manager. Generally used by the servlets that handle - * agent operations to authenticate its users. It calls this method to know - * which are the required credentials from the user (e.g. Javascript form - * data) - * + * get the list of authentication credential attribute names + * required by this authentication manager. Generally used by + * the servlets that handle agent operations to authenticate its + * users. It calls this method to know which are the + * required credentials from the user (e.g. Javascript form data) * @return attribute names in Vector */ public String[] getRequiredCreds() { @@ -230,15 +224,15 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator } /** - * get the list of configuration parameter names required by this - * authentication manager. Generally used by the Certificate Server Console - * to display the table for configuration purposes. CertUserDBAuthentication - * is currently not exposed in this case, so this method is not to be used. - * - * @return configuration parameter names in Hashtable of Vectors where each - * hashtable entry's key is the substore name, value is a Vector of - * parameter names. If no substore, the parameter name is the - * Hashtable key itself, with value same as key. + * get the list of configuration parameter names + * required by this authentication manager. Generally used by + * the Certificate Server Console to display the table for + * configuration purposes. CertUserDBAuthentication is currently not + * exposed in this case, so this method is not to be used. + * @return configuration parameter names in Hashtable of Vectors + * where each hashtable entry's key is the substore name, value is a + * Vector of parameter names. If no substore, the parameter name + * is the Hashtable key itself, with value same as key. */ public String[] getConfigParams() { return (mConfigParams); @@ -251,8 +245,8 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator } /** - * gets the configuretion substore used by this authentication manager - * + * gets the configuretion substore used by this authentication + * manager * @return configuration store */ public IConfigStore getConfigStore() { @@ -262,7 +256,7 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator // Profile-related methods public void init(IProfile profile, IConfigStore config) - throws EProfileException { + throws EProfileException { } /** @@ -294,13 +288,14 @@ public class TokenAuthentication implements IAuthManager, IProfileAuthenticator } /** - * Retrieves the descriptor of the given value parameter by name. + * Retrieves the descriptor of the given value + * parameter by name. */ public IDescriptor getValueDescriptor(Locale locale, String name) { return null; } public void populate(IAuthToken token, IRequest request) - throws EProfileException { + throws EProfileException { } } |