use of com.iplanet.services.comm.share.RequestSet in project OpenAM by OpenRock.
the class AuthContext method processRequest.
protected Document processRequest(String xmlRequest) throws AuthLoginException {
Document doc = null;
try {
Request request = new Request(xmlRequest);
RequestSet set = new RequestSet(AuthXMLTags.AUTH_SERVICE);
set.addRequest(request);
URL url = authServiceURL;
if (url.getProtocol().equals("https") && (nickName != null)) {
Class[] paramtype = { String.class };
Object[] param = { nickName };
String protHandler = protHandlerPkg + ".https.Handler";
Constructor construct = Class.forName(protHandler).getConstructor(paramtype);
URLStreamHandler handler = (URLStreamHandler) construct.newInstance(param);
url = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile(), handler);
}
if (authDebug.messageEnabled()) {
authDebug.message("Service URL : " + url.toString());
}
Vector responses = PLLClient.send(url, set, cookieTable);
if ((responses.isEmpty()) || (responses.size() != 1)) {
throw new L10NMessageImpl(amAuthContext, "responseError", null);
}
Response res = (Response) responses.elementAt(0);
String responseStr = (String) res.getContent();
doc = XMLUtils.getXMLDocument(new ByteArrayInputStream(responseStr.getBytes("UTF-8")));
} catch (Exception e) {
authDebug.message("error in getting service url", e);
throw new AuthLoginException(amAuthContext, "xmlProcessError", null, e);
}
return (doc);
}
use of com.iplanet.services.comm.share.RequestSet in project OpenAM by OpenRock.
the class RemoteHandler method flush.
/**
* Flush any buffered output.
*/
public synchronized void flush() {
if (recCount <= 0) {
if (Debug.messageEnabled()) {
Debug.message("RemoteHandler.flush(): no records " + "in buffer to send");
}
return;
}
Vector responses = new Vector();
if (Debug.messageEnabled()) {
Debug.message("RemoteHandler.flush(): sending buffered records");
}
String thisAMException = null;
try {
Iterator sidIter = reqSetMap.keySet().iterator();
while (sidIter.hasNext()) {
String currentLoggedBySID = (String) sidIter.next();
URL logHostURL = getLogHostURL(currentLoggedBySID);
if (logHostURL == null) {
Debug.error("RemoteHandler.flush(): logHostURL is null");
this.recCount = 0;
reqSetMap = new HashMap();
return;
}
RequestSet reqSet = (RequestSet) reqSetMap.get(currentLoggedBySID);
responses = PLLClient.send(logHostURL, reqSet);
Iterator respIter = responses.iterator();
while (respIter.hasNext()) {
Response resp = (Response) respIter.next();
String respContent = resp.getContent();
if (!respContent.equals("OK")) {
Debug.error("RemoteHandler.flush(): " + respContent + " on remote machine");
if (thisAMException == null) {
thisAMException = "RemoteHandler.flush(): " + respContent + " on remote machine";
}
}
}
}
} catch (Exception e) {
Debug.error("RemoteHandler.flush(): ", e);
}
this.recCount = 0;
reqSetMap = new HashMap();
if (thisAMException != null) {
throw new AMLogException(thisAMException);
}
}
use of com.iplanet.services.comm.share.RequestSet in project OpenAM by OpenRock.
the class RemoteHandler method publish.
/**
* This method sends the LogRecord to the remote logging service.
* @param logRecord The LogRecord to be published to the remote
* logging service.
*/
public synchronized void publish(java.util.logging.LogRecord logRecord) {
logName = logRecord.getLoggerName();
String xml = getFormatter().format(logRecord);
if (xml == null || xml.length() <= 0) {
if (Debug.warningEnabled()) {
Debug.warning(logName + ":RemoteHandler.publish : formatted xml is null");
}
return;
}
Request request = new Request(xml);
if (logRecord instanceof ILogRecord) {
Map logInfoMap = ((ILogRecord) logRecord).getLogInfoMap();
String loggedBySid = (String) logInfoMap.get(LogConstants.LOGGED_BY_SID);
if (loggedBySid != null) {
RequestSet reqSet = (RequestSet) reqSetMap.get(loggedBySid);
if (reqSet == null) {
reqSet = new RequestSet("Logging");
}
reqSet.addRequest(request);
reqSetMap.put(loggedBySid, reqSet);
}
}
this.recCount++;
if (this.recCount >= recCountLimit) {
if (Debug.messageEnabled()) {
Debug.message(logName + ":RemoteHandler.publish(): got " + recCount + " records, flushing all");
}
nonBlockingFlush();
}
}
Aggregations