当前位置: 首页>>代码示例>>Java>>正文


Java TextOutputCallback类代码示例

本文整理汇总了Java中javax.security.auth.callback.TextOutputCallback的典型用法代码示例。如果您正苦于以下问题:Java TextOutputCallback类的具体用法?Java TextOutputCallback怎么用?Java TextOutputCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextOutputCallback类属于javax.security.auth.callback包,在下文中一共展示了TextOutputCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException,
		UnsupportedCallbackException {
	
	for (Callback callback : callbacks) {
		if (callback instanceof TextOutputCallback) {
			 TextOutputCallback tc = (TextOutputCallback) callback;
			 switch (tc.getMessageType()) {
			 	case TextOutputCallback.INFORMATION: logger.info(tc.getMessage()); break;
			 	case TextOutputCallback.ERROR: logger.error(tc.getMessage()); break;
			 	case TextOutputCallback.WARNING: logger.warn(tc.getMessage()); break;
			 }
		} else if (callback instanceof NameCallback) {
			NameCallback nc = (NameCallback) callback;
			nc.setName(upn);
		} else if (callback instanceof PasswordCallback) {
			PasswordCallback pc = (PasswordCallback) callback;
			pc.setPassword(this.password.toCharArray());
		}
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:23,代码来源:UpnPwdCallbackHandler.java

示例2: addLoginCallbackMessage

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
private void addLoginCallbackMessage(Callback[] callbacks)
throws UnsupportedCallbackException
{
    int i = 0;
    try {
        for (i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                handleTextOutputCallback((TextOutputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof NameCallback) {
                handleNameCallback((NameCallback)callbacks[i]);
            } else if (callbacks[i] instanceof PasswordCallback) {
                handlePasswordCallback((PasswordCallback)callbacks[i]);
            } else if (callbacks[i] instanceof TextInputCallback) {
                handleTextInputCallback((TextInputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof ChoiceCallback) {
                handleChoiceCallback((ChoiceCallback)callbacks[i]);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new UnsupportedCallbackException(callbacks[i],e.getMessage());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:24,代码来源:LoginTest.java

示例3: handleTextOutputCallback

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
private void handleTextOutputCallback(TextOutputCallback toc) {
    debugMessage("Got TextOutputCallback");
    // display the message according to the specified type

    switch (toc.getMessageType()) {
        case TextOutputCallback.INFORMATION:
            debugMessage(toc.getMessage());
            break;
        case TextOutputCallback.ERROR:
            debugMessage("ERROR: " + toc.getMessage());
            break;
        case TextOutputCallback.WARNING:
            debugMessage("WARNING: " + toc.getMessage());
            break;
        default:
            debugMessage("Unsupported message type: " +
                toc.getMessageType());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:20,代码来源:LoginTest.java

示例4: addLoginCallbackMessage

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
private void addLoginCallbackMessage(Callback[] callbacks)
throws UnsupportedCallbackException {
    int i = 0;
    try {
        for (i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                handleTextOutputCallback((TextOutputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof NameCallback) {
                handleNameCallback((NameCallback)callbacks[i]);
            } else if (callbacks[i] instanceof PasswordCallback) {
                handlePasswordCallback((PasswordCallback)callbacks[i]);
            } else if (callbacks[i] instanceof TextInputCallback) {
                handleTextInputCallback((TextInputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof ChoiceCallback) {
                handleChoiceCallback((ChoiceCallback)callbacks[i]);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new UnsupportedCallbackException(callbacks[i],e.getMessage());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:23,代码来源:FailedLoginTest.java

示例5: processCallback

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
protected void processCallback(Callback callback) throws IOException, UnsupportedCallbackException
{
  if (callback instanceof NameCallback) {
    NameCallback namecb = (NameCallback)callback;
    namecb.setName(context.getValue(SecurityContext.USER_NAME));
  } else if (callback instanceof PasswordCallback) {
    PasswordCallback passcb = (PasswordCallback)callback;
    passcb.setPassword(context.getValue(SecurityContext.PASSWORD));
  } else if (callback instanceof RealmCallback) {
    RealmCallback realmcb = (RealmCallback)callback;
    realmcb.setText(context.getValue(SecurityContext.REALM));
  } else if (callback instanceof TextOutputCallback) {
    TextOutputCallback textcb = (TextOutputCallback)callback;
    if (textcb.getMessageType() == TextOutputCallback.INFORMATION) {
      logger.info(textcb.getMessage());
    } else if (textcb.getMessageType() == TextOutputCallback.WARNING) {
      logger.warn(textcb.getMessage());
    } else if (textcb.getMessageType() == TextOutputCallback.ERROR) {
      logger.error(textcb.getMessage());
    } else {
      logger.debug("Auth message type {}, message {}", textcb.getMessageType(), textcb.getMessage());
    }
  } else {
    throw new UnsupportedCallbackException(callback);
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:27,代码来源:DefaultCallbackHandler.java

示例6: handle

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
    UnsupportedCallbackException {
  for (Callback cb : callbacks) {
    if (cb instanceof TextOutputCallback) {
      // TODO: Implement this
      throw new UnsupportedCallbackException(cb);
    } else if (cb instanceof NameCallback) {
      NameCallback nc = (NameCallback) cb;
      nc.setName(username);
    } else if (cb instanceof PasswordCallback) {
      PasswordCallback pc = (PasswordCallback) cb;
      pc.setPassword(password);
    } else {
      throw new UnsupportedCallbackException(cb);
    }
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:18,代码来源:PlainCallbackHandler.java

示例7: handle

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
@Override
   public void handle(Callback[] callbacks)
     throws IOException, UnsupportedCallbackException {
   
     for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
         // prompt the user for a username
         NameCallback nc = (NameCallback)callbacks[i];
  String username = tokens[index++];
         nc.setName(username);

       } else if (callbacks[i] instanceof PasswordCallback) {      
         // prompt the user for sensitive information
         PasswordCallback pc = (PasswordCallback)callbacks[i];
  String password = tokens[index++];
         pc.setPassword(password.toCharArray());

} else if (callbacks[i] instanceof TextOutputCallback) {
  // ignore
       
       } else {
         throw new UnsupportedCallbackException(callbacks[i], 
					 "Unrecognized Callback");
       }
     }
   }
 
开发者ID:ontopia,项目名称:ontopia,代码行数:27,代码来源:TMLoginModuleTest.java

示例8: handle

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
		UnsupportedCallbackException {
	for(Callback cb : callbacks) {
		if(cb instanceof TextOutputCallback) {
			// Not implementing this one yet...
		} else if(cb instanceof NameCallback) {
			NameCallback nc=(NameCallback)cb;
			nc.setName(username);
		} else if(cb instanceof PasswordCallback) {
			PasswordCallback pc=(PasswordCallback)cb;
			pc.setPassword(password);
		} else {
			throw new UnsupportedCallbackException(cb);
		}
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:PlainCallbackHandler.java

示例9: assertDeserialized

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
public void assertDeserialized(Serializable golden, Serializable test) {
    assertTrue(test instanceof TextOutputCallback);
    assertEquals(((TextOutputCallback) golden).getMessage(),
            ((TextOutputCallback) test).getMessage());
    assertEquals(((TextOutputCallback) golden).getMessageType(),
            ((TextOutputCallback) test).getMessageType());

}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:9,代码来源:TextOutputCallbackTest.java

示例10: testSaslClientCallbackHandlerWithException

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
@Test
public void testSaslClientCallbackHandlerWithException() {
  final Token<? extends TokenIdentifier> token = createTokenMock();
  when(token.getIdentifier()).thenReturn(DEFAULT_USER_NAME.getBytes());
  when(token.getPassword()).thenReturn(DEFAULT_USER_PASSWORD.getBytes());
  final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token);
  try {
    saslClCallbackHandler.handle(new Callback[] { mock(TextOutputCallback.class) });
  } catch (UnsupportedCallbackException expEx) {
    //expected
  } catch (Exception ex) {
    fail("testSaslClientCallbackHandlerWithException error : " + ex.getMessage());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestHBaseSaslRpcClient.java

示例11: prompt4NewPassword

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
private boolean prompt4NewPassword(CallbackHandler handler,
                                   Callback[] prompts, Callback[] errors)
    throws IOException, UnsupportedCallbackException
{
  String p = Messages.getFormattedString("KeyCloneCmd.28", //$NON-NLS-1$
                                         new String[] { destinationAlias,
                                                        String.valueOf(keyPasswordChars) });
  PasswordCallback pcb = new PasswordCallback(p, false);
  prompts[0] = pcb;
  handler.handle(prompts);
  char[] pwd1 = pcb.getPassword();
  pcb.clearPassword();
  if (pwd1 == null || pwd1.length == 0)
    {
      newKeyPasswordChars = (char[]) keyPasswordChars.clone();
      return true;
    }

  if (pwd1.length < 6)
    {
      errors[0] = new TextOutputCallback(TextOutputCallback.ERROR,
                                         Messages.getString("StorePasswdCmd.21")); //$NON-NLS-1$
      handler.handle(errors);
      return false;
    }

  newKeyPasswordChars = pwd1;
  return true;
}
 
开发者ID:vilie,项目名称:javify,代码行数:30,代码来源:KeyCloneCmd.java

示例12: handle

import javax.security.auth.callback.TextOutputCallback; //导入依赖的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

示例13: handleTextOutput

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
protected synchronized void handleTextOutput(TextOutputCallback c)
{
  Frame ownerFrame = new Frame();
  Dialog dialog = new Dialog(ownerFrame);
  dialog.setLayout(new GridLayout(2, 1));
  switch (c.getMessageType() /*c.getStyle()*/)
    {
    case ConfirmationCallback.ERROR:
      dialog.setTitle(messages.getString("callback.error"));
      break;
    case ConfirmationCallback.INFORMATION:
      dialog.setTitle(messages.getString("callback.information"));
      break;
    case ConfirmationCallback.WARNING:
      dialog.setTitle(messages.getString("callback.warning"));
      break;
    default:
      dialog.setTitle("");
    }
  Label label = new Label(c.getMessage());
  Panel buttons = new Panel();
  Button ok = new Button(messages.getString("callback.ok"));
  buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
  buttons.add(ok);
  ok.addActionListener(this);
  dialog.add(label);
  dialog.add(buttons);
  dialog.pack();
  dialog.show();
  try { wait(); }
  catch (InterruptedException ie) { }
  dialog.dispose();
  ownerFrame.dispose();
}
 
开发者ID:vilie,项目名称:javify,代码行数:35,代码来源:AWTCallbackHandler.java

示例14: customizeCallbacks

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
private void customizeCallbacks(int state, String msg) throws AuthLoginException {
    switch (state) {
        
        case STATE_ERROR: {
            TextOutputCallback toc = new TextOutputCallback(TextOutputCallback.ERROR, "Impersonation failed");
            replaceCallback(STATE_ERROR, 0, toc);
            break;
        }

        default:
    }
}
 
开发者ID:javedmshah,项目名称:impersonation-policy,代码行数:13,代码来源:ImpersonationModule.java

示例15: abort

import javax.security.auth.callback.TextOutputCallback; //导入依赖的package包/类
/**
 * <p>
 * This method is called if the LoginContext's overall authentication failed.
 * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did
 * not succeed).
 * <p>
 * If this LoginModule's own authentication attempt succeeded (checked by
 * retrieving the private state saved by the {@code login} and
 * {@code commit} methods), then this method cleans up any state that was
 * originally saved.
 * <p>
 *
 * @return false if this LoginModule's own login and/or commit attempts
 *         failed, and true otherwise.
 */
@Override
public boolean abort() {
  if (!succeeded) {
    Callback[] callbacks = new Callback[1];
    callbacks[0] = new TextOutputCallback(TextOutputCallback.ERROR,
        LoginUtils.LOGIN_FAILED);
    try {
      callbackHandler.handle(callbacks);
    } catch (IOException | UnsupportedCallbackException ex) {
      // NO-OP.
    }
    return false;
  }
  if (!commitSucceeded) {
    // login succeeded but overall authentication failed
    succeeded = false;
    username = null;
    suffix = "";
    if (password != null) {
      for (int i = 0; i < password.length; i++) {
        password[i] = ' ';
      }
      password = null;
    }
    userPrincipal = null;
  } else {
    // overall authentication succeeded and commit succeeded,
    // but someone else's commit failed
    logout();
  }
  return true;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:48,代码来源:DevelopmentLoginModule.java


注:本文中的javax.security.auth.callback.TextOutputCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。