/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ISResourceBundle.java,v 1.3 2008/06/25 05:42:26 qcheng Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/**
* This class provides static utility methods to be used by console and Access
* Manager admin * CLI for storing, retrieving and deleting locale-specific
* resource bundles in the directory (data store)
* <p>
* This class is a subclass of <code> java.util.ListResourceBundle </code>. The
* method (shown below) returns an instance of ISResourceBundle, which can be
* used to obtain the key and values as any other ResourceBundle.
*
* <PRE>
*
* ResourceBundle rb = ISResourceBundle.getBundle(token, "test", "en_US");
*
* </PRE>
*/
/**
* Non-default construtor used to create a new ISResourceBundle object This
* constructor takes a Map of key-value pairs (both Strings) and uses that
* Map to construct an ISResourceBundle object
*
* @param keyValues
* Map of key-value pairs.
*/
super();
throw new NullPointerException();
}
int count = 0;
count++;
}
}
}
/**
* Returns a ResourceBundle. This method tries to find a ResourceBundle
* given locale using <code> java.util.ResourceManager </code> first. But if
* it doesn't find the ResourceBundle in the local file system, then look
* for it in the directory (data store). In the directory, it follows the
* same protocol as the default ResourceManager. It looks for the specific
* locale first (language and country) and if not found than language
* locale, and if that is not found then the default locale.
*
* @param token
* Single sign-on token of the user
* @param rbName
* Name of the ResourceBundle
* @param locale
* Specific locale of ResourceBundle
* @return ResourceBundle with the key-value pairs.
* @throws SSOException
*/
}
}
}
}
/**
* Returns a ResourceBundle. This method tries to find a ResourceBundle
* given locale using <code> java.util.ResourceManager </code> first. But if
* it doesn't find the ResourceBundle in the local file system, then look
* for it in the directory (data store). In the directory, it follows the
* same protocol as the default ResourceManager. It looks for the specific
* locale first (language and country) and if not found than language
* locale, and if that is not found then the default locale.
*
* @param token
* Single sign-on token of the user
* @param rbName
* Name of the ResourceBundle
* @param locale
* String identifying the language and country (for example:
* en_US). If this is null, then the default ResourceBundle is
* returned.
* @return ISResourceBundle
* @throws SSOException
* If user does not have read access to read the ResourceBundles
* from directory.
*/
try {
} catch (MissingResourceException me) {
}
}
/**
* Deletes the specified ResourceBundle from the directory.
*
* @param token
* Single sign-on token of user
* @param rbName
* Name of ResourceBundle
* @param locale
* String defining the locale. If null, then all the locales of
* this ResourceBundle, including the default one, are deleted.
* @throws SMSException
* If there is an error trying to modify the datastore
* @throws SSOException
* If this user's token has expired.
*/
return;
}
// Delete the entire ResourceBundle tree
try {
} catch (SMSException se) {
throw new MissingResourceException(_bundle
.getString("isResourceBundleMsg1")
.getString("isResourceBundleMsg3"));
}
} else {
// This will happen only when there is no config for
// the resource bundle provided.
throw new MissingResourceException(_bundle
.getString("isResourceBundleMsg0")
.getString("isResourceBundleMsg3"));
} else {
}
}
}
/**
* Stores or creates the ResourceBundle in the directory.
*
* @param token
* Single sign-on token of user
* @param rbName
* Name of ResourceBundle
* @param locale
* Locale of ResourceBundle. If null, the default ResourceBundle
* is updated.
* @param attributes
* Map of key-value pairs defining the ResourceBundle.
* @throws SMSException
* If there is an error trying to modify the datastore
* @throws SSOException
* If this user's token has expired.
*/
return;
}
// create a sub config
}
// store these as defaults
} else {
if (localeConfig == null) {
} else {
}
}
}
/*
* (non-Javadoc)
*
* @see java.util.ListResourceBundle#getContents()
*/
return rbArray;
}
if (tzer.hasMoreTokens()) {
} else {
language, ""));
}
} else {
}
} else {
}
}
// Since we did not find the ResourceBundle
// in the local file system, we look it up in the directory.
if (debug.messageEnabled()) {
+ " local path. looking in the directory: " + rbName);
}
try {
if (globalConfig == null) {
// throw MissingResourceException
throw new MissingResourceException("Unable to find "
+ "LocaleService",
"com.sun.identity.common.ISResourceBundle", "all");
}
// Check to see if rb subconfig exists
throw new MissingResourceException("Unable to find "
+ "ResourceBundle: " + rbName,
"com.sun.identity.common.ISResourceBundle", "all");
}
// Get the default set of key-values
return new ISResourceBundle(attrs);
} else {
}
if (localeConfig == null) {
// look for language specific RB
}
if (localeConfig == null) {
// look for generic RB
return new ISResourceBundle(attrs);
} else {
return new ISResourceBundle(attrs);
}
} catch (SMSException se) {
// log a debug exceptipn
throw new MissingResourceException(_bundle
.getString("isResourceBundleMsg0")
}
}
/*
* Converts \\uxxxx to unicode chars
*/
char c;
for (int x = 0; x < len;) {
if (c == '\\' && x < len) {
if (c == 'u') {
// Read the xxxx
int value = 0;
if (x + 4 <= len) {
for (int i = 0; i < 4; i++) {
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
break;
default:
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.");
}
}
} else {
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.\\u should be" +
" followed by atleast four hex digits ");
}
} else {
// Process the escape character
if (c == 't') {
c = '\t';
} else if (c == 'r') {
c = '\r';
} else if (c == 'n') {
c = '\n';
} else if (c == 'f') {
c = '\f';
} else {
// illegal escape character
// do not process it.append as it is
}
}
} else
}
}
}