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


Java PasswordCallback.setPassword方法代码示例

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


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

示例1: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    System.out.println("Callback Handler - handle called");
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callbacks[i];
            nameCallback.setName(name);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callbacks[i];
            passwordCallback.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(callbacks[i],
                    "The submitted Callback is unsupported");
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:WSCallbackHandler.java

示例2: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callback;
            ncb.setName(username);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pwcb = (PasswordCallback) callback;
            pwcb.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(
                    callback,
                    "We got a "
                            + callback.getClass().getCanonicalName()
                            + ", but only NameCallback and PasswordCallback is supported");
        }
    }
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:19,代码来源:KerberosAuthenticator2.java

示例3: handle

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

示例4: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(userName);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callback;
            pc.setPassword(password);
        } else {
            throw new UnsupportedCallbackException(callback,
                    "Unrecognized Callback");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:DynamicConfigurationTest.java

示例5: handlePasswordCallback

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
private void handlePasswordCallback(PasswordCallback pc) {
    if ("super".equals(this.userName) && System.getProperty(SYSPROP_SUPER_PASSWORD) != null) {
        // superuser: use Java system property for password, if available.
        pc.setPassword(System.getProperty(SYSPROP_SUPER_PASSWORD).toCharArray());
    } else if (credentials.containsKey(userName) ) {
        pc.setPassword(credentials.get(userName).toCharArray());
    } else {
        LOG.warn("No password found for user: " + userName);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:11,代码来源:SaslServerCallbackHandler.java

示例6: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
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];
            nc.setName(username);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks[i];
            pc.setPassword(password);
        }
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:14,代码来源:JaasKerberosConfiguration.java

示例7: getUsernamePasswordHandler

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
private static CallbackHandler getUsernamePasswordHandler(final String username, final String password) {
    return callbacks -> {
        for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
                final NameCallback nameCallback = (NameCallback) callback;
                nameCallback.setName(username);
            } else if (callback instanceof PasswordCallback) {
                final PasswordCallback passCallback = (PasswordCallback) callback;
                passCallback.setPassword(password.toCharArray());
            } else {
                System.err.println("Unsupported Callback: " + callback.getClass().getName());
            }
        }
    };
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:16,代码来源:PasswordTicketValidator.java

示例8: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    if (!(callbacks[0] instanceof PasswordCallback)) {
        throw new UnsupportedCallbackException(callbacks[0]);
    }
    PasswordCallback pc = (PasswordCallback)callbacks[0];
    pc.setPassword(password);  // this clones the password if not null
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:P11KeyStore.java

示例9: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback nc = (NameCallback) callbacks[i];
            nc.setName(user);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks[i];
            pc.setPassword(pass);
        }
    }
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:12,代码来源:UserPassCallbackHandler.java

示例10: bad7

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
public void bad7() throws Exception {
    byte[] bytes = new byte[2];
    char[] pwd = "secret7".toCharArray();
    new PBEKeySpec(pwd);
    new PBEKeySpec(pwd, bytes, 1);
    new PBEKeySpec(pwd, bytes, 1, 1);
    PasswordAuthentication auth = new PasswordAuthentication("user", pwd);
    PasswordCallback callback = new PasswordCallback("str", true);
    callback.setPassword(pwd);
    KeyStore.PasswordProtection protection = new KeyStore.PasswordProtection(pwd);
    KerberosKey key = new KerberosKey(null, pwd, "alg");
    KeyManagerFactory.getInstance("").init(null, pwd);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:14,代码来源:ConstantPasswords.java

示例11: handlePasswordCallback

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
private void handlePasswordCallback(PasswordCallback pc) {
    if (credentials.containsKey(userName) ) {
        pc.setPassword(credentials.get(userName).toCharArray());
    } else {
        LOG.warn("No password found for user: {}", userName);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:8,代码来源:SaslQuorumServerCallbackHandler.java

示例12: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException
{
    for ( Callback cb : callbacks )
    {
        if ( cb instanceof NameCallback )
        {
            NameCallback ncb = ( NameCallback ) cb;

            String name = saslReq.getUsername();
            LOG.debug( "sending name {} in the NameCallback", name );
            ncb.setName( name );
        }
        else if ( cb instanceof PasswordCallback )
        {
            PasswordCallback pcb = ( PasswordCallback ) cb;

            LOG.debug( "sending credentials in the PasswordCallback" );
            pcb.setPassword( Strings.utf8ToString( saslReq.getCredentials() ).toCharArray() );
        }
        else if ( cb instanceof RealmCallback )
        {
            RealmCallback rcb = ( RealmCallback ) cb;

            if ( saslReq.getRealmName() != null )
            {
                LOG.debug( "sending the user specified realm value {} in the RealmCallback", saslReq.getRealmName() );
                rcb.setText( saslReq.getRealmName() );
            }
            else
            {
                LOG.debug(
                    "No user specified relam value, sending the default realm value {} in the RealmCallback",
                    rcb.getDefaultText() );
                rcb.setText( rcb.getDefaultText() );
            }
        }
        else if ( cb instanceof RealmChoiceCallback )
        {
            RealmChoiceCallback rccb = ( RealmChoiceCallback ) cb;

            boolean foundRealmName = false;

            String[] realmNames = rccb.getChoices();
            for ( int i = 0; i < realmNames.length; i++ )
            {
                String realmName = realmNames[i];
                if ( realmName.equals( saslReq.getRealmName() ) )
                {
                    foundRealmName = true;

                    LOG.debug( "sending the user specified realm value {} in the RealmChoiceCallback", realmName );
                    rccb.setSelectedIndex( i );
                    break;
                }
            }

            if ( !foundRealmName )
            {
                throw new IOException(
                    I18n.format(
                        "Cannot match ''java.naming.security.sasl.realm'' property value ''{0}'' with choices ''{1}'' in RealmChoiceCallback.",
                        saslReq.getRealmName(), getRealmNamesAsString( realmNames ) ) );
            }
        }
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:71,代码来源:SaslCallbackHandler.java

示例13: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
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 {
                    LOG.warn("Could not login: the client is being asked for a password, but the Zookeeper" +
                      " client code does not currently support obtaining a password from the user." +
                      " Make sure that the client is configured to use a ticket cache (using" +
                      " the JAAS configuration setting 'useTicketCache=true)' and restart the client. If" +
                      " you still get this message after that, the TGT in the ticket cache has expired and must" +
                      " be manually refreshed. To do so, first determine if you are using a password or a" +
                      " keytab. If the former, run kinit in a Unix shell in the environment of the user who" +
                      " is running this Zookeeper client using the command" +
                      " 'kinit <princ>' (where <princ> is the name of the client's Kerberos principal)." +
                      " If the latter, do" +
                      " 'kinit -k -t <keytab> <princ>' (where <princ> is the name of the Kerberos principal, and" +
                      " <keytab> is the location of the keytab file). After manually refreshing your cache," +
                      " restart this client. If you continue to see this message after manually refreshing" +
                      " your cache, ensure that your KDC host's clock is in sync with this host's clock.");
                }
            }
            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:maoling,项目名称:fuck_zookeeper,代码行数:57,代码来源:ZooKeeperSaslClient.java

示例14: handle

import javax.security.auth.callback.PasswordCallback; //导入方法依赖的package包/类
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 {
                    LOG.warn("Could not login: the {} is being asked for a password, but the ZooKeeper {}" +
                      " code does not currently support obtaining a password from the user." +
                      " Make sure that the {} is configured to use a ticket cache (using" +
                      " the JAAS configuration setting 'useTicketCache=true)' and restart the {}. If" +
                      " you still get this message after that, the TGT in the ticket cache has expired and must" +
                      " be manually refreshed. To do so, first determine if you are using a password or a" +
                      " keytab. If the former, run kinit in a Unix shell in the environment of the user who" +
                      " is running this Zookeeper {} using the command" +
                      " 'kinit <princ>' (where <princ> is the name of the {}'s Kerberos principal)." +
                      " If the latter, do" +
                      " 'kinit -k -t <keytab> <princ>' (where <princ> is the name of the Kerberos principal, and" +
                      " <keytab> is the location of the keytab file). After manually refreshing your cache," +
                      " restart this {}. If you continue to see this message after manually refreshing" +
                      " your cache, ensure that your KDC host's clock is in sync with this host's clock.",
                      new Object[]{entity, entity, entity, entity, entity, entity, entity});
                }
            }
            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 " + entity + "Callback");
                    }
                }
            }
        }
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:57,代码来源:SaslClientCallbackHandler.java


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