本文整理汇总了Java中javax.security.auth.callback.LanguageCallback类的典型用法代码示例。如果您正苦于以下问题:Java LanguageCallback类的具体用法?Java LanguageCallback怎么用?Java LanguageCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageCallback类属于javax.security.auth.callback包,在下文中一共展示了LanguageCallback类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handle
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException
{
if (callbacks == null)
throw new NullPointerException();
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] == null)
continue;
if (callbacks[i] instanceof ChoiceCallback)
handleChoice((ChoiceCallback) callbacks[i]);
else if (callbacks[i] instanceof ConfirmationCallback)
handleConfirmation((ConfirmationCallback) callbacks[i]);
else if (callbacks[i] instanceof LanguageCallback)
handleLanguage((LanguageCallback) callbacks[i]);
else if (callbacks[i] instanceof NameCallback)
handleName((NameCallback) callbacks[i]);
else if (callbacks[i] instanceof PasswordCallback)
handlePassword((PasswordCallback) callbacks[i]);
else if (callbacks[i] instanceof TextInputCallback)
handleTextInput((TextInputCallback) callbacks[i]);
else if (callbacks[i] instanceof TextOutputCallback)
handleTextOutput((TextOutputCallback) callbacks[i]);
else
handleOther(callbacks[i]);
}
}
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:AbstractCallbackHandler.java
示例2: handleLanguage
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
protected void handleLanguage(LanguageCallback c) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
out.print(messages.getString("callback.language"));
String reply = null;
reply = in.readLine();
if (reply == null)
{
c.setLocale(Locale.getDefault());
}
else
{
c.setLocale(new Locale(reply.trim()));
}
}
开发者ID:vilie,项目名称:javify,代码行数:16,代码来源:ConsoleCallbackHandler.java
示例3: testLanguageCallback_01
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
/**
* test of Ctor, method set/getLocale()
*/
public final void testLanguageCallback_01() {
lc = new LanguageCallback();
Locale locale = Locale.US;
lc.setLocale(locale);
assertEquals("US", lc.getLocale().getCountry());
}
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:LanguageCallbackTest.java
示例4: testLanguageCallback_02
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
/**
* locale is null
*/
public final void testLanguageCallback_02() {
lc = new LanguageCallback();
assertNull(lc.getLocale());
try {
lc.setLocale(null);
} catch (NullPointerException e ){}
}
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:LanguageCallbackTest.java
示例5: testRoboconfCallbackHandler_failure
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
@Test( expected = UnsupportedCallbackException.class )
public void testRoboconfCallbackHandler_failure() throws Exception {
RoboconfCallbackHandler handler = new RoboconfCallbackHandler( "user", "password" );
handler.handle( new Callback[] {
new NameCallback( "Username: " ),
new PasswordCallback( "Password: ", false ),
new LanguageCallback()
});
}
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:11,代码来源:AuthenticationManagerTest.java
示例6: handleLanguage
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
protected synchronized void handleLanguage(LanguageCallback c)
{
Locale[] locales = Locale.getAvailableLocales();
String[] languages = new String[locales.length];
Locale def = Locale.getDefault();
int defind = 0;
for (int i = 0; i < locales.length; i++)
{
CPStringBuilder lang =
new CPStringBuilder(locales[i].getDisplayLanguage(locales[i]));
String country = locales[i].getDisplayCountry(locales[i]);
String variant = locales[i].getDisplayVariant(locales[i]);
if (country.length() > 0 && variant.length() > 0)
{
lang.append(" (");
lang.append(country);
lang.append(", ");
lang.append(variant);
lang.append(")");
}
else if (country.length() > 0)
{
lang.append(" (");
lang.append(country);
lang.append(")");
}
else if (variant.length() > 0)
{
lang.append(" (");
lang.append(variant);
lang.append(")");
}
languages[i] = lang.toString();
if (locales[i].equals(def))
defind = i;
}
ChoiceCallback c2 =
new ChoiceCallback(messages.getString("callback.language"), languages,
defind, false);
handleChoice(c2);
c.setLocale(def);
if (c2.getSelectedIndexes() != null && c2.getSelectedIndexes().length > 0)
{
int index = c2.getSelectedIndexes()[0];
if (index >= 0 && index < locales.length)
c.setLocale(locales[index]);
}
}
开发者ID:vilie,项目名称:javify,代码行数:49,代码来源:AWTCallbackHandler.java
示例7: handleLanguage
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
protected void handleLanguage(LanguageCallback c)
{
c.setLocale(Locale.getDefault());
}
开发者ID:vilie,项目名称:javify,代码行数:5,代码来源:DefaultCallbackHandler.java
示例8: getData
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
@Override
protected Object[] getData() {
LanguageCallback lc = new LanguageCallback();
lc.setLocale(Locale.UK);
return new Object[] { lc };
}
开发者ID:shannah,项目名称:cn1,代码行数:7,代码来源:LanguageCallbackTest.java
示例9: assertDeserialized
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
public void assertDeserialized(Serializable golden, Serializable test) {
assertTrue(test instanceof LanguageCallback);
assertEquals(((LanguageCallback) golden).getLocale(),
((LanguageCallback) test).getLocale());
}
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:LanguageCallbackTest.java
示例10: handleLanguage
import javax.security.auth.callback.LanguageCallback; //导入依赖的package包/类
/**
* Handles a {@link LanguageCallback}.
*
* @param callback The language callback.
* @throws IOException If an I/O error occurs.
*/
protected abstract void handleLanguage(LanguageCallback callback)
throws IOException;
开发者ID:vilie,项目名称:javify,代码行数:9,代码来源:AbstractCallbackHandler.java
注:本文中的javax.security.auth.callback.LanguageCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论