org.glite.slcs.util
Class Utils

java.lang.Object
  extended by org.glite.slcs.util.Utils

public class Utils
extends java.lang.Object

Utils some utility functions

Version:
$Revision: 1.4 $
Author:
Valery Tschopp

Method Summary
static java.lang.String convertShibbolethUTF8ToUnicode(java.lang.String shibUTF8)
          Shibboleth sends values UTF8 encoded.
static java.lang.String convertUnicodeToISOLatin1(java.lang.String unicode)
          Converts a Java unicode string in a ISO-8859-1 (ISO Latin1) string.
static java.lang.String filterISOLatin1AccentuedString(java.lang.String latin1)
          Converts ISO-8859-1 accentued chars into their unaccentued equivalent 192 => 'A', 193 => 'A', 194 => 'A', 195 => 'A', 196 => 'Ae', 197 => 'A', 198 => 'AE', 199 => 'C', 200 => 'E', 201 => 'E', 202 => 'E', 203 => 'E', 204 => 'I', 205 => 'I', 206 => 'I', 207 => 'I', 209 => 'N', 210 => 'O', 211 => 'O', 212 => 'O', 213 => 'O', 214 => 'Oe', 216 => 'O', 217 => 'U', 218 => 'U', 219 => 'U', 220 => 'Ue', 221 => 'Y', 223 => 'ss', 224 => 'a', 225 => 'a', 226 => 'a', 227 => 'a', 228 => 'ae', 229 => 'a', 230 => 'ae', 231 => 'c', 232 => 'e', 233 => 'e', 234 => 'e', 235 => 'e', 236 => 'i', 237 => 'i', 238 => 'i', 239 => 'i', 241 => 'n', 242 => 'o', 243 => 'o', 244 => 'o', 245 => 'o', 246 => 'oe', 248 => 'o', 249 => 'u', 250 => 'u', 251 => 'u', 252 => 'ue', 253 => 'y', 255 => 'y'
static java.lang.String filterUnicodeAccentuedString(java.lang.String unicode)
          Filter an unicode Java string accentuated characters and replace them with their non-accentuated equivalants.
static boolean setFilePermissions(java.io.File file, int mode)
          Sets permissions on a given file.
static java.lang.String toHexString(byte[] b)
          Returns the hexadecimal representation of the byte array (uppercase).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

filterUnicodeAccentuedString

public static java.lang.String filterUnicodeAccentuedString(java.lang.String unicode)
Filter an unicode Java string accentuated characters and replace them with their non-accentuated equivalants.

Parameters:
unicode - The string to filter.
Returns:
A unicode string without accentuated characters or null if the filtering failed.

filterISOLatin1AccentuedString

public static java.lang.String filterISOLatin1AccentuedString(java.lang.String latin1)
Converts ISO-8859-1 accentued chars into their unaccentued equivalent 192 => 'A', 193 => 'A', 194 => 'A', 195 => 'A', 196 => 'Ae', 197 => 'A', 198 => 'AE', 199 => 'C', 200 => 'E', 201 => 'E', 202 => 'E', 203 => 'E', 204 => 'I', 205 => 'I', 206 => 'I', 207 => 'I', 209 => 'N', 210 => 'O', 211 => 'O', 212 => 'O', 213 => 'O', 214 => 'Oe', 216 => 'O', 217 => 'U', 218 => 'U', 219 => 'U', 220 => 'Ue', 221 => 'Y', 223 => 'ss', 224 => 'a', 225 => 'a', 226 => 'a', 227 => 'a', 228 => 'ae', 229 => 'a', 230 => 'ae', 231 => 'c', 232 => 'e', 233 => 'e', 234 => 'e', 235 => 'e', 236 => 'i', 237 => 'i', 238 => 'i', 239 => 'i', 241 => 'n', 242 => 'o', 243 => 'o', 244 => 'o', 245 => 'o', 246 => 'oe', 248 => 'o', 249 => 'u', 250 => 'u', 251 => 'u', 252 => 'ue', 253 => 'y', 255 => 'y'


convertShibbolethUTF8ToUnicode

public static java.lang.String convertShibbolethUTF8ToUnicode(java.lang.String shibUTF8)
Shibboleth sends values UTF8 encoded. But mod_jk seems to screw the encoding up.

Parameters:
shibUTF8 - The strange encoded shibboleth UTF8 string.
Returns:
a Java unicode string or null if the convertion failed.

convertUnicodeToISOLatin1

public static java.lang.String convertUnicodeToISOLatin1(java.lang.String unicode)
Converts a Java unicode string in a ISO-8859-1 (ISO Latin1) string.

Parameters:
unicode - The string to convert
Returns:
The ISO-8859-1 string or null if the convertion failed.

toHexString

public static java.lang.String toHexString(byte[] b)
Returns the hexadecimal representation of the byte array (uppercase).

Parameters:
b -
Returns:

setFilePermissions

public static boolean setFilePermissions(java.io.File file,
                                         int mode)
Sets permissions on a given file. The permissions are set using the chmod command and will only work on Unix machines. Chmod command must be in the path.

Parameters:
file - the file to set the permissions of.
mode - the Unix style permissions.
Returns:
true, if change was successful, otherwise false. It can return false, in many instances, e.g. when file does not exits, when chmod is not found, or other error occurs.