Package javax.security.sasl

Examples of javax.security.sasl.AuthorizeCallback


            log.finest("PasswordCallback: " +  passwd);
          } catch (Exception e) {
            throw new IOException("Password retrieving problem.", e);
          } // end of try-catch
        } else if (callbacks[i] instanceof AuthorizeCallback) {
          AuthorizeCallback authCallback = ((AuthorizeCallback)callbacks[i]);
          String authenId = authCallback.getAuthenticationID();
          log.finest("AuthorizeCallback: authenId: " + authenId);
          String authorId = authCallback.getAuthorizationID();
          log.finest("AuthorizeCallback: authorId: " + authorId);
          if (authenId.equals(authorId)) {
            authCallback.setAuthorized(true);
          } // end of if (authenId.equals(authorId))
        } else {
          throw new UnsupportedCallbackException
            (callbacks[i], "Unrecognized Callback");
        }
View Full Code Here


            log.finest("PasswordCallback: " +  passwd);
          } catch (Exception e) {
            throw new IOException("Password retrieving problem.", e);
          } // end of try-catch
        } else if (callbacks[i] instanceof AuthorizeCallback) {
          AuthorizeCallback authCallback = ((AuthorizeCallback)callbacks[i]);
          String authenId = authCallback.getAuthenticationID();
          log.finest("AuthorizeCallback: authenId: " + authenId);
          String authorId = authCallback.getAuthorizationID();
          log.finest("AuthorizeCallback: authorId: " + authorId);
          if (authenId.equals(authorId)) {
            authCallback.setAuthorized(true);
          } // end of if (authenId.equals(authorId))
        } else {
          throw new UnsupportedCallbackException
            (callbacks[i], "Unrecognized Callback");
        }
View Full Code Here

        throw new SaslException("Password missmatch.");
      }
      if (authoriz != null && !authoriz.isEmpty()) {
        String realm = rc.getText();
        callbacks = new Callback[1];
        AuthorizeCallback ac =
          new AuthorizeCallback(JIDUtils.getNodeID(user_id, realm), authoriz);
        callbacks[0] = ac;
        callbackHandler.handle(callbacks);
        if (ac.isAuthorized()) {
          auth_ok = true;
        } else {
          throw new SaslException("Not authorized.");
        } // end of else
      } else {
View Full Code Here

            log.finest("PasswordCallback: " +  passwd);
          } catch (Exception e) {
            throw new IOException("Password retrieving problem.", e);
          } // end of try-catch
        } else if (callbacks[i] instanceof AuthorizeCallback) {
          AuthorizeCallback authCallback = ((AuthorizeCallback)callbacks[i]);
          String authenId = authCallback.getAuthenticationID();
          log.finest("AuthorizeCallback: authenId: " + authenId);
          String authorId = authCallback.getAuthorizationID();
          log.finest("AuthorizeCallback: authorId: " + authorId);
          if (authenId.equals(authorId)) {
            authCallback.setAuthorized(true);
          } // end of if (authenId.equals(authorId))
        } else {
          throw new UnsupportedCallbackException
            (callbacks[i], "Unrecognized Callback");
        }
View Full Code Here

      @Override
      public void handle(Callback[] callbacks) throws InvalidToken,
      UnsupportedCallbackException {
        NameCallback nc = null;
        PasswordCallback pc = null;
        AuthorizeCallback ac = null;
        for (Callback callback : callbacks) {
          if (callback instanceof AuthorizeCallback) {
            ac = (AuthorizeCallback) callback;
          } else if (callback instanceof NameCallback) {
            nc = (NameCallback) callback;
          } else if (callback instanceof PasswordCallback) {
            pc = (PasswordCallback) callback;
          } else if (callback instanceof RealmCallback) {
            continue; // realm is ignored
          } else {
            throw new UnsupportedCallbackException(callback,
            "Unrecognized SASL DIGEST-MD5 Callback");
          }
        }
        if (pc != null) {
          DelegationTokenIdentifier tokenIdentifier = SaslRpcServer.
          getIdentifier(nc.getDefaultName(), secretManager);
          char[] password = getPassword(tokenIdentifier);

          if (LOG.isDebugEnabled()) {
            LOG.debug("SASL server DIGEST-MD5 callback: setting password "
                + "for client: " + tokenIdentifier.getUser());
          }
          pc.setPassword(password);
        }
        if (ac != null) {
          String authid = ac.getAuthenticationID();
          String authzid = ac.getAuthorizationID();
          if (authid.equals(authzid)) {
            ac.setAuthorized(true);
          } else {
            ac.setAuthorized(false);
          }
          if (ac.isAuthorized()) {
            if (LOG.isDebugEnabled()) {
              String username =
                SaslRpcServer.getIdentifier(authzid, secretManager).getUser().getUserName();
              LOG.debug("SASL server DIGEST-MD5 callback: setting "
                  + "canonicalized client ID: " + username);
            }
            ac.setAuthorizedID(authzid);
          }
        }
      }
View Full Code Here

            log.finest("PasswordCallback: " +  passwd);
          } catch (Exception e) {
            throw new IOException("Password retrieving problem.", e);
          } // end of try-catch
        } else if (callbacks[i] instanceof AuthorizeCallback) {
          AuthorizeCallback authCallback = ((AuthorizeCallback)callbacks[i]);
          String authenId = authCallback.getAuthenticationID();
          log.finest("AuthorizeCallback: authenId: " + authenId);
          String authorId = authCallback.getAuthorizationID();
          log.finest("AuthorizeCallback: authorId: " + authorId);
          if (authenId.equals(authorId)) {
            authCallback.setAuthorized(true);
          } // end of if (authenId.equals(authorId))
        } else {
          throw new UnsupportedCallbackException
            (callbacks[i], "Unrecognized Callback");
        }
View Full Code Here

    @Override
    public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
      NameCallback nc = null;
      PasswordCallback pc = null;
      AuthorizeCallback ac = null;
      for (Callback callback : callbacks) {
        if (callback instanceof AuthorizeCallback) {
          ac = (AuthorizeCallback) callback;
        } else if (callback instanceof NameCallback) {
          nc = (NameCallback) callback;
        } else if (callback instanceof PasswordCallback) {
          pc = (PasswordCallback) callback;
        } else if (callback instanceof RealmCallback) {
          continue; // realm is ignored
        } else {
          throw new UnsupportedCallbackException(callback,
              "handle: Unrecognized SASL DIGEST-MD5 Callback");
        }
      }
      if (pc != null) {
        JobTokenIdentifier tokenIdentifier = getIdentifier(nc.getDefaultName(),
            secretManager);
        char[] password =
          encodePassword(secretManager.retrievePassword(tokenIdentifier));

        if (LOG.isDebugEnabled()) {
          LOG.debug("handle: SASL server DIGEST-MD5 callback: setting " +
              "password for client: " + tokenIdentifier.getUser());
        }
        pc.setPassword(password);
      }
      if (ac != null) {
        String authid = ac.getAuthenticationID();
        String authzid = ac.getAuthorizationID();
        if (authid.equals(authzid)) {
          ac.setAuthorized(true);
        } else {
          ac.setAuthorized(false);
        }
        if (ac.isAuthorized()) {
          if (LOG.isDebugEnabled()) {
            String username =
              getIdentifier(authzid, secretManager).getUser().getUserName();
            if (LOG.isDebugEnabled()) {
              LOG.debug("handle: SASL server DIGEST-MD5 callback: setting " +
                  "canonicalized client ID: " + username);
            }
          }
          ac.setAuthorizedID(authzid);
        }
      }
    }
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public void handle(Callback[] callbacks) throws
        UnsupportedCallbackException {
      AuthorizeCallback ac = null;
      for (Callback callback : callbacks) {
        if (callback instanceof AuthorizeCallback) {
          ac = (AuthorizeCallback) callback;
        } else {
          throw new UnsupportedCallbackException(callback,
              "Unrecognized SASL GSSAPI Callback");
        }
      }
      if (ac != null) {
        String authid = ac.getAuthenticationID();
        String authzid = ac.getAuthorizationID();
        if (authid.equals(authzid)) {
          ac.setAuthorized(true);
        } else {
          ac.setAuthorized(false);
        }
        if (ac.isAuthorized()) {
          if (LOG.isDebugEnabled())
            LOG.debug("SASL server GSSAPI callback: setting "
                + "canonicalized client ID: " + authzid);
          ac.setAuthorizedID(authzid);
        }
      }
    }
View Full Code Here

    @Override
    public void handle(Callback[] callbacks) throws InvalidToken,
        UnsupportedCallbackException {
      NameCallback nc = null;
      PasswordCallback pc = null;
      AuthorizeCallback ac = null;
      for (Callback callback : callbacks) {
        if (callback instanceof AuthorizeCallback) {
          ac = (AuthorizeCallback) callback;
        } else if (callback instanceof NameCallback) {
          nc = (NameCallback) callback;
        } else if (callback instanceof PasswordCallback) {
          pc = (PasswordCallback) callback;
        } else if (callback instanceof RealmCallback) {
          continue; // realm is ignored
        } else {
          throw new UnsupportedCallbackException(callback,
              "Unrecognized SASL DIGEST-MD5 Callback");
        }
      }
      if (pc != null) {
        TokenIdentifier tokenIdentifier = getIdentifier(nc.getDefaultName(), secretManager);
        char[] password = getPassword(tokenIdentifier);
        UserGroupInformation user = null;
        user = tokenIdentifier.getUser(); // may throw exception
        connection.attemptingUser = user;
        if (LOG.isDebugEnabled()) {
          LOG.debug("SASL server DIGEST-MD5 callback: setting password "
              + "for client: " + tokenIdentifier.getUser());
        }
        pc.setPassword(password);
      }
      if (ac != null) {
        String authid = ac.getAuthenticationID();
        String authzid = ac.getAuthorizationID();
        if (authid.equals(authzid)) {
          ac.setAuthorized(true);
        } else {
          ac.setAuthorized(false);
        }
        if (ac.isAuthorized()) {
          if (LOG.isDebugEnabled()) {
            String username =
              getIdentifier(authzid, secretManager).getUser().getUserName();
            LOG.debug("SASL server DIGEST-MD5 callback: setting "
                + "canonicalized client ID: " + username);
          }
          ac.setAuthorizedID(authzid);
        }
      }
    }
View Full Code Here

            String pwd = new String(response, authcidNullPosition + 1, passwordLen, "utf8");
           
            // we do not care about the prompt but it throws if null
            NameCallback nameCb = new NameCallback("prompt", authzid);
            PlainPasswordCallback passwordCb = new PlainPasswordCallback("prompt", false, pwd);
            AuthorizeCallback authzCb = new AuthorizeCallback(authzid, authzid);

            Callback[] callbacks = new Callback[]{nameCb, passwordCb, authzCb};
            _cbh.handle(callbacks);

            if (passwordCb.isAuthenticated())
            {
                _complete = true;
            }
            if (authzCb.isAuthorized() && _complete)
            {
                _authorizationId = authzCb.getAuthenticationID();
                return null;
            }
            else
            {
                throw new SaslException("Authentication failed");
View Full Code Here

TOP

Related Classes of javax.security.sasl.AuthorizeCallback

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.