use of java.util.logging.Logger in project GCViewer by chewiebug.
the class AbstractGCModelLoaderImpl method doInBackground.
@Override
protected GCModel doInBackground() throws Exception {
setProgress(0);
final GCModel result;
try {
result = loadGcModel();
} catch (DataReaderException | RuntimeException e) {
Logger logger = getGcResource().getLogger();
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Failed to load GCModel from " + getGcResource().getResourceName(), e);
}
throw e;
}
return result;
}
use of java.util.logging.Logger in project che by eclipse.
the class LanguageServerFileTypeRegister method start.
@Override
public void start(final Callback<WsAgentComponent, Exception> callback) {
Promise<List<LanguageDescriptionDTO>> registeredLanguages = serverLanguageRegistry.getSupportedLanguages();
registeredLanguages.then(new Operation<List<LanguageDescriptionDTO>>() {
@Override
public void apply(List<LanguageDescriptionDTO> langs) throws OperationException {
if (!langs.isEmpty()) {
JsArrayString contentTypes = JsArrayString.createArray().cast();
for (LanguageDescriptionDTO lang : langs) {
String primaryExtension = lang.getFileExtensions().get(0);
for (String ext : lang.getFileExtensions()) {
final FileType fileType = new FileType(resources.file(), ext);
fileTypeRegistry.registerFileType(fileType);
editorRegistry.registerDefaultEditor(fileType, editorProvider);
ext2langId.put(ext, lang.getLanguageId());
}
List<String> mimeTypes = lang.getMimeTypes();
if (mimeTypes.isEmpty()) {
mimeTypes = newArrayList("text/x-" + lang.getLanguageId());
}
for (String contentTypeId : mimeTypes) {
contentTypes.push(contentTypeId);
OrionContentTypeOverlay contentType = OrionContentTypeOverlay.create();
contentType.setId(contentTypeId);
contentType.setName(lang.getLanguageId());
contentType.setExtension(primaryExtension);
contentType.setExtends("text/plain");
// highlighting
OrionHighlightingConfigurationOverlay config = OrionHighlightingConfigurationOverlay.create();
config.setId(lang.getLanguageId() + ".highlighting");
config.setContentTypes(contentTypeId);
config.setPatterns(lang.getHighlightingConfiguration());
Logger logger = Logger.getLogger(LanguageServerFileTypeRegister.class.getName());
contentTypeRegistrant.registerFileType(contentType, config);
}
}
orionHoverRegistrant.registerHover(contentTypes, hoverProvider);
orionOccurrencesRegistrant.registerOccurrencesHandler(contentTypes, occurrencesProvider);
}
callback.onSuccess(LanguageServerFileTypeRegister.this);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
callback.onFailure(new Exception(arg.getMessage(), arg.getCause()));
}
});
}
use of java.util.logging.Logger in project android_frameworks_base by ParanoidAndroid.
the class CookiesTest method testCookiesAreNotLogged.
/**
* Test that we don't log potentially sensitive cookie values.
* http://b/3095990
*/
public void testCookiesAreNotLogged() throws IOException, URISyntaxException {
// enqueue an HTTP response with a cookie that will be rejected
server.enqueue(new MockResponse().addHeader("Set-Cookie: password=secret; Domain=fake.domain"));
server.play();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Logger logger = Logger.getLogger("org.apache.http");
StreamHandler handler = new StreamHandler(out, new SimpleFormatter());
logger.addHandler(handler);
try {
HttpClient client = new DefaultHttpClient();
client.execute(new HttpGet(server.getUrl("/").toURI()));
handler.close();
String log = out.toString("UTF-8");
assertTrue(log, log.contains("password"));
assertTrue(log, log.contains("fake.domain"));
assertFalse(log, log.contains("secret"));
} finally {
logger.removeHandler(handler);
}
}
use of java.util.logging.Logger in project MSEC by Tencent.
the class SendCmdsToAgentAndRun method doSendCmdsToAgentAndRun.
private String doSendCmdsToAgentAndRun(SendCmdsToAgentAndRunRequest request, StringBuffer outputFileName) {
Socket socket = new Socket();
Logger logger = Logger.getLogger("remote_shell");
try {
File file = new File(request.getLocalFileFullName());
//����ִ�к���������ļ�������
String outFileName = String.format("/tmp/output_%d.txt", (int) (Math.random() * Integer.MAX_VALUE));
outputFileName.delete(0, outputFileName.length());
outputFileName.append(outFileName);
//�������ļ�����ǩ��
String signature = "";
if (Main.privateKey != null) {
signature = geneSignature(request.getLocalFileFullName());
}
socket.connect(new InetSocketAddress(request.getRemoteServerIP(), 9981), 1000);
String s = "{\"handleClass\":\"SendCmdsToAgentAndRun\", \"requestBody\":{" + "\"cmdFileLength\":" + String.format("%d", file.length()) + ", \"outputFileName\":\"" + outFileName + "\"" + ", \"signature\":\"" + signature + "\"" + "}}";
s = Tools.getLengthField(s.length()) + s;
socket.getOutputStream().write(s.getBytes());
logger.info(String.format("write json complete.%s", s));
//send file content
FileInputStream fileInputStream = new FileInputStream(file);
byte[] buf = new byte[10240];
int total_len = 0;
while (true) {
int len = fileInputStream.read(buf);
if (len <= 0) {
break;
}
total_len += len;
socket.getOutputStream().write(buf, 0, len);
}
logger.info(String.format("write file bytes number:%d", total_len));
socket.shutdownOutput();
;
//recv the response
// length field 10bytes
total_len = 0;
while (total_len < 10) {
int len = socket.getInputStream().read(buf, total_len, 10 - total_len);
if (len <= 0) {
return "recv response failed!";
}
total_len += len;
}
int jsonLen = new Integer(new String(buf, 0, total_len).trim()).intValue();
if (jsonLen < 2) {
return "response json string empty";
}
logger.info(String.format("response json string len:%d", jsonLen));
total_len = 0;
while (jsonLen < buf.length && total_len < jsonLen) {
int len = socket.getInputStream().read(buf, total_len, jsonLen - total_len);
if (len <= 0) {
break;
}
total_len += len;
}
logger.info(String.format("read agent response bytes number:%d", total_len));
String jsonStr = new String(buf, 0, total_len);
JSONObject jsonObject = new JSONObject(jsonStr);
String message = jsonObject.getString("message");
int status = jsonObject.getInt("status");
if (status == 0) {
return "success";
} else {
return message;
}
} catch (IOException e) {
e.printStackTrace();
return e.toString();
}
}
use of java.util.logging.Logger in project MSEC by Tencent.
the class SendCmdsToAgentAndRun method exec.
public SendCmdsToAgentAndRunResponse exec(SendCmdsToAgentAndRunRequest request) {
Logger logger = Logger.getLogger("remote_shell");
logger.setLevel(Level.ALL);
logger.info(String.format("I will send cmd to agent, [%s][%s]", request.getLocalFileFullName(), request.getRemoteServerIP()));
StringBuffer sb = new StringBuffer();
String result = doSendCmdsToAgentAndRun(request, sb);
if (result.equals("success")) {
logger.info(String.format("output file name: %s", sb.toString()));
SendCmdsToAgentAndRunResponse response = new SendCmdsToAgentAndRunResponse();
response.setMessage("success");
response.setOutputFileName(sb.toString());
response.setStatus(0);
return response;
} else {
SendCmdsToAgentAndRunResponse response = new SendCmdsToAgentAndRunResponse();
response.setMessage(result);
response.setStatus(100);
return response;
}
}
Aggregations