當前位置: 首頁>>代碼示例>>Java>>正文


Java RealmCallback.setText方法代碼示例

本文整理匯總了Java中javax.security.sasl.RealmCallback.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java RealmCallback.setText方法的具體用法?Java RealmCallback.setText怎麽用?Java RealmCallback.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.security.sasl.RealmCallback的用法示例。


在下文中一共展示了RealmCallback.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" +
                         " client code does not currently support obtaining a password from the user.";
            throw new UnsupportedCallbackException(callback, errorMessage);
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized SASL Login callback");
        }
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:19,代碼來源:AbstractLogin.java

示例2: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(nameCallback.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(TestJaasConfig.PASSWORD.toCharArray());
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(realmCallback.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authCallback = (AuthorizeCallback) callback;
            if (TestJaasConfig.USERNAME.equals(authCallback.getAuthenticationID())) {
                authCallback.setAuthorized(true);
                authCallback.setAuthorizedID(authCallback.getAuthenticationID());
            }
        }
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:22,代碼來源:TestDigestLoginModule.java

示例3: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            String errorMessage = "Could not login: the client is being asked for a password, but this " +
                    " module does not currently support obtaining a password from the user.";
            throw new UnsupportedCallbackException(callback, errorMessage);
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized Login callback");
        }
    }
}
 
開發者ID:hortonworks,項目名稱:registry,代碼行數:19,代碼來源:AbstractLogin.java

示例4: processCallback

import javax.security.sasl.RealmCallback; //導入方法依賴的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

示例5: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for(Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback)callback;
            nameCallback.setName("user");
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback)callback;
            passwordCallback.setPassword(password.toCharArray());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authorizeCallback = (AuthorizeCallback)callback;
            authorizeCallback.setAuthorized(authorizeCallback.getAuthenticationID().equals(authorizeCallback.getAuthorizationID()));
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(REALM);
        } else {
            throw new UnsupportedCallbackException(callback);
        }
    }
}
 
開發者ID:zjumty,項目名稱:jgroups-3.6.4-fixed,代碼行數:21,代碼來源:SASLTest.java

示例6: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(args[0]);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(args[1].toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-config-api,代碼行數:17,代碼來源:AuthCallback.java

示例7: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(this.userName);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(this.password.toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }

}
 
開發者ID:wildfly-swarm-archive,項目名稱:ARCHIVE-wildfly-swarm,代碼行數:19,代碼來源:AuthCallbackHandler.java

示例8: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
  for (Callback cb : callbacks) {
    if (cb instanceof RealmChoiceCallback) {
      continue; // Ignore.
    } else if (cb instanceof NameCallback) {
      ((NameCallback)cb).setName(token_.identifier);
    } else if (cb instanceof PasswordCallback) {
      PasswordCallback pcb = ((PasswordCallback)cb);
      if (token_.password == null) {
        pcb.setPassword(null);
      } else {
        pcb.setPassword(token_.password.toCharArray());
      }
    } else if (cb instanceof RealmCallback) {
      RealmCallback rcb = (RealmCallback)cb;
      rcb.setText(rcb.getDefaultText());
    } else {
      throw new UnsupportedCallbackException(cb, "Unexpected DIGEST-MD5 callback");
    }
  }
}
 
開發者ID:cloudera,項目名稱:RecordServiceClient,代碼行數:24,代碼來源:ThriftUtils.java

示例9: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            ncb.setName(username);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) current;
            pcb.setPassword(password.toCharArray());
        } else if (current instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback) current;
            rcb.setText(rcb.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
開發者ID:fabric8io,項目名稱:jube,代碼行數:17,代碼來源:SimpleCallbackHandler.java

示例10: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
/**
 * 
 */
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback)callbacks[i];
            ncb.setName(authenticationId);
        } else if(callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback)callbacks[i];
            pcb.setPassword(password.toCharArray());
        } else if(callbacks[i] instanceof RealmCallback) {
            RealmCallback rcb = (RealmCallback)callbacks[i];
            //Retrieve the REALM from the challenge response that the server returned when the client initiated the authentication 
            //exchange. If this value is not null or empty, *this value* has to be sent back to the server in the client's response 
            //to the server's challenge
            String text = rcb.getDefaultText();
            //The SASL client (sc) created in smack  uses rcb.getText when creating the negotiatedRealm to send it back to the server
            //Make sure that this value matches the server's realm
            rcb.setText(text);
        } else if(callbacks[i] instanceof RealmChoiceCallback){
            //unused
            //RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
        } else {
           throw new UnsupportedCallbackException(callbacks[i]);
        }
     }
}
 
開發者ID:bejayoharen,項目名稱:java-bells,代碼行數:29,代碼來源:SASLMechanism.java

示例11: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) current;
            if (realm == null || realm.trim().length() == 0) {
                String defaultRealm = realmCallback.getDefaultText();
                realmCallback.setText(defaultRealm);
            } else {
                realmCallback.setText(realm);
            }
        } else if (current instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) current;
            nameCallback.setName(username);
        } else if (current instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) current;
            passwordCallback.setPassword(password);
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
開發者ID:techblue,項目名稱:jboss-controller-operation-executor,代碼行數:22,代碼來源:AuthenticationCallbackHandler.java

示例12: createClient

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
static ModelControllerClient createClient(
        final InetAddress host, final int port,
        final String username, final String password) {

    final CallbackHandler callbackHandler = new CallbackHandler() {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (Callback current : callbacks) {
                if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName(username);
                } else if (current instanceof PasswordCallback) {
                    PasswordCallback pcb = (PasswordCallback) current;
                    pcb.setPassword(password.toCharArray());
                } else if (current instanceof RealmCallback) {
                    RealmCallback rcb = (RealmCallback) current;
                    rcb.setText(rcb.getDefaultText());
                } else {
                    throw new UnsupportedCallbackException(current);
                }
            }
        }
    };

    return ModelControllerClient.Factory.create(host, port, callbackHandler);
}
 
開發者ID:heiko-braun,項目名稱:river-metrics,代碼行數:27,代碼來源:WildlfyRiver.java

示例13: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            if (!isKerberos && subject != null && !subject.getPublicCredentials(String.class).isEmpty()) {
                nc.setName(subject.getPublicCredentials(String.class).iterator().next());
            } else
                nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            if (!isKerberos && subject != null && !subject.getPrivateCredentials(String.class).isEmpty()) {
                char[] password = subject.getPrivateCredentials(String.class).iterator().next().toCharArray();
                ((PasswordCallback) callback).setPassword(password);
            } else {
                String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" +
                         " client code does not currently support obtaining a password from the user.";
                if (isKerberos) {
                    errorMessage += " Make sure -Djava.security.auth.login.config property passed to JVM and" +
                         " the client is configured to use a ticket cache (using" +
                         " the JAAS configuration setting 'useTicketCache=true)'. Make sure you are using" +
                         " FQDN of the Kafka broker you are trying to connect to.";
                }
                throw new UnsupportedCallbackException(callback, errorMessage);
            }
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback ac = (AuthorizeCallback) callback;
            String authId = ac.getAuthenticationID();
            String authzId = ac.getAuthorizationID();
            ac.setAuthorized(authId.equals(authzId));
            if (ac.isAuthorized())
                ac.setAuthorizedID(authzId);
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized SASL ClientCallback");
        }
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:40,代碼來源:SaslClientCallbackHandler.java

示例14: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            if (!isKerberos && subject != null && !subject.getPublicCredentials(String.class).isEmpty()) {
                nc.setName(subject.getPublicCredentials(String.class).iterator().next());
            } else
                nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            if (!isKerberos && subject != null && !subject.getPrivateCredentials(String.class).isEmpty()) {
                char [] password = subject.getPrivateCredentials(String.class).iterator().next().toCharArray();
                ((PasswordCallback) callback).setPassword(password);
            } else {
                String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" +
                         " client code does not currently support obtaining a password from the user.";
                if (isKerberos) {
                    errorMessage += " Make sure -Djava.security.auth.login.config property passed to JVM and" +
                         " the client is configured to use a ticket cache (using" +
                         " the JAAS configuration setting 'useTicketCache=true)'. Make sure you are using" +
                         " FQDN of the Kafka broker you are trying to connect to.";
                }
                throw new UnsupportedCallbackException(callback, errorMessage);
            }
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback ac = (AuthorizeCallback) callback;
            String authId = ac.getAuthenticationID();
            String authzId = ac.getAuthorizationID();
            ac.setAuthorized(authId.equals(authzId));
            if (ac.isAuthorized())
                ac.setAuthorizedID(authzId);
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized SASL ClientCallback");
        }
    }
}
 
開發者ID:txazo,項目名稱:kafka,代碼行數:40,代碼來源:SaslClientCallbackHandler.java

示例15: handle

import javax.security.sasl.RealmCallback; //導入方法依賴的package包/類
@Override
public void handle(Callback[] callbacks) throws
    UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else {
            if (callback instanceof PasswordCallback) {
                PasswordCallback pc = (PasswordCallback) callback;
                if (password != null) {
                    pc.setPassword(this.password.toCharArray());
                }
            } else {
                if (callback instanceof RealmCallback) {
                    RealmCallback rc = (RealmCallback) callback;
                    rc.setText(rc.getDefaultText());
                } else {
                    if (callback instanceof AuthorizeCallback) {
                        AuthorizeCallback ac = (AuthorizeCallback) callback;
                        String authid = ac.getAuthenticationID();
                        String authzid = ac.getAuthorizationID();
                        if (authid.equals(authzid)) {
                            ac.setAuthorized(true);
                        } else {
                            ac.setAuthorized(false);
                        }
                        if (ac.isAuthorized()) {
                            ac.setAuthorizedID(authzid);
                        }
                    } else {
                        throw new UnsupportedCallbackException(callback, "Unrecognized SASL ClientCallback");
                    }
                }
            }
        }
    }
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:39,代碼來源:SaslNettyServer.java


注:本文中的javax.security.sasl.RealmCallback.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。