'Code Muri'에 해당되는 글 690건

  1. 2014.11.29 Bndtools
  2. 2014.11.25 Support telnet on OSGI Console
  3. 2014.11.25 Modularizing existing web applications with OSGi
  4. 2014.11.24 Target Definition
  5. 2014.11.22 OSGI Useful commands
  6. 2014.11.19 WCF Routing with Failover and Load Balancing
  7. 2014.10.11 Address filter mismatch
  8. 2014.10.03 URL Rewrite
  9. 2014.08.12 Load Tests for WCF Services
  10. 2014.08.12 Tinyget - to test or to troubleshoot HTTP client-to-server communication
  11. 2014.07.24 The process of the hierarchy dump in android
  12. 2014.07.24 How to search android source using google
  13. 2014.07.24 Android Source Search Site
  14. 2014.07.15 Free wireframing set for powerpoint
  15. 2014.07.10 How to change chef-server's nginx configure
  16. 2014.07.10 sudo: cd: command not found
  17. 2014.06.17 WebScarab
  18. 2014.06.14 Check available HTTP methods
  19. 2014.06.14 DMZ (Computing)
  20. 2014.06.14 CSRF - Cross Site Request Forgery
2014. 11. 29. 03:01

Bndtools

It seems to be very helpful when developing the OSGI bundle.


http://bndtools.org/


The easy, powerful and productive way to develop with OSGi. Based on bnd and Eclipse.


2014. 11. 25. 06:51

Support telnet on OSGI Console

Type the following command at the OSGI console.



 

osgi> telnetd --port 1234 start

telnetd is running on 127.0.0.1:1234

osgi>

 


Reference : http://books.google.co.kr/books?id=zgBcBAAAQBAJ&pg=PT255&lpg=PT255&dq=connect+to+equinox+console+using+telnet&source=bl&ots=JE0yDkexpm&sig=ad3nta5ZKFZx9ZIk9h41YlIotu8&hl=ko&sa=X&ei=2aNzVMH0CoqX8QWEsoDYDw&ved=0CDQQ6AEwAzgK#v=onepage&q=connect%20to%20equinox%20console%20using%20telnet&f=false

2014. 11. 25. 06:26

Modularizing existing web applications with OSGi

The following site gives good explanation and examples to show how to modularize existing web applications with OSGI.


http://server.dzone.com/articles/modularizing-existing-web


To make examples to be run, the point is that you should make the new Target definition which loads bundles under [example]/rsp_repository/rsp_target_platform.


and don't forget to copy org.eclipse.pde.http.ui_1.0.0.jar file to the dropins folder under eclipse installed folder.


The following picture shows example.



rsp4j-example-workspace.zip




2014. 11. 24. 03:19

Target Definition

Target definition can be added by 


Windows > Preferences > Plug-in Development > Target Platform menu.




: Reload command is useful when you copied some bundle to plugin folder newly.


: In the case of locations, variables can be used as below





ex) ${project_loc}\lib 


ex) ${eclipse_home} 



If you specify import packages in the MANIFEST.MF file as below,


Import-Package:

javax.servlet.jsp.jstl.fmt



If no problem is, the specified jar will be added to the Plug-in Dependencies.





If not, check if the jar file including that package is in the target definition folder. This validation can be run at the "Run configuration" dialog as well.


2014. 11. 22. 07:17

OSGI Useful commands


help 


: lists all available commands


ss | grep text


: lists services which matches with text


bundle [bundle id]


: prints detailed information like Id,Status, Data Root and etc.


b [build id]


: prints all meta data related to this bundle


update [bundle id]


: applies newest bundle


diag [bundle id]


: prints diagnose messages


packages [package name]


: lists all the bundles which use the given package. Wild card can be used at package name.


install file:[file path]


: install a bundle into running OSGI environment. 


* [bundle symbolic name] also can be sued instead of [bundle id]



* And more useful console


CommandDescription
startStarts a bundle given an ID or symbolic name
stopStops a bundle given an ID or symbolic name
installAdds a bundle given a URL for the current instance
uninstallRemoves a bundle given a URL for the current instance
updateUpdates a bundle given a URL for the current instance
activeLists all active bundles in the current instance
headersList the headers for a bundle given an ID or symbolic name
ssLists a short status of all the bundles registered in the current instance
services <filter>Lists services given the proper filter
diagRuns diagnostics on a bundle given an ID or symbolic name


Refer : 

http://www.ibm.com/developerworks/library/os-ecl-osgiconsole/

http://isurues.wordpress.com/2009/01/01/useful-equinox-osgi-commands/

2014. 11. 19. 23:24

WCF Routing with Failover and Load Balancing

The following sample shows how to support failover and load balancing using WCF Routing.






WCFRoutingServiceTest_LB.zip


Sorry, but web.config has an error. Same service was specified as backup list so this causes to round robin routing to fail. Fix this problem by yourself.


References : http://www.codeproject.com/Articles/778575/WCF-Routing-Service-Part-III-Failover-Load-Balanci

2014. 10. 11. 08:36

Address filter mismatch

After setting the URL Rewriter on IIS I got the following error from WCF services which were set as  polling duplex or net.tcp protocols.



 The message with To 'http://localhost/WCFService.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver's EndpointAddresses agree.



The reason is that by default, WCF ensures that the To of each Message matches the intended address.


It's simple to resolve this. Set the AddressFilterMode as Any!


[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]


Here's sample code:



    [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
    public class CalculatorService : ICalculator
    {
        public double Add(double n1, double n2)
        {
            return n1 + n2;
        }

        public double Subtract(double n1, double n2)
        {
            return n1 - n2;
        }

        public double Multiply(double n1, double n2)
        {
            return n1 * n2;
        }

        public double Divide(double n1, double n2)
        {
            return n1 / n2;
        }
    }

References:

http://msdn.microsoft.com/en-us/library/system.servicemodel.addressfiltermode(v=vs.110).aspx 

https://social.msdn.microsoft.com/Forums/vstudio/en-US/b5ae495b-f5fb-4eed-ae21-2b2280d4fec3/address-filter-mismatch-wcf-addressing




2014. 10. 3. 08:49

URL Rewrite

HTTP Redirect VS URL Rewrite


1. HTTP Redirect


Redirecting sends a HTTP 301 or 302 to the client, 

telling the client that it should try to access the page using another URL. 

The client knows that there is another URL that should be used. 


2. URL Rewrite


Rewriting happens on the server, and simply is a translation of one URL to another, 

that is used by your web application. 

The client does not know that internally there is another URL, 

it just sees the one it sent to the server.


(http://forums.iis.net/t/1174487.aspx?How+does+URL+Rewrite+differ+from+HTTP+Redirect+)



Installing ARR manually without WebPI (Web Platform Installer)


    Refer: http://blogs.technet.com/b/erezs_iis_blog/archive/2013/11/27/installing-arr-manually-without-webpi.aspx


1. Stop IIS


2. Download and install the Web Farm Framework module. 


    2.1 Web Platform Installer 


    2.2 WebDeploy 2.0 


    2.3 http://www.iis.net/downloads/microsoft/web-farm-framework


3. Download and install the External cache 


    http://download.microsoft.com/download/3/4/1/3415F3F9-5698-44FE-A072-D4AF09728390/ExternalDiskCache_amd64_en-US.msi


4. Download and install the URL Rewrite


http://www.iis.net/downloads/microsoft/url-rewrite


5. Download and install the Application Request Routing


http://www.iis.net/downloads/microsoft/application-request-routing


6. Restart IIS


Example


Assume that we want to forward the url ending with "/test" like http://localhost/test to http://localhost:81/. 

The following example shows how to do this.




{R:2} means that the rest of url excepting 'http://host/test' address. You can check this from the test pattern.






☞ Tip 


To check what the problem is when setting the URL rewrite rule, access it in the server that owns the rule. Then, the browser will give you more information. In addition, use fiddler to check the whole access URL.


References


    - http://www.iis.net/learn/extensions/url-rewrite-module/modifying-http-response-headers

    - http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Rule_pattern_syntax

    - http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

        

2014. 8. 12. 23:31

Load Tests for WCF Services

Refer following links:


Generating Load Tests for WCF Services with the WCF Load Test Tool


http://blogs.msdn.com/b/mcsuksoldev/archive/2010/12/03/generating-load-tests-for-wcf-services-with-the-wcf-load-test-tool.aspx


Create and run a load test


http://msdn.microsoft.com/en-us/library/ms182594.aspx

2014. 8. 12. 22:09

Tinyget - to test or to troubleshoot HTTP client-to-server communication

TinyGet version 5.2

TinyGet 5.2 (TinyGet.exe) is a command-line Hypertext Transfer Protocol (HTTP) client that supports multiple threads and looping. You can use TinyGet to test or to troubleshoot HTTP client-to-server communication. By using TinyGet, you can customize your test request by configuring many different factors, including the authentication method, the HTTP version, and the output format. You can also use scripts that specify looping and multithreading.


Reference : http://support.microsoft.com/kb/840671/en

Download Link: http://www.microsoft.com/en-us/download/details.aspx?id=17275




2014. 7. 24. 07:29

The process of the hierarchy dump in android

The simple overview of ui dump process in android is like the following figure:

(2 years ago, I was involved in the project that developed the android test automation tool.)





The related source code is as below:


-----------------------------------------------------------------------------------

ViewServer.java

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/master/services/java/com/android/server/wm/ViewServer.java



class ViewServer implements Runnable {


    private final WindowManagerService mWindowManager;


    class ViewServerWorker implements Runnable, WindowManagerService.WindowChangeListener {

        private Socket mClient;

        private boolean mNeedWindowListUpdate;

        private boolean mNeedFocusedWindowUpdate;

        public ViewServerWorker(Socket client) {

            mClient = client;

            mNeedWindowListUpdate = false;

            mNeedFocusedWindowUpdate = false;

        }

        public void run() {

            BufferedReader in = null;

            try {

                in = new BufferedReader(new InputStreamReader(mClient.getInputStream()), 1024);

                final String request = in.readLine();

                String command;

                String parameters;

                int index = request.indexOf(' ');

                if (index == -1) {

                    command = request;

                    parameters = "";

                } else {

                    command = request.substring(0, index);

                    parameters = request.substring(index + 1);

                }

                boolean result;

                if (COMMAND_PROTOCOL_VERSION.equalsIgnoreCase(command)) {

                    result = writeValue(mClient, VALUE_PROTOCOL_VERSION);

                } else if (COMMAND_SERVER_VERSION.equalsIgnoreCase(command)) {

                    result = writeValue(mClient, VALUE_SERVER_VERSION);

                } else if (COMMAND_WINDOW_MANAGER_LIST.equalsIgnoreCase(command)) {

                    result = mWindowManager.viewServerListWindows(mClient);

                } else if (COMMAND_WINDOW_MANAGER_GET_FOCUS.equalsIgnoreCase(command)) {

                    result = mWindowManager.viewServerGetFocusedWindow(mClient);

                } else if (COMMAND_WINDOW_MANAGER_AUTOLIST.equalsIgnoreCase(command)) {

                    result = windowManagerAutolistLoop();

                } else {

                    result = mWindowManager.viewServerWindowCommand(mClient,command, parameters);

                }

   // ...

}

    }

}


-----------------------------------------------------------------------------------

WindowManagerService.java

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/master/services/java/com/android/server/wm/WindowManagerService.java



public class WindowManagerService extends IWindowManager.Stub

        implements Watchdog.Monitor, WindowManagerPolicy.WindowManagerFuncs,

                DisplayManagerService.WindowManagerFuncs, DisplayManager.DisplayListener {


    boolean viewServerWindowCommand(Socket client, String command, String parameters) {


        // Any uncaught exception will crash the system process

        try {

            // Find the hashcode of the window

            int index = parameters.indexOf(' ');

            if (index == -1) {

                index = parameters.length();

            }

            final String code = parameters.substring(0, index);

            int hashCode = (int) Long.parseLong(code, 16);

            // Extract the command's parameter after the window description

            if (index < parameters.length()) {

                parameters = parameters.substring(index + 1);

            } else {

                parameters = "";

            }

            final WindowState window = findWindow(hashCode);

            if (window == null) {

                return false;

            }

            data = Parcel.obtain();

            data.writeInterfaceToken("android.view.IWindow");

            data.writeString(command);

            data.writeString(parameters);

            data.writeInt(1);

            ParcelFileDescriptor.fromSocket(client).writeToParcel(data, 0);

            reply = Parcel.obtain();

            final IBinder binder = window.mClient.asBinder();

            // TODO: GET THE TRANSACTION CODE IN A SAFER MANNER

            binder.transact(IBinder.FIRST_CALL_TRANSACTION, data, reply, 0);


}

}


-----------------------------------------------------------------------------------

WindowState.java

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/master/services/java/com/android/server/wm/WindowState.java


import android.view.IWindow;


final class WindowState implements WindowManagerPolicy.WindowState {


    final IWindow mClient;


}


-----------------------------------------------------------------------------------

IWindow.aidl

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/com/android/internal/view/BaseIWindow.java


oneway interface IWindow {

    void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);

}


-----------------------------------------------------------------------------------

ViewRootImpl.java

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/17d28ca/core/java/android/view/ViewRootImpl.java


public final class ViewRootImpl implements ViewParent,

        View.AttachInfo.Callbacks, HardwareRenderer.HardwareDrawCallbacks {


    static class W extends IWindow.Stub {

        @Override

        public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {

            final ViewRootImpl viewAncestor = mViewAncestor.get();

            if (viewAncestor != null) {

                final View view = viewAncestor.mView;

                if (view != null) {

                    if (checkCallingPermission(Manifest.permission.DUMP) !=

                            PackageManager.PERMISSION_GRANTED) {

                        throw new SecurityException("Insufficient permissions to invoke"

                                + " executeCommand() from pid=" + Binder.getCallingPid()

                                + ", uid=" + Binder.getCallingUid());

                    }

                    OutputStream clientStream = null;

                    try {

                        clientStream = new ParcelFileDescriptor.AutoCloseOutputStream(out);

                        ViewDebug.dispatchCommand(view, command, parameters, clientStream);

                    } catch (IOException e) {

                        e.printStackTrace();

                    } finally {

                        if (clientStream != null) {

                            try {

                                clientStream.close();

                            } catch (IOException e) {

                                e.printStackTrace();

                            }

                        }

                    }

                }

            }

        }

    }


}



-----------------------------------------------------------------------------------

ViewDebug.java

-----------------------------------------------------------------------------------

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewDebug.java


/**

 * Various debugging/tracing tools related to {@link View} and the view hierarchy.

 */

class ViewDebug

{

void dispatchCommand(View view, String command, String parameters,

            OutputStream clientStream) throws IOException {

        if (REMOTE_COMMAND_DUMP.equalsIgnoreCase(command)) {

            dump(view, false, true, clientStream);

}




    /**

     * Dumps the view hierarchy starting from the given view.

     * @hide

     */

    public static void dump(View root, boolean skipChildren, boolean includeProperties,

            OutputStream clientStream) throws IOException {

        BufferedWriter out = null;

        try {

            out = new BufferedWriter(new OutputStreamWriter(clientStream, "utf-8"), 32 * 1024);

            View view = root.getRootView();

            if (view instanceof ViewGroup) {

                ViewGroup group = (ViewGroup) view;

                dumpViewHierarchy(group.getContext(), group, out, 0,

                        skipChildren, includeProperties);

            }

            out.write("DONE.");

            out.newLine();

        } catch (Exception e) {

            android.util.Log.w("View", "Problem dumping the view:", e);

        } finally {

            if (out != null) {

                out.close();

            }

        }

    }


    private static void dumpViewHierarchy(Context context, ViewGroup group,

            BufferedWriter out, int level, boolean skipChildren, boolean includeProperties) {

        if (!dumpView(context, group, out, level, includeProperties)) {

            return;

        }

        if (skipChildren) {

            return;

        }

        final int count = group.getChildCount();

        for (int i = 0; i < count; i++) {

            final View view = group.getChildAt(i);

            if (view instanceof ViewGroup) {

                dumpViewHierarchy(context, (ViewGroup) view, out, level + 1, skipChildren,

                        includeProperties);

            } else {

                dumpView(context, view, out, level + 1, includeProperties);

            }

            if (view.mOverlay != null) {

                ViewOverlay overlay = view.getOverlay();

                ViewGroup overlayContainer = overlay.mOverlayViewGroup;

                dumpViewHierarchy(context, overlayContainer, out, level + 2, skipChildren,

                        includeProperties);

            }

        }

        if (group instanceof HierarchyHandler) {

            ((HierarchyHandler)group).dumpViewHierarchyWithProperties(out, level + 1);

        }

    } 


}





2014. 7. 24. 07:21

How to search android source using google


Use site option as below:


windowmanageservice site:android.googlesource.com/platform/frameworks/base/


Without cpp file


windowmanageservice site:android.googlesource.com/platform/frameworks/base/ -cpp


This search doesn't catch the contents of the source, so just use to reach latest or specific version of android source file.

2014. 7. 24. 07:17

Android Source Search Site

The following site is really helpful to find something inside android  and kernel source!

This site uses OpenGrok internally. 2 years ago I also used this. 


http://androidxref.com/




Additional References : Set Opengrok Up

2014. 7. 15. 03:07

Free wireframing set for powerpoint

Source : http://designmodo.com/windows-8-wireframe/


The wireframing set is available as a .pptx file that you can download using the link below:



It is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License


Screen shots:







windows-8-wireframing-set.zip.pptx


2014. 7. 10. 03:02

How to change chef-server's nginx configure

There are two ways to achieve this.


First is to use nginx's config file directly. chef-server's nginx config file is located under 


 /var/opt/chef-server/nginx/etc/nginx.conf


After changing some settings, restart chef-server as below:


 sudo chef-server-ctl restart


Second is to use chef-server.rb file instead of using nginx.conf file


This file is located under /etc/chef-server. If it doesn't exist, just create it. put some values you want in it as below:


 nginx['ssl_port'] = 449


To see the more detailed information about this, visit the following link:


http://docs.opscode.com/config_rb_chef_server_optional_settings.html


After specifying some options, run the following commands to apply those.


 sudo chef-server-ctl reconfigure

 sudo chef-server-ctl restart



2014. 7. 10. 02:50

sudo: cd: command not found

just type following command


sudo su


and use cd command.

2014. 6. 17. 00:40

WebScarab

https://www.owasp.org/index.php/Category:OWASP_WebScarab_Project


WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols.


WebScarab operates as an intercepting proxy, allowing the operator to review and modify requests created by the browser before they are sent to the server, and to review and modify responses returned from the server before they are received by the browser.





2014. 6. 14. 19:08

Check available HTTP methods

It's very simple to check what kind of methods are available on target site using telnet.


This example assumes that you are using windows.


1. Run cmd.exe after typing Windows + R keys



2, Check if the telnet client is installed by typing 'telnet' as below. 


  



  If it's installed, following message will be shown





  If not, install it first.


3. Enter following command: 


telnet [server url or ip address] 80





4. Enter the following text after changing host info according to yours



OPTIONS / HTTP/1.1

Host: [server url or ip address]



This example used the following text



OPTIONS / HTTP/1.1

Host: 192.168.0.6



After sending this text, the result will be shown as below:





For the HTTP 1.0, following text can be used as text



OPTIONS * HTTP/1.0


Note: Some famous sites such as naver and other portals was already prohibited to this kind of access. 


But we can find out naver is using nginx as its HTTP server.






2014. 6. 14. 17:58

DMZ (Computing)

In computing, DMZ term is often used over networks.


DMZ is the very term that we know it as military related. Its full spells are "demilitarized zone". Korean is '비무장 지대'.


From Wikipedia



 In computer security, a DMZ or Demilitarized Zone (sometimes referred to as a perimeter network) is a physical or logical subnetwork that contains and exposes an organization's external-facing services to a larger and untrusted network, usually the Internet. The purpose of a DMZ is to add an additional layer of security to an organization's local area network(LAN); an external attacker only has direct access to equipment in the DMZ, rather than any other part of the network.



 내부 네트워크와 외부 네트워크가 DMZ로 연결할 수 있도록 허용하면서도, DMZ 내의 컴퓨터는 오직 외부 네트워크에만 연결할 수 있도록 한다는 점이다. 즉 DMZ 안에 있는 호스트들은 내부 네트워크로 연결할 수 없다. 이것은 DMZ에 있는 호스트들이 외부 네트워크로 서비스를 제공하면서 DMZ 안의 호스트의 칩입으로부터 내부 네트워크를 보호한다. 내부 네트워크로 불법적 연결을 시도하는 외부 네트워크의 누군가가 있다면, DMZ는 그들에게 막다른 골목이 된다.



2014. 6. 14. 09:04

CSRF - Cross Site Request Forgery

From Wikipedia


 Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf[1]) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts.[2] 


Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.



To understand difference between XSS and CSRF, read the highlighted sentences with color.