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


Java NameCallback.setName方法代码示例

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


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

示例1: handle

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

import javax.security.auth.callback.NameCallback; //导入方法依赖的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(username);
		} else if (callbacks[i] instanceof PasswordCallback) {
			PasswordCallback pcb = (PasswordCallback) callbacks[i];
			pcb.setPassword(password.toCharArray());
		} else {
			throw new UnsupportedCallbackException(
					callbacks[i],
					"Unrecognized Callback");
		}
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:17,代码来源:EjbUtil.java

示例6: getUserNamePasswordCallbackHandler

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
 * Create call back handler using given username and password
 *
 * @param username
 * @param password
 * @return CallbackHandler
 */
private static CallbackHandler getUserNamePasswordCallbackHandler(final String username, final char[] password) {

    return new CallbackHandler() {
        public void handle(final Callback[] callback) {
            for (Callback currentCallBack : callback) {
                if (currentCallBack instanceof NameCallback) {
                    final NameCallback nameCallback = (NameCallback) currentCallBack;
                    nameCallback.setName(username);
                } else if (currentCallBack instanceof PasswordCallback) {
                    final PasswordCallback passCallback = (PasswordCallback) currentCallBack;
                    passCallback.setPassword(password);
                } else {
                    log.error("Unsupported Callback class = " + currentCallBack.getClass().getName());
                }
            }
        }
    };
}
 
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:26,代码来源:IWAAuthenticationUtil.java

示例7: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
 */
@Override
public void handle ( Callback[] callbacks ) throws IOException, UnsupportedCallbackException {
    for ( Callback cb : callbacks ) {
        if ( log.isDebugEnabled() ) {
            log.debug("Got callback " + cb.getClass().getName());
        }

        if ( cb instanceof NameCallback ) {
            NameCallback nc = (NameCallback) cb;
            String userDomain = this.getSpecifiedUserDomain();
            if ( this.getUsername() != null && userDomain != null ) {
                nc.setName(this.getUsername() + "@" + userDomain);
            }
        }
        else if ( cb instanceof PasswordCallback ) {
            PasswordCallback pc = (PasswordCallback) cb;
            if ( this.getPassword() != null ) {
                pc.setPassword(this.getPassword().toCharArray());
            }
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:28,代码来源:JAASAuthenticator.java

示例8: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的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(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:18,代码来源:UsernamePasswordCallbackHandler.java

示例9: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
 * Handles the callbacks, and sets the user/password detail.
 * @param callbacks the callbacks to handle
 * @throws IOException if an input or output error occurs.
 */
public void handle( Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
	 
  for ( int i=0; i<callbacks.length; i++) {
    if ( callbacks[i] instanceof NameCallback && username != null) {
      NameCallback nc = (NameCallback) callbacks[i];
      nc.setName( username);
    }
    else if ( callbacks[i] instanceof PasswordCallback) {
      PasswordCallback pc = (PasswordCallback) callbacks[i];
      pc.setPassword( password.toCharArray());
    }
    else {
      /*throw new UnsupportedCallbackException(
      callbacks[i], "Unrecognized Callback");*/
    }
  }
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:24,代码来源:KerberosCallbackHandler.java

示例10: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
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:BT-OpenSource,项目名称:Skool,代码行数:21,代码来源:KerberosAuthenticator2.java

示例11: getUsernamePasswordHandler

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
 * Used by the BASIC Auth mechanism for establishing a LoginContext 
 * to authenticate a client/caller/request.
 * 
 * @param username client username
 * @param password client password
 * @return CallbackHandler to be used for establishing a LoginContext
 */
public static CallbackHandler getUsernamePasswordHandler(
    final String username, final String password) {

    LOGGER.fine("username=" + username + "; password=" + password.hashCode());

    final CallbackHandler handler = new CallbackHandler() {
        public void handle(final Callback[] callback) {
            for (int i=0; i<callback.length; i++) {
                if (callback[i] instanceof NameCallback) {
                    final NameCallback nameCallback = (NameCallback) callback[i];
                    nameCallback.setName(username);
                } else if (callback[i] instanceof PasswordCallback) {
                    final PasswordCallback passCallback = (PasswordCallback) callback[i];
                    passCallback.setPassword(password.toCharArray());
                } else {
                    LOGGER.warning("Unsupported Callback i=" + i + "; class=" 
                            + callback[i].getClass().getName());
                }
            }
        }
    };

    return handler;
}
 
开发者ID:codelibs,项目名称:spnego,代码行数:33,代码来源:SpnegoProvider.java

示例12: handleNameCallback

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
private void handleNameCallback(NameCallback nc) {
    // check to see if this user is in the user password database.
    if (credentials.get(nc.getDefaultName()) == null) {
        LOG.warn("User '" + nc.getDefaultName() + "' not found in list of DIGEST-MD5 authenticateable users.");
        return;
    }
    nc.setName(nc.getDefaultName());
    userName = nc.getDefaultName();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:10,代码来源:SaslServerCallbackHandler.java

示例13: handle

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

示例14: getUsernamePasswordHandler

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

示例15: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	iHandler.handle(callbacks);
	if (iRealm != null)
		for (Callback callback : callbacks) {
			if (callback instanceof NameCallback) {
				NameCallback nc = (NameCallback) callback;
				if (nc.getName() != null && !nc.getName().contains("@"))
					nc.setName(nc.getName() + "@" + iRealm);
			}
		}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:KerberosAuthenticateModule.java


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