Search This Blog

Monday, April 15, 2013

On RHEL in FIPS Mode

Went to an excellent talk by Steve Grubb of Red Hat that went over some of the particulars of the security systems in Red Hat Enterprise Linux. This talk really collected together a lot of the information that I had been searching for. I guess it is a fairly niche market that is searching for auditing capabilities, FIPS mode, and the like, so information was fairly thin until his talk. You can find his slides here.
For me the most important information at the moment is the FIPS 140-2 mode for RHEL 5 platforms. I was aware there were efforts to make this happen, you can use the fipscheck program to verify select binary integrity on start up, OpenSSH was being built with a FIPS mode, and so on, but the slide on page 40 gave me the main command to bring this all together.
  • mkinitrd –with-fips -f /boot/initrd-$(uname -r).img $(uname -r)
  • Add “fips=1” to grub kernel boot line
  • Reboot
Now two caveats that I know of so far: in order for fipscheck to work, prelinking must be disabled, otherwise the hashes will change every time prelinking is re-run (which happens nightly). So in order to disable prelinking on a system do the following:
  • Edit /etc/sysconfing/prelink and set ‘PRELINKING=no’
  • Execute ‘sudo prelink -ua’ to remove relinking, or just wait until the nightly prelinking is run and everything is cleaned up.
As well /boot has to be a separate partition on your system.
There is now a Red Hat Knowledge base article up that describes this process, sadly you have to be logged in now to see Red Hat knowledge base articles.

Wednesday, April 10, 2013

How to send SMS message in Android


In Android, you can use SmsManager API or device’s Built-in SMS application to send a SMS message. In this tutorial, we show you two basic examples to send SMS message :
  1. SmsManager API
    SmsManager smsManager = SmsManager.getDefault();
     smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
  2. Built-in SMS application
    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
     sendIntent.putExtra("sms_body", "default content"); 
     sendIntent.setType("vnd.android-dir/mms-sms");
     startActivity(sendIntent);
Of course, both need SEND_SMS permission.
<uses-permission android:name="android.permission.SEND_SMS" />
P.S This project is developed in Eclipse 3.7, and tested with Samsung Galaxy S2 (Android 2.3.3).
Note
The Built-in SMS application solution is the easiest way, because you let device handle everything for you.

1. SmsManager Example

Android layout file to textboxes (phone no, sms message) and button to send the SMS message.
File : res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
 
    <TextView
        android:id="@+id/textViewPhoneNo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter Phone Number : "
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <EditText
        android:id="@+id/editTextPhoneNo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:phoneNumber="true" >
    </EditText>
 
    <TextView
        android:id="@+id/textViewSMS"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter SMS Message : "
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <EditText
        android:id="@+id/editTextSMS"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:lines="5"
        android:gravity="top" />
 
    <Button
        android:id="@+id/buttonSend"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Send" />
 
</LinearLayout>
File : SendSMSActivity.java – Activity to send SMS via SmsManager.
package com.mkyong.android;
 
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
 
public class SendSMSActivity extends Activity {
 
 Button buttonSend;
 EditText textPhoneNo;
 EditText textSMS;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 
  buttonSend = (Button) findViewById(R.id.buttonSend);
  textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo);
  textSMS = (EditText) findViewById(R.id.editTextSMS);
 
  buttonSend.setOnClickListener(new OnClickListener() {
 
   @Override
   public void onClick(View v) {
 
     String phoneNo = textPhoneNo.getText().toString();
     String sms = textSMS.getText().toString();
 
     try {
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNo, null, sms, null, null);
    Toast.makeText(getApplicationContext(), "SMS Sent!",
       Toast.LENGTH_LONG).show();
     } catch (Exception e) {
    Toast.makeText(getApplicationContext(),
     "SMS faild, please try again later!",
     Toast.LENGTH_LONG).show();
    e.printStackTrace();
     }
 
   }
  });
 }
}
File : AndroidManifest.xml , need SEND_SMS permission.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mkyong.android"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk android:minSdkVersion="10" />
 
    <uses-permission android:name="android.permission.SEND_SMS" />
 
    <application
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".SendSMSActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
 
</manifest>
See demo :
send sms message via smsmanager


'via Blog this'