Package javax.security.auth.callback

Examples of javax.security.auth.callback.CallbackHandler


        // If username specifies a domain (user@domain) only that domain is authenticated against.
        // If username specifies no domain, then all domains are tried in order.
        for (String domain:getDomainsForUser(domains, username)) {
                   
            try {
            CallbackHandler handler = new CallbackHandler() {
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
              if (callbacks[i] instanceof NameCallback) {
                NameCallback nc = (NameCallback)callbacks[i];
View Full Code Here


  public void testLoginAndPermission() {
    initControl();
   
    LoginContext loginContext;
    try {
      loginContext = new LoginContext("gvs", new CallbackHandler() {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
              ((NameCallback) callback).setName(username);
View Full Code Here

  public void testWrongLogin() {
    initControl();
    final boolean[] exceptionCatched = new boolean[1];
    LoginContext loginContext;
    try {
      loginContext = new LoginContext("gvs", new CallbackHandler() {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
              ((NameCallback) callback).setName(username);
View Full Code Here

      public JaasSecurityHandler(Object target, final String username, final String password) {
          this.target = target;               
          Configuration jaasConfig = new JBossConfiguration();
          try {
              this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, null, new CallbackHandler() {
         
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                for (Callback callback : callbacks) {
                    if (callback instanceof NameCallback) {
View Full Code Here

        try {
          Cookie loginCookie = new Cookie("login", "-");
          loginCookie.setMaxAge(-1);
          response.setHeader(HeaderName.SET_COOKIE, loginCookie.toString());

          loginContext = new LoginContext("GVS-Auth", new CallbackHandler() {

            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
              for (int i = 0; i < callbacks.length; i++) {
                if (callbacks[i] instanceof NameCallback) {
                  ((NameCallback) callbacks[i]).setName("");
View Full Code Here

            {
               System.setProperty(JNDIBasedSecurityManagement.CBH, callbackHandlerClassName);
               return null;
            }
         });
         CallbackHandler callbackHandler = null;
         callbackHandler = (CallbackHandler) callbackHandlerClass.newInstance();
         if (callbackHandler != null)
            securityManagement.setCallBackHandler(callbackHandler);
      }
     
View Full Code Here

        */
    }

    public void testLogin()
    {
        CallbackHandler handler = new UsernamePasswordHandler("scott", "stark".toCharArray());
        try
        {
            LoginContext lc = new LoginContext("srp-login", handler);
            lc.login();
            Subject subject = lc.getSubject();
View Full Code Here

                    && WSConstants.SAML2_NS.equals(namespace) && "Assertion".equals(localname)) {
                return new AssertionWrapper(tokenElement);
            }
        }
       
        CallbackHandler handler = null;
        if (o instanceof CallbackHandler) {
            handler = (CallbackHandler)o;
        } else if (o instanceof String) {
            try {
                handler = (CallbackHandler)ClassLoaderUtils
View Full Code Here

        return id;
    }
   
    public String getPassword(String userName, Assertion info, int type) {
        //Then try to get the password from the given callback handler
        CallbackHandler handler = getCallbackHandler();
        if (handler == null) {
            policyNotAsserted(info, "No callback handler and no password available");
            return null;
        }
       
        WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)};
        try {
            handler.handle(cb);
        } catch (Exception e) {
            policyNotAsserted(info, e);
        }
       
        //get the password
View Full Code Here

    }
   
    protected CallbackHandler getCallbackHandler() {
        Object o = message.getContextualProperty(SecurityConstants.CALLBACK_HANDLER);
       
        CallbackHandler handler = null;
        if (o instanceof CallbackHandler) {
            handler = (CallbackHandler)o;
        } else if (o instanceof String) {
            try {
                handler = (CallbackHandler)ClassLoaderUtils
View Full Code Here

TOP

Related Classes of javax.security.auth.callback.CallbackHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.