Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. package zti;
  2.  
  3. import java.io.*;
  4. import javax.security.auth.*;
  5. import javax.security.auth.callback.*;
  6.  
  7. public class MyCallbackHandler implements CallbackHandler {
  8. private String name;
  9.  
  10. public MyCallbackHandler(String name)
  11. {
  12. this.name = name;
  13. }
  14.  
  15. public void handle(Callback callbacks[]) throws IOException, UnsupportedCallbackException {
  16. for(int i=0;i<callbacks.length;i++) {
  17. if(callbacks[i] instanceof NameCallback) {
  18. NameCallback nc = (NameCallback) callbacks[i];
  19. nc.setName(name);
  20. } else {
  21. throw(new UnsupportedCallbackException(callbacks[i], "not supported!"));
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement