exceptionMsg = local.getMessage();
}
// test if authentication was successful
boolean isValid = false;
UserHandler handler = null;
if (doc != null) {
isValid = this.isValidAuthenticationFragment( doc );
if ( isValid ) {
if (this.getLogger().isInfoEnabled() ) {
this.getLogger().info("Authenticator: User authenticated using handler '" + configuration.getName()+"'");
}
AuthenticationContext authContext = new AuthenticationContext(this.context);
handler = new UserHandler(configuration, authContext);
MediaManager mediaManager = null;
String mediaType;
try {
mediaManager = (MediaManager)this.manager.lookup( MediaManager.ROLE );
mediaType = mediaManager.getMediaType();
} catch (ServiceException se) {
throw new ProcessingException("Unable to lookup media manager.", se);
} finally {
this.manager.release( mediaManager );
}
synchronized(authContext) {
// add special nodes to the authentication block:
// useragent, type and media
Element specialElement;
Text specialValue;
Element authNode;
authNode = (Element)doc.getFirstChild();
specialElement = doc.createElementNS(null, "type");
specialValue = doc.createTextNode("cocoon.authentication");
specialElement.appendChild(specialValue);
authNode.appendChild(specialElement);
specialElement = doc.createElementNS(null, "media");
specialValue = doc.createTextNode(mediaType);
specialElement.appendChild(specialValue);
authNode.appendChild(specialElement);
// store the authentication data in the context
authContext.init(doc);
// And now load applications
Iterator applications = configuration.getApplications().values().iterator();
while ( applications.hasNext() ) {
ApplicationConfiguration appHandler = (ApplicationConfiguration)applications.next();
if ( !appHandler.getLoadOnDemand() ) {
handler.getContext().loadApplicationXML( appHandler, this.resolver );
}
}
} // end sync
}