Hashing API's

Guys ,
Any one have any idea how i can produce a hash of a String using OIM APi's or anything else .
Thanks
Suren

When u user API, it will automatically does it.
If you want to convert String HashCode just Search Java Forum, it would be helpful.
If you want to encypt any QA value in OIM, see this
Re: password encryption/decryption

Similar Messages

  • Java API for 1-Way Hash

    Hi guys,
    Does anyone know if Java has API's to perform one-way hash transformation?
    Please, could someone let me know!
    Thank you,
    Leon

    The crypto APIs do, although you need a provider for the actual hash. Have a search through the Cryptography forum http://forum.java.sun.com/forum.jsp?forum=9

  • Using a byte[] as a secondary index's key within the Collection's API

    I am using JE 4.1.7 and its Collections API. Overall I am very satisfied with the ease of using JE within our applications. (I need to know more about maintenance, however!) My problem is that I wanted a secondary index with a byte[] key. The key contains the 16 bytes of an MD5 hash. However, while the code compiles without error when it runs JE tell me
    Exception in thread "main" java.lang.IllegalArgumentException: ONE_TO_ONE and MANY_TO_ONE keys must not have an array or Collection type: example.MyRecord.hash
    See test code below. I read the docs again and found that the only "complex" formats that are acceptable are String and BigInteger. For now I am using String instead of byte[] but I would much rather use the smaller byte[]. Is it possible to trick JE into using the byte[]? (Which we know it is using internally.)
    -- Andrew
    package example;
    import com.sleepycat.je.Environment;
    import com.sleepycat.je.EnvironmentConfig;
    import com.sleepycat.persist.EntityStore;
    import com.sleepycat.persist.PrimaryIndex;
    import com.sleepycat.persist.SecondaryIndex;
    import com.sleepycat.persist.StoreConfig;
    import com.sleepycat.persist.model.Entity;
    import com.sleepycat.persist.model.PrimaryKey;
    import com.sleepycat.persist.model.Relationship;
    import com.sleepycat.persist.model.SecondaryKey;
    import java.io.File;
    @Entity
    public class MyRecord {
    @PrimaryKey
    private long id;
    @SecondaryKey(relate = Relationship.ONE_TO_ONE, name = "byHash")
    private byte[] hash;
    public static MyRecord create(long id, byte[] hash) {
    MyRecord r = new MyRecord();
    r.id = id;
    r.hash = hash;
    return r;
    public long getId() {
    return id;
    public byte[] getHash() {
    return hash;
    public static void main( String[] args ) throws Exception {
    File directory = new File( args[0] );
    EnvironmentConfig environmentConfig = new EnvironmentConfig();
    environmentConfig.setTransactional(false);
    environmentConfig.setAllowCreate(true);
    environmentConfig.setReadOnly(false);
    StoreConfig storeConfig = new StoreConfig();
    storeConfig.setTransactional(false);
    storeConfig.setAllowCreate(true);
    storeConfig.setReadOnly(false);
    Environment environment = new Environment(directory, environmentConfig);
    EntityStore myRecordEntityStore = new EntityStore(environment, "my-record", storeConfig);
    PrimaryIndex<Long, MyRecord> idToMyRecordIndex = myRecordEntityStore.getPrimaryIndex(Long.class, MyRecord.class);
    SecondaryIndex<byte[], Long, MyRecord> hashToMyRecordIndex = myRecordEntityStore.getSecondaryIndex(idToMyRecordIndex, byte[].class, "byHash");
    // END

    We have highly variable length data that we wish to use as keys. To avoid massive index sizes and slow key lookup we are using MD5 hashes (or something more collision resistant should we need it). (Note that I am making assumptions about key size and its relation to index size that may well inaccurate.)Thanks for explaining, that makes sense.
    It would be the whole field. (I did consider using my own key data design using the @Persistent and @KeyField annotations to place the MD5 hash into two longs. I abandoned that effort because I assumed (again) that lookup with a custom key design would slower than the built-in String key implementation.)A composite key class with several long or int fields will not be slower than a single String field, and will probably result in a smaller key since the UTF-8 encoding is avoided. Since the byte array is fixed size (I didn't realize that earlier), this is the best approach.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 3DES decryption with SHA1 hashed key

    Hello all,
    I've been given the task of rewriting an existing VB application in Java, and one routine makes use of the Microsoft Cryptography API.
    The VB code decrypts a string using TripleDES decryption, using a string key that's been hashed with a SHA1 has algorithm.
    Most of the java DESede encryption/decryption examples I've worked through generate keys with a KeyGenerator instance, but I have not yet found any examples that use a key that's been SHA1 hashed.
    My attempts at using a hashed byte[] array of my key phrase with a DESede Crypto instance always return a "wrong key size" error.
    Can anyone provide some help? Example code fragments or anything would help.

    Thanks for the reply, and you're right in that this might be a more appropriate question to ask on a VB forum or on a MS cryptography API forum.
    Nevertheless, I've been able to make some headway on the VB side by getting the bytes of the SHA-1 hash map through some API calls.
    The hex representation of the SHA-1 hashed keyword:
    "3EC10CE885353DCD23B912860C2B91885CD3D6D1"
    A keyword to use as a test:
    "logins"
    Hex representation of the 3DES encrypted result of "logins" using the hashed keyword:
    "FB158A921E3C4CDB"
    Currently, my problem is with the length of the key. As you pointed out, SHA is 20 bytes, while 3DES is looking for 24 bytes. I'll experiment with your suggested 2-key approach, but here's my test code at the moment:
    import java.security.*;
    import javax.crypto.*;
    import javax.crypto.Cipher;
    import javax.crypto.Mac;
    import javax.crypto.SecretKey;
    import javax.crypto.spec.DESedeKeySpec;
    import javax.crypto.spec.SecretKeySpec;
    public class EncryptionTest {
    public static void main(String[] args) {
    String hashedKey = "3EC10CE885353DCD23B912860C2B91885CD3D6D1";
    String textToCode = "logins";
    byte[] keyBytes = hexStringToBytes( hashedKey );
    byte[] source = textToCode.getBytes();
    SecretKey key = new SecretKeySpec(keyBytes, "DESede");
    try {
    Cipher cipher = Cipher.getInstance("DESede");
    cipher.init(Cipher.ENCRYPT_MODE, key);
    byte[] result = cipher.doFinal(source);
    String sresult = hex( result );
    System.out.println( result );
    } catch ( NoSuchPaddingException e ) {
    e.printStackTrace();
    } catch ( BadPaddingException e ) { 
    e.printStackTrace();
    } catch ( NoSuchAlgorithmException e ) {
    e.printStackTrace();
    } catch ( InvalidKeyException e ) {
    e.printStackTrace();
    } catch (IllegalBlockSizeException e ) {
    e.printStackTrace();
    static byte[] hexStringToBytes( String s ) {
    int iLength = s.length();
    int iBuff = iLength / 2;
    byte[] buff = new byte[ iBuff ];
    int j = 0;
    for(int i = 0; i < iLength; i+=2) {
    try {
    String s1 = s.substring(i, i+2);
    buff[j++] = (byte) Integer.parseInt(s1, 16);
    } catch ( Exception e ) {
    e.printStackTrace();
    return buff;
    static String hex(byte[] data) {
    StringBuilder sb = new StringBuilder();
    for (byte b : data) {
    sb.append(Character.forDigit((b & 240) >> 4, 16));
    sb.append(Character.forDigit((b & 15), 16));
    return sb.toString();
    }

  • How to set the return language? i read the api already

    import java.io.*;
    import java.util.*;
    class Listing_Available_Locales
         public static void main(String args[])   
             Locale[] locales = Locale.ENGLISH(); //error is here
                             //Locale[] locales = Locale.getAvailableLocales(); //this line no error
             for (int i=0; i<locales.length; i++) {
                 // Get the 2-letter language code
                 String language = locales.getLanguage();
         // Get the 2-letter country code; may be equal to ""
         String country = locales[i].getCountry();
         // Get localized name suitable for display to the user
         String locName = locales[i].getDisplayName();
         System.out.println(language+" "+country+" "+locName);
    local api is like below
    java.util
    Class Locale
    java.lang.Object
    java.util.Locale
    All Implemented Interfaces:
    Cloneable, Serializable
    public final class Locale
    extends Object
    implements Cloneable, Serializable
    A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation--the number should be formatted according to the customs/conventions of the user's native country, region, or culture.
    Create a Locale object using the constructors in this class:
    Locale(String language)
    Locale(String language, String country)
    Locale(String language, String country, String variant)
    The language argument is a valid ISO Language Code. These codes are the lower-case, two-letter codes as defined by ISO-639. You can find a full list of these codes at a number of sites, such as:
    http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
    The country argument is a valid ISO Country Code. These codes are the upper-case, two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as:
    http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
    The variant argument is a vendor or browser-specific code. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might construct a locale with parameters for language, country and variant as: "es", "ES", "Traditional_WIN".
    Because a Locale object is just an identifier for a region, no validity check is performed when you construct a Locale. If you want to see whether particular resources are available for the Locale you construct, you must query those resources. For example, ask the NumberFormat for the locales it supports using its getAvailableLocales method.
    Note: When you ask for a resource for a particular locale, you get back the best available match, not necessarily precisely what you asked for. For more information, look at ResourceBundle.
    The Locale class provides a number of convenient constants that you can use to create Locale objects for commonly used locales. For example, the following creates a Locale object for the United States:
    Locale.US
    Once you've created a Locale you can query it for information about itself. Use getCountry to get the ISO Country Code and getLanguage to get the ISO Language Code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. Interestingly, the getDisplayXXX methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as an argument.
    The Java 2 platform provides a number of classes that perform locale-sensitive operations. For example, the NumberFormat class formats numbers, currency, or percentages in a locale-sensitive manner. Classes such as NumberFormat have a number of convenience methods for creating a default object of that type. For example, the NumberFormat class provides these three convenience methods for creating a default NumberFormat object:
    NumberFormat.getInstance()
    NumberFormat.getCurrencyInstance()
    NumberFormat.getPercentInstance()
    These methods have two variants; one with an explicit locale and one without; the latter using the default locale.
    NumberFormat.getInstance(myLocale)
    NumberFormat.getCurrencyInstance(myLocale)
    NumberFormat.getPercentInstance(myLocale)
    A Locale is the mechanism for identifying the kind of object (NumberFormat) that you would like to get. The locale is just a mechanism for identifying objects, not a container for the objects themselves.
    Each class that performs locale-sensitive operations allows you to get all the available objects of that type. You can sift through these objects by language, country, or variant, and use the display names to present a menu to the user. For example, you can create a menu of all the collation objects suitable for a given language. Such classes must implement these three class methods:
    public static Locale[] getAvailableLocales()
    public static String getDisplayName(Locale objectLocale,
    Locale displayLocale)
    public static final String getDisplayName(Locale objectLocale)
    // getDisplayName will throw MissingResourceException if the locale
    // is not one of the available locales.
    Since:
    1.1
    See Also:
    ResourceBundle, Format, NumberFormat, Collator, Serialized Form
    Field Summary
    static Locale CANADA
    Useful constant for country.
    static Locale CANADA_FRENCH
    Useful constant for country.
    static Locale CHINA
    Useful constant for country.
    static Locale CHINESE
    Useful constant for language.
    static Locale ENGLISH
    Useful constant for language.
    static Locale FRANCE
    Useful constant for country.
    static Locale FRENCH
    Useful constant for language.
    static Locale GERMAN
    Useful constant for language.
    static Locale GERMANY
    Useful constant for country.
    static Locale ITALIAN
    Useful constant for language.
    static Locale ITALY
    Useful constant for country.
    static Locale JAPAN
    Useful constant for country.
    static Locale JAPANESE
    Useful constant for language.
    static Locale KOREA
    Useful constant for country.
    static Locale KOREAN
    Useful constant for language.
    static Locale PRC
    Useful constant for country.
    static Locale SIMPLIFIED_CHINESE
    Useful constant for language.
    static Locale TAIWAN
    Useful constant for country.
    static Locale TRADITIONAL_CHINESE
    Useful constant for language.
    static Locale UK
    Useful constant for country.
    static Locale US
    Useful constant for country.
    Constructor Summary
    Locale(String language)
    Construct a locale from a language code.
    Locale(String language, String country)
    Construct a locale from language, country.
    Locale(String language, String country, String variant)
    Construct a locale from language, country, variant.
    Method Summary
    Object clone()
    Overrides Cloneable
    boolean equals(Object obj)
    Returns true if this Locale is equal to another object.
    static Locale[] getAvailableLocales()
    Returns a list of all installed locales.
    String getCountry()
    Returns the country/region code for this locale, which will either be the empty string or an upercase ISO 3166 2-letter code.
    static Locale getDefault()
    Gets the current value of the default locale for this instance of the Java Virtual Machine.
    String getDisplayCountry()
    Returns a name for the locale's country that is appropriate for display to the user.
    String getDisplayCountry(Locale inLocale)
    Returns a name for the locale's country that is appropriate for display to the user.
    String getDisplayLanguage()
    Returns a name for the locale's language that is appropriate for display to the user.
    String getDisplayLanguage(Locale inLocale)
    Returns a name for the locale's language that is appropriate for display to the user.
    String getDisplayName()
    Returns a name for the locale that is appropriate for display to the user.
    String getDisplayName(Locale inLocale)
    Returns a name for the locale that is appropriate for display to the user.
    String getDisplayVariant()
    Returns a name for the locale's variant code that is appropriate for display to the user.
    String getDisplayVariant(Locale inLocale)
    Returns a name for the locale's variant code that is appropriate for display to the user.
    String getISO3Country()
    Returns a three-letter abbreviation for this locale's country.
    String getISO3Language()
    Returns a three-letter abbreviation for this locale's language.
    static String[] getISOCountries()
    Returns a list of all 2-letter country codes defined in ISO 3166.
    static String[] getISOLanguages()
    Returns a list of all 2-letter language codes defined in ISO 639.
    String getLanguage()
    Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
    String getVariant()
    Returns the variant code for this locale.
    int hashCode()
    Override hashCode.
    static void setDefault(Locale newLocale)
    Sets the default locale for this instance of the Java Virtual Machine.
    String toString()
    Getter for the programmatic name of the entire locale, with the language, country and variant separated by underbars.
    Methods inherited from class java.lang.Object
    finalize, getClass, notify, notifyAll, wait, wait, wait
    Field Detail
    ENGLISH
    public static final Locale ENGLISHUseful constant for language.
    FRENCH
    public static final Locale FRENCHUseful constant for language.
    GERMAN
    public static final Locale GERMANUseful constant for language.
    ITALIAN
    public static final Locale ITALIANUseful constant for language.
    JAPANESE
    public static final Locale JAPANESEUseful constant for language.
    KOREAN
    public static final Locale KOREANUseful constant for language.
    CHINESE
    public static final Locale CHINESEUseful constant for language.
    SIMPLIFIED_CHINESE
    public static final Locale SIMPLIFIED_CHINESEUseful constant for language.
    TRADITIONAL_CHINESE
    public static final Locale TRADITIONAL_CHINESEUseful constant for language.
    FRANCE
    public static final Locale FRANCEUseful constant for country.
    GERMANY
    public static final Locale GERMANYUseful constant for country.
    ITALY
    public static final Locale ITALYUseful constant for country.
    JAPAN
    public static final Locale JAPANUseful constant for country.
    KOREA
    public static final Locale KOREAUseful constant for country.
    CHINA
    public static final Locale CHINAUseful constant for country.
    PRC
    public static final Locale PRCUseful constant for country.
    TAIWAN
    public static final Locale TAIWANUseful constant for country.
    UK
    public static final Locale UKUseful constant for country.
    US
    public static final Locale USUseful constant for country.
    CANADA
    public static final Locale CANADAUseful constant for country.
    CANADA_FRENCH
    public static final Locale CANADA_FRENCHUseful constant for country.
    Constructor Detail
    Locale
    public Locale(String language,
    String country,
    String variant)Construct a locale from language, country, variant. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.
    Parameters:
    language - lowercase two-letter ISO-639 code.
    country - uppercase two-letter ISO-3166 code.
    variant - vendor and browser specific code. See class description.
    Throws:
    NullPointerException - thrown if any argument is null.
    Locale
    public Locale(String language,
    String country)Construct a locale from language, country. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.
    Parameters:
    language - lowercase two-letter ISO-639 code.
    country - uppercase two-letter ISO-3166 code.
    Throws:
    NullPointerException - thrown if either argument is null.
    Locale
    public Locale(String language)Construct a locale from a language code. NOTE: ISO 639 is not a stable standard; some of the language codes it defines (specifically iw, ji, and in) have changed. This constructor accepts both the old codes (iw, ji, and in) and the new codes (he, yi, and id), but all other API on Locale will return only the OLD codes.
    Parameters:
    language - lowercase two-letter ISO-639 code.
    Throws:
    NullPointerException - thrown if argument is null.
    Since:
    1.4
    Method Detail
    getDefault
    public static Locale getDefault()Gets the current value of the default locale for this instance of the Java Virtual Machine.
    The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified. It can be changed using the setDefault method.
    Returns:
    the default locale for this instance of the Java Virtual Machine
    setDefault
    public static void setDefault(Locale newLocale)Sets the default locale for this instance of the Java Virtual Machine. This does not affect the host locale.
    If there is a security manager, its checkPermission method is called with a PropertyPermission("user.language", "write") permission before the default locale is changed.
    The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified.
    Since changing the default locale may affect many different areas of functionality, this method should only be used if the caller is prepared to reinitialize locale-sensitive code running within the same Java Virtual Machine, such as the user interface.
    Parameters:
    newLocale - the new default locale
    Throws:
    SecurityException - if a security manager exists and its checkPermission method doesn't allow the operation.
    NullPointerException - if newLocale is null
    See Also:
    SecurityManager.checkPermission(java.security.Permission), PropertyPermission
    getAvailableLocales
    public static Locale[] getAvailableLocales()Returns a list of all installed locales.
    getISOCountries
    public static String[] getISOCountries()Returns a list of all 2-letter country codes defined in ISO 3166. Can be used to create Locales.
    getISOLanguages
    public static String[] getISOLanguages()Returns a list of all 2-letter language codes defined in ISO 639. Can be used to create Locales. [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.]
    getLanguage
    public String getLanguage()Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.
    NOTE: ISO 639 is not a stable standard-- some languages' codes have changed. Locale's constructor recognizes both the new and the old codes for the languages whose codes have changed, but this function always returns the old code. If you want to check for a specific language whose code has changed, don't do
    if (locale.getLanguage().equals("he")
    Instead, do
    if (locale.getLanguage().equals(new Locale("he", "", "").getLanguage())
    See Also:
    getDisplayLanguage()
    getCountry
    public String getCountry()Returns the country/region code for this locale, which will either be the empty string or an upercase ISO 3166 2-letter code.
    See Also:
    getDisplayCountry()
    getVariant
    public String getVariant()Returns the variant code for this locale.
    See Also:
    getDisplayVariant()
    toString
    public final String toString()Getter for the programmatic name of the entire locale, with the language, country and variant separated by underbars. Language is always lower case, and country is always upper case. If the language is missing, the string will begin with an underbar. If both the language and country fields are missing, this function will return the empty string, even if the variant field is filled in (you can't have a locale with just a variant-- the variant must accompany a valid language or country code). Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"
    Overrides:
    toString in class Object
    Returns:
    a string representation of the object.
    See Also:
    getDisplayName()
    getISO3Language
    public String getISO3Language()
    throws MissingResourceExceptionReturns a three-letter abbreviation for this locale's language. If the locale doesn't specify a language, this will be the empty string. Otherwise, this will be a lowercase ISO 639-2/T language code. The ISO 639-2 language codes can be found on-line at ftp://dkuug.dk/i18n/iso-639-2.txt
    Throws:
    MissingResourceException - Throws MissingResourceException if the three-letter language abbreviation is not available for this locale.
    getISO3Country
    public String getISO3Country()
    throws MissingResourceExceptionReturns a three-letter abbreviation for this locale's country. If the locale doesn't specify a country, this will be tbe the empty string. Otherwise, this will be an uppercase ISO 3166 3-letter country code.
    Throws:
    MissingResourceException - Throws MissingResourceException if the three-letter country abbreviation is not available for this locale.
    getDisplayLanguage
    public final String getDisplayLanguage()Returns a name for the locale's language that is appropriate for display to the user. If possible, the name returned will be localized for the default locale. For example, if the locale is fr_FR and the default locale is en_US, getDisplayLanguage() will return "French"; if the locale is en_US and the default locale is fr_FR, getDisplayLanguage() will return "anglais". If the name returned cannot be localized for the default locale, (say, we don't have a Japanese name for Croatian), this function falls back on the English name, and uses the ISO code as a last-resort value. If the locale doesn't specify a language, this function returns the empty string.
    getDisplayLanguage
    public String getDisplayLanguage(Locale inLocale)Returns a name for the locale's language that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayLanguage() will return "French"; if the locale is en_US and inLocale is fr_FR, getDisplayLanguage() will return "anglais". If the name returned cannot be localized according to inLocale, (say, we don't have a Japanese name for Croatian), this function falls back on the default locale, on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a language, this function returns the empty string.
    getDisplayCountry
    public final String getDisplayCountry()Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized for the default locale. For example, if the locale is fr_FR and the default locale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and the default locale is fr_FR, getDisplayLanguage() will return "Etats-Unis". If the name returned cannot be localized for the default locale, (say, we don't have a Japanese name for Croatia), this function falls back on the English name, and uses the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.
    getDisplayCountry
    public String getDisplayCountry(Locale inLocale)Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and inLocale is fr_FR, getDisplayLanguage() will return "Etats-Unis". If the name returned cannot be localized according to inLocale. (say, we don't have a Japanese name for Croatia), this function falls back on the default locale, on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.
    getDisplayVariant
    public final String getDisplayVariant()Returns a name for the locale's variant code that is appropriate for display to the user. If possible, the name will be localized for the default locale. If the locale doesn't specify a variant code, this function returns the empty string.
    getDisplayVariant
    public String getDisplayVariant(Locale inLocale)Returns a name for the locale's variant code that is appropriate for display to the user. If possible, the name will be localized for inLocale. If the locale doesn't specify a variant code, this function returns the empty string.
    getDisplayName
    public final String getDisplayName()Returns a name for the locale that is appropriate for display to the user. This will be the values returned by getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. The display name will have one of the following forms:
    language (country, variant)
    language (country)
    language (variant)
    country (variant)
    language
    country
    variant
    depending on which fields are specified in the locale. If the language, country, and variant fields are all empty, this function returns the empty string.
    getDisplayName
    public String getDisplayName(Locale inLocale)Returns a name for the locale that is appropriate for display to the user. This will be the values returned by getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. The display name will have one of the following forms:
    language (country, variant)
    language (country)
    language (variant)
    country (variant)
    language
    country
    variant
    depending on which fields are specified in the locale. If the language, country, and variant fields are all empty, this function returns the empty string.
    clone
    public Object clone()Overrides Cloneable
    Overrides:
    clone in class Object
    Returns:
    a clone of this instance.
    See Also:
    Cloneable
    hashCode
    public int hashCode()Override hashCode. Since Locales are often used in hashtables, caches the value for speed.
    Overrides:
    hashCode in class Object
    Returns:
    a hash code value for this object.
    See Also:
    Object.equals(java.lang.Object), Hashtable
    equals
    public boolean equals(Object obj)Returns true if this Locale is equal to another object. A Locale is deemed equal to another Locale with identical language, country, and variant, and unequal to all other objects.
    Overrides:
    equals in class Object
    Parameters:
    obj - the reference object with which to compare.
    Returns:
    true if this Locale is equal to the specified object.
    See Also:
    Object.hashCode(), Hashtable
    Overview Package Class Use Tree Deprecated Index Help
    JavaTM 2 Platform
    Std. Ed. v1.4.2
    PREV CLASS NEXT CLASS FRAMES NO FRAMES
    SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
    Submit a bug or feature
    For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

    Was it really necessary to post the whole API description?!?
    Locale[] locales = Locale.ENGLISH();ENGLISH is not a method in class Locale, so do not add the braces "( );".
    Also, the constant ENGLISH is not an array, but just a single Locale object.
    You didn't say what your problem was. What do you want to achieve with your program and what is it that you don't understand?

  • Assigning users to role using Security API

    Hi,
    I am trying to assign portal users to portal role using the IRoleFactory and IRole class of Secutiy API from my web dynpro application.
    For getting the role , i can use either the uniqueId of the role or the uniqueName of the role.(Using methods of IRole class, getRole(uid) or getRoleByUniqueName(uname)).
    The UniqueId of roles contains some hash values and cannot be used. For example ROLE.PCD_ROLE_PERSISTENCE.6dT95vZpyNWQHm59z7B9FxAM/fg=.
    And the for getting the role using the uniqueName, i need to give like pcd:portal_content/other_vendors/<folder name>/<my prefix>.<rolename>. Which is also not feasible.
    Is there any way to get the role only using the role name that we give while creating it?
    Thanks and Regards,
    Venkat

    Hi,
         Check if this helps.
    try  {
         IRoleFactory rfact = UMFactory.getRoleFactory();
         IRoleSearchFilter isf = rfact.getRoleSearchFilter();
         isf.setDisplayName ("*",ISearchAttribute.LIKE_OPERATOR,false);
         ISearchResult rit = rfact.searchRoles(isf);
         while(rit.next()!=null){
             String roleName = (String) rit.next();
             IRole role = rfact.getRole(roleName);
             response.write("nRole:" + role.getUniqueName());
      }catch(Exception e){
           response.write("exception");
    U will get list of roles. U can pass these directly or use String tokenizer to separate the role name alone using '.' as separator.
    Regards,
    Vijai

  • Help needed in calculating hash code for a linked list??

    I have reffered API documentation for the list interface...There i found the code below for the hashcode() method ...I couldn't get why "31" is used as a multiplicative factor?
           int hashCode = 1;
           Iterator<E> i = list.iterator();
           while (i.hasNext()) {
               E obj = i.next();
               hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
           }I'm a beginner....please help me out..

    Because it's a prime number, I think. You'll probably want to find an article or decent book on creating optimal hash functions.

  • Is it possible to change the hash algorithm when I renew the Root CA

    My Root CA is installed on a Windows Server 2008. The Hash algorithm of Root CA in my environment is MD5. I would like to renew the Root CA and change the Hash algorithm to SHA1. Is it possible to change it?
    Regards,
    Terry | My Blog: http://terrytlslau.tls1.cc

    Hi,
    The hashing
    algorithm chosen during the setup of a Certificate Authority determines how the certificates that the CA issues are digitally signed. It is a one
    algorithm per CA scenario, so if your environment requires multiple algorithms for compatibility, then you will need multiple PKI hierarchies (one for each
    algorithm.) Prior to Windows 2008, you had to rebuild the CA and decommision the entire PKI hierarchy to
    change the signing algorithm used. In Windows 2008 and 2008 R2, we allow you to
    change the algorithm and from that point forward it will digitally sign all new certificates with the updated
    algorithm.
    The
    Certificate
    Services Enhancements in Longhorn Server Whitepaper describing these steps can be found under the section
    Configuring the Cryptographic Algorithms used by the CA.
    Step 1: Verify the configuration of the CRL and AIA paths. Sometimes users will manually
    change these paths to not include the crl name suffix variable that distinguish multiple certificates on a CA. This is important because the process of changing the
    algorithm requires the renewal of the private key and results in administration of multiple CA certificates. When we publish multiple crt and crls, they will be identified as CAName and CAName(1.) You can verify these paths
    include the variables by checking the registry keys below:
    [HKLM\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\{CAname}
    CRLPublicationURLs = "1:%WINDIR%\system32\CertSrv\CertEnroll\%%3%%8%%9.crl\n2:http://FCCA01.fourthcoffee.com/certenroll/%%3%%8%%9.crl\n10:ldap:///CN=%%7%%8,CN=%%2,CN=CDP,CN=Public
    Key Services,CN=Services,%%6%%10"
    CACertPublicationURLs = "1:%WINDIR%\system32\CertSrv\CertEnroll\%%1_%%3%%4.crt\n2:http://FCCA01.fourthcoffee.com/certenroll/%%1_%%3%%4.crt\n2:ldap:///CN=%%7,CN=AIA,CN=Public Key Services,CN=Services,%%6%%11"
    Step 2: Modify the CSP parameters to specify the new
    algorithm. The CSP may use the original CryptoAPI or Cryptography API:Next Generation - you can verify this by looking in the registry key
    HKLM\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\{CAname}\CSP.
    If you have the regvalues
    CNGPublicKeyAlgorithm and CNGHashAlgorithm then your CSP is using Next Generation.
    Change the
    algorithm from MD5 to SHA1 and was using Cryptography API: Next Generation. The original registry value was:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CertSvc\Configuration\{CAname}\CSP]
    "ProviderType"=dword:00000000
    "Provider"="Microsoft Software Key Storage Provider"
    "HashAlgorithm"=dword:00008003
    "CNGPublicKeyAlgorithm"="RSA"
    "CNGHashAlgorithm"="MD5"
    "MachineKeyset"=dword:00000001
    we changed it to
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CertSvc\Configuration\{CAname}\CSP]
    "ProviderType"=dword:00000000
    "Provider"="Microsoft Software Key Storage Provider"
    "HashAlgorithm"=dword:00008004
    "CNGPublicKeyAlgorithm"="RSA"
    "CNGHashAlgorithm"="SHA1"
    "MachineKeyset"=dword:00000001
    Step 3: Restart the CA service. You can do this in the CA MMC. Right Click on the
    CA and choose "Stop Service" and "Start Service".
    Step 4: Renew the CA certificate with new Private Key. Right click on the CA and
    choose "Renew CA certificate". Choose to renew the public and private key pair. On completion, this will result in the CA having two certificates. You will see that the old one has the MD5 for the Signature
    Hash Algorithm and that the new certificate uses SHA1.
    Hope this helps!
    Best Regards
    Elytis Cheng
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Elytis Cheng
    TechNet Community Support

  • Using JHS tables and hashing with salt algorithms for Weblogic security

    We are going to do our first enterprise ADF/JHeadstart application. For security part, we are going to do the following:
    1. We will use JHS tables as authentication for ADF security.
    2. We will use JAAS as authentication and Custom as authorization.
    2. We need to use JHeadStart security service screen in our application to manage users, roles and permission, instead of doing users/groups management within Weblogic.
    3. We will create new Weblogic SQL Authentication Provider.
    4. We will store salt with password in the database table.
    5. We will use Oracle MDS.
    There are some blogs online giving detail steps on how to create Weblogic SQL Authentication Provider and use JHS tables as authentication for ADF security. I am not sure about the implementation of hashing with salt algorithms, as ideally we'd like to use JHS security service screen in the application to manage users, roles and permission, not using Weblogic to do the users/groups management. We are going to try JMX client to interact with Weblogic API, looks like it is a flexiable approach. Does anybody have experience on working with JMX, SQL Authentication Provider and hashing with salt algorithms? Just want to make sure we are on the right track.
    Thanks,
    Sarah

    To be clear, we are planning on using a JMX client at the Entity level using custom JHS entitiy classes.
    BradW working with Sarah

  • User enrolled via API does not appear to be enrolled within Connect

    Posting this here because it appears I have stumped the band over at connectusers.com...
    Using the API to access our hosted account I am able to:
    Login as a user (administrator or normal user)
    Add a user
    Change user password
    List all of the SCOs that the user has access to
    List the response to the report-my-training action
    I am attempting to enroll a user by calling permission-update. It appears to work because the status returned is "ok". When I connect to the API as the user and call report-my-training the curriculum appears in the response. So far, so good.
    Next, I accessed Adobe Connect via a web browser and logged in as the user. The curriculum I thought I enrolled the user in appears in the training catalog. The first sign of trouble is that the enrollment status is reported as "You are currently not enrolled."
    If I direct the user to the curriculum using a URL like "http://hosted-account.acrobat.com/p31959044/?session=na1breezyxxxxxxxxxxxxxxx" the browser is redirected to a page that shows the title of the curriculum, but nothing more (blank white page).
    What am I missing or doing wrong?

    Thank you for your reply Loren.  Unfortunately I don't currently have access to the remote side's crypto configuration, since they are an external entity.  However, I can check in and see if I can get that info.
    Hopefully this is the information that you requested:
    access-list Outside_27_cryptomap extended permit tcp object 20.0.0.106 object Remote_Server object-group RemoteSite
    Result of the command: "sh access-list Outside_27_cryptomap"
    access-list Outside_27_cryptomap; 1 elements; name hash: 0x3a48e673
    access-list Outside_27_cryptomap line 1 extended permit tcp object 20.0.0.106 object Remote_Server object-group RemoteSite (hitcnt=36) 0xce74f220
      access-list Outside_27_cryptomap line 1 extended permit tcp host 20.0.0.106 host 188.1.1.69 eq 204 (hitcnt=36) 0xdd218de0
    Again, thank you for your help.

  • URGENT - Sorting Hash Tables

    I am using a hash table with 2 columns. The first one has strings and is the key. The second column has integers.
    I need to sort this table on the first column and print the contents of the table.
    Then i need to sort it on the second column and print the results.
    How do i sort the hastables.
    Please let me know as soon as possible.
    Thanks and Regards,
    Vijay

    You got it all wrong. Hashtables cannot be sorted because then it would not be a hashtable. The content of the Hashtable can be sorted.
    What you want to do is get the key Set (keySet() method) of the Hashtable, wrap it in a List (e.g. LinkedList), sort that (see java.util.Collections for sorting) and then print out the contents of the Hashtable in the order pointed out by the keys in the sorted List.
    Then you can do the same for the values() Collection of the Hashtable.
    Pointers:
    http://java.sun.com/j2se/1.4/docs/api/java/util/Hashtable.html
    http://java.sun.com/j2se/1.4/docs/api/java/util/Set.html
    http://java.sun.com/j2se/1.4/docs/api/java/util/List.html
    http://java.sun.com/j2se/1.4/docs/api/java/util/LinkedList.html
    http://java.sun.com/j2se/1.4/docs/api/java/util/Collections.html

  • I need know API to get password

    Hi,
    I have a procedure to login public users to portal users like
    PORTAL30.wwptl_login.login_url('user','PASSWORD','','url','');
    but in this procedure I needed put the password hard-coded and when I need to change the user password I will have to change the procedure.
    Somebody know a API to capture the password's user and pass this like parameter?
    Thanks

    Gloria,
    Passwords are one-way hashed you cannot get them back in clear text.
    Could you explain what you are trying to achieve?

  • Not able to update Start/End Date with updateUser API

    Hello all,
    I am trying to update start and end date using the updateUser API, but the dates are not being set. I know the updateUser call works since I tested by changing the user's first name and it worked fine (verified through OIM web app). Below is the code that I am using to update as well as the sample values I am using. No exceptions are thrown either. I am clueless of what the problem can be. Also, one of my client's request is to also display the time of when those values where updated (through a custom web app that I am building). Is that posible? Before I was getting the time on where the call to userUpdate was made and appending that to the values I was setting in the hash table, but started using 0s for the time since that's what I read on a thread on this forum (Re: (OIM) Timestamp format must be yyyy-mm-dd.....
    Sample Values
    startDate = 2010-11-08
    endDate = 2010-12-09
    String startDateStr = startDate.toString() + " 00:00:00.000";
    String endDateStr = endDate.toString() + " 00:00:00.000";
    printout of the above strings
    startDateStr = 2010-11-08 00:00:00.000
    endDateStr = 2010-12-09 00:00:00.000
    Hashtable<String,String> attrValues = new Hashtable<String,String>();
    attrValues.put("Users.Start Date", activateDateStr);
    attrValues.put("Users.End Date", inactivateDateStr);
    usrOps.updateUser(rsUser, attrValues);
    Please help me out I've been stuck on this issue for too long now.
    Thank you!
    -I
    Edited by: cri_cri_99 on Jun 23, 2009 12:46 PM

    It is working fine for me.
    Map strDate = new HashMap();
    strDate.put("Users.Start Date", "*2009-06-24 12:01:56.000000000*");
    moUserUtility.updateUser(userResultSet, strDate);
    It will show you in DB as *24-JUN-09*. I don't understand what you are asking more in your thread.
    But updateUser API is working with this format. If you are getting time from some application, convert it to this format and run.
    If you need any help, let me know.
    Edited by: Dost

  • What is the hash code?

    What is the hash code of an object? What does hash code mean?

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Obje
    ct.html#hashCode()also http://en.wikipedia.org/wiki/Hash_code
    what the hashcode isn't, though, is an identifier for an object, unique or otherwise. don't make that mistake!
    "Database Systems" by Connolly-Begg has a good section on hash codes and their uses, if memory serves me well

  • Hash marks in Regular Expressions

    Given this example code, what do you expect as output?import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class HashTest
       * @param args
      public static void main(String[] args)
        String testChar = "#";
        String testInput = "this string is # split by a hash";
        String[] stringArray = testInput.split( testChar );
        for (String s : stringArray)
          System.out.println( s );
        Pattern p = Pattern.compile( testChar );
        Matcher m = p.matcher( testInput );
        if ( m.lookingAt() )
          System.out.println( m.groupCount() );
        p = Pattern.compile( "(#)(.*)" );
        m = p.matcher( testInput );
        if ( m.lookingAt() )
          for (int i = 0; i <= m.groupCount(); i++)
            System.out.println( m.group( i ) );
    }The output I get is
    this string is
    split by a hash
    replacing the last pattern with
    p = Pattern.compile( "(.*?)(#)(.*)" );I get
    this string is
    split by a hash
    this string is # split by a hash
    this string is
    split by a hash
    This is very unexpected behavior and if anyone could come up with a convincing solution, I'd appreciate it.

    As for matches(), I think it was because they were also adding regex-related wrapper methods to String. Part of the contract for the find() method is that, if you call it multiple times without resetting the matcher, each match attempt will start searching at the position where the last match ended. But that wouldn't work in String, because there was no way to ensure that the variable it's being called on this time still refers the same string it referred to the last time. So, if it can only be meaninfully called once anyway, they might as well have it match the whole string. That's my guess.
    I can't even guess what they were thinking about with lookingAt(). I found it perfectly useless until JDK 1.5, when they added the "regions" API and the usePattern(Pattern) method to Matcher. Now it's useful for scanning text with multiple regexes, which is how they use it in java.util.Scanner, and how I use it in my syntax-highlighting editor. Before, I had to prepend "\G" to every regex and, for each match attempt, create a new Matcher and call its find(int) method--yech!.

Maybe you are looking for