IOS Security

Here is a basic simple way to prevent or make it harder for hackers from peeking into your IOS code in released binary by using macro in critical section of your code:

#ifndef DEBUG SEC_IS_BEING_DEBUGGED_RETURN_NIL(); #endif

and prevent gdb from attaching to a running process by adding code in main():
#ifndef DEBUG
    ptrace(PT_DENY_ATTACH, 0, 0, 0);
#endif

The above ptrace code does not prevent hackers from changing the registers values before executing ptrace but this is good enough practice for most of us.

《雨ニモマケズ》(不怕風雨)

雨ニモマケズ 不要輸給雨
風ニモマケズ 不要輸給風
雪ニモ夏ノ暑サニモマケヌ 也不要輸給冰雪和夏天的炙熱
丈夫ナカラダヲモチ 保持健康的身體

慾ハナク 沒有貪念
決シテ瞋ラズ 絕對不要生氣
イツモシヅカニワラッテヰル 總是沉靜的微笑
一日ニ玄米四合ト 一日吃四合的糙米
味噌ト少シノ野菜ヲタベ 一點味噌和青菜

アラユルコトヲ 不管遇到甚麼事
ジブンヲカンジョウニ入レズニ 先別加入己見
ヨクミキキシワカリ 好好的看、聽、了解
ソシテワスレズ 而後謹記在心不要忘記

野原ノ松ノ林ノ蔭ノ 在原野松林的樹蔭中
小サナ萱ブキノ小屋ニヰテ 有我棲身的小小的茅草屋

東ニ病気ノコドモアレバ 東邊若有生病的孩童
行ッテ看病シテヤリ 去照顧他的病

西ニツカレタ母アレバ 西方若有疲倦的母親
行ッテソノ稲ノ束ヲ負ヒ 去幫他扛起稻桿

南ニ死ニソウナ人アレバ 南邊如果有快去世的人
行ッテコハガラナクテモイゝトイヒ 去告訴他:不要害怕

北ニケンクワヤソショウガアレバ 北方如果有吵架的人們
ツマラナイカラヤメロトイヒ 去跟他們說:別做這麼無聊的事情了!

ヒドリノトキハナミダヲナガシ 旱災的時候擔心的流下眼淚
サムサノナツハオロオロアルキ 夏季卻寒流來襲,不安的來回踱步
ミンナニデクノボートヨバレ 大家說我像個傻子
ホメラレモセズ 不需要別人稱讚
クニモサレズ 也無須他人為我擔憂

サウイフモノニ 這就是
ワタシハナリタイ 我想成為的人。

宮澤賢治 1896 - 1933

You have to trust in something–your gut, destiny, life, karma, whatever–because believing that the dots will connect down the road will give you the confidence to follow your heart, even when it leads you off the well-worn path, and that will make all the difference.

Steve Jobs, 1955 - 2011

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma, which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice, heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

Steve Jobs, 1955 - 2011

My friends, love is better than anger. Hope is better than fear. Optimism is better than despair. So let us be loving, hopeful and optimistic. And we’ll change the world.

Jack Layton, 1950-2011

SAP PI Java Mapping from 7.0 to 7.1

In SAP PI 7.0, if you are using Java mapping, you would have to copy PI 7.0 aii_map_api.jar into your prefered JAVA IDE and start your mapping code.  The skeleton code should look something like this:

package com.objectbiz.pi.mymapping;

import com.sap.aii.mapping.api.*;
import java.io.*

public class MyJavaMapping implements StreamTransformation {

  public void execute(InputStream in, OutputStream out)
                      throws StreamTransformationException {
        // Add your code here
  }
}

When you upgrade to SAP PI 7.1, the Java StreamTransformation class has been deprecated and the new JAR com.sap.xpi.ib.mapping.lib.jar is located in usr/sap/<SID>/DVEBMGS<nr>/j2ee/cluster/bin/: ext/com.sap.xi.mapping.api.lib/lib:com.sap.xpi.ib.mapping.lib.jar and to make your code backward compatible, you would:

package com.objectbiz.pi.mymapping;

import com.sap.aii.mapping.api.*;
import java.io.*;


public class MyJavaMapping extends AbstractTransformation{

  public void transform(TransformationInput arg0, TransformationOutput arg1)
   throws StreamTransformationException { 

   this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
  }

  public void execute(InputStream in, OutputStream out)
        throws StreamTransformationException {
       // Add your PI 7.0 code here
  }
}

Notes:

  • In PI 7.1 Java mapping program must extends the abstract class AbstractTransformation.
  • Each JAVA Mapping using program 7.1 API must implement the method transform(TransformationInput input, TransformationOutput output).
  • In the JAVA Mapping using program 7.1 API  trace Object (AbstractTrace) is obtained using getTrace() Method of AbstractTransformation class.
  • One of the most useful features of the 7.1 JAVA API is now it supports parameters in the mapping (inline with parameterized message mapping).
  • A DynamicConfiguration is a map containing adapter specific message attributes. It associates DynamicConfigurationKeys with string values. The DynamicConfiguration object is obtained using method getDynamicConfiguration()of class com.sap.aii.mapping.api.TransformationInput.

Enjoy!

Rendering JSON in Spring 3

In Spring 3.0 the AnnotationMethodHandlerAdapter is extended to support the @RequestBody and has the following HttpMessageConverters registered by default:

  • ByteArrayHttpMessageConverter converts byte arrays.
  • StringHttpMessageConverter converts strings.
  • FormHttpMessageConverter converts form data to/from a MultiValueMap<String,String>.
  • SourceHttpMessageConverter converts to/from a javax.xml.transform.Source.
  • MarshallingHttpMessageConverter converts to/from an object using the org.springframework.oxm package.

In-order to support JavaScript Object Notation - JSON response, you will need to create an AnnotationMethodHandlerAdapter bean in your spring configuration with a MappingJacksonHttpMessageConverter and annotate your Controller service method with the @RequestBody annotation.

 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="order" value="1" />
<property name="messageConverters">
<list>
<!-- Message converters -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.FormHttpMessageConverter"/>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>

The above configuration instruct Spring to iterate over message converters sequentially until it find one that matches the object you are returning.

Listing 1.

@Controller
public class MovieController {

@RequestMapping(value="/movie/{id}", method=RequestMethod.GET)
@ResponseBody
public Movie getMovie(@PathVariable Integer id)
{
return MovieService.findMovie(id);
}
}

In the listing 1 example above, the getMovie method returns a Movie object, Spring iterate through the message converters in the AnnotationMethodHandlerAdapter list for a suitable message converter and because Movie class is not handled by others, it fall back to MappingJacksonHttpMessageConverter hence returned as JSON.

5 key managerial roles to remember.

Innovator: engaging others’ innovative ideas

Director: effective goal and expectation setting

Motivator: inspiring and motivating others

Enabler: supporting performance and removing roadblocks

Coach: developing individuals and building teams

I have never for one instant seen clearly within myself; how then would you have me judge the deeds of others.

Maurice Maeterlinck (1862-1949), Belgian writer and Nobel laureate