本文整理汇总了Java中net.jradius.client.RadiusClient类的典型用法代码示例。如果您正苦于以下问题:Java RadiusClient类的具体用法?Java RadiusClient怎么用?Java RadiusClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RadiusClient类属于net.jradius.client包,在下文中一共展示了RadiusClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import net.jradius.client.RadiusClient; //导入依赖的package包/类
@Override
public boolean authenticate(final String username, final String password) throws PreventedException {
final AttributeList attributeList = new AttributeList();
attributeList.add(new Attr_UserName(username));
attributeList.add(new Attr_UserPassword(password));
RadiusClient client = null;
try {
client = this.radiusClientFactory.newInstance();
LOGGER.debug("Created RADIUS client instance {}", client);
final AccessRequest request = new AccessRequest(client, attributeList);
final RadiusPacket response = client.authenticate(
request,
RadiusClient.getAuthProtocol(this.protocol.getName()),
this.retries);
LOGGER.debug("RADIUS response from {}: {}",
client.getRemoteInetAddress().getCanonicalHostName(),
response.getClass().getName());
if (response instanceof AccessAccept) {
return true;
}
} catch (final Exception e) {
throw new PreventedException(e);
} finally {
if (client != null) {
client.close();
}
}
return false;
}
示例2: setupRequest
import net.jradius.client.RadiusClient; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @see net.jradius.client.auth.RadiusAuthenticator#setupRequest(net.jradius.client.RadiusClient, net.jradius.packet.RadiusPacket)
*/
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
super.setupRequest(c, p);
tunnelRequest = new AccessRequest(tunneledAttributes);
AttributeList attrs = tunnelRequest.getAttributes();
if (attrs.get(Attr_UserName.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(username, false));
if (attrs.get(Attr_UserPassword.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(password, false));
tunnelAuth.setupRequest(c, tunnelRequest);
if (!(tunnelAuth instanceof PAPAuthenticator)) // do not encode pap password
{
tunnelAuth.processRequest(tunnelRequest);
}
}
示例3: OTPProxyRequest
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public OTPProxyRequest(WebServiceListener wsListener, String userName, JRadiusRealm realm, Socket socket, BufferedReader reader, BufferedWriter writer) throws OTPProxyException
{
this.wsListener = wsListener;
this.userName = userName;
this.otpName = RadiusRandom.getRandomString(16);
this.otpPassword = RadiusRandom.getRandomString(16);
this.socket = socket;
this.reader = reader;
this.writer = writer;
this.radiusRealm = realm;
try
{
radiusClient = new RadiusClient(InetAddress.getByName(this.radiusRealm.getServer()), this.radiusRealm.getSharedSecret());
}
catch (Exception e)
{
throw new OTPProxyException(e.getMessage());
}
}
示例4: setupRequest
import net.jradius.client.RadiusClient; //导入依赖的package包/类
/**
* @param c The RadiusClient context being used
* @param p Setup the Authenticator with packet data
* @throws RadiusException
* @throws NoSuchAlgorithmException
*/
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
RadiusAttribute a;
client = c;
if (username == null)
{
a = p.findAttribute(AttributeDictionary.USER_NAME);
if (a == null)
throw new RadiusException("You must at least have a User-Name attribute in a Access-Request");
username = AttributeFactory.copyAttribute(a, false);
}
if (password == null)
{
a = p.findAttribute(AttributeDictionary.USER_PASSWORD);
if (a != null)
{
password = AttributeFactory.copyAttribute(a, false);
}
}
}
示例5: init
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void init() throws RadiusException
{
super.init();
tunnelAuth = RadiusClient.getAuthProtocol(getInnerProtocol());
if (tunnelAuth == null ||
tunnelAuth instanceof MSCHAPv2Authenticator ||
tunnelAuth instanceof MSCHAPv1Authenticator ||
tunnelAuth instanceof CHAPAuthenticator)
{
throw new RadiusException("You can not currently use " + tunnelAuth.getAuthName() +" within a TLS Tunnel because of limitations in Java 1.5.");
}
}
示例6: setupRequest
import net.jradius.client.RadiusClient; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @see net.jradius.client.auth.RadiusAuthenticator#setupRequest(net.jradius.client.RadiusClient, net.jradius.packet.RadiusPacket)
*/
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
super.setupRequest(c, p);
tunnelRequest = new AccessRequest();
AttributeList attrs = tunnelRequest.getAttributes();
if (attrs.get(Attr_UserName.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(username, false));
if (attrs.get(Attr_UserPassword.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(password, false));
tunnelAuth.setupRequest(c, tunnelRequest);
tunnelAuth.processRequest(tunnelRequest);
}
示例7: newPacket
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public static RadiusRequest newPacket(byte b, RadiusClient client, AttributeList list)
{
RadiusRequest p = (RadiusRequest) newPacket(new Integer(b));
p.setRadiusClient(client);
p.getAttributes().add(list);
return p;
}
示例8: authenticate
import net.jradius.client.RadiusClient; //导入依赖的package包/类
@Override
public RadiusResponse authenticate(final String username, final String password) throws PreventedException {
final AttributeList attributeList = new AttributeList();
attributeList.add(new Attr_UserName(username));
attributeList.add(new Attr_UserPassword(password));
if (StringUtils.isNotBlank(this.nasIpAddress)) {
attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
}
if (StringUtils.isNotBlank(this.nasIpv6Address)) {
attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
}
if (StringUtils.isNotBlank(this.nasIdentifier)) {
attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
}
if (this.nasPort != -1) {
attributeList.add(new Attr_NASPort(this.nasPort));
}
if (this.nasPortId != -1) {
attributeList.add(new Attr_NASPortId(this.nasPortId));
}
if (this.nasRealPort != -1) {
attributeList.add(new Attr_NASRealPort(this.nasRealPort));
}
if (this.nasPortType != -1) {
attributeList.add(new Attr_NASPortType(this.nasPortType));
}
RadiusClient client = null;
try {
client = this.radiusClientFactory.newInstance();
final AccessRequest request = new AccessRequest(client, attributeList);
final RadiusPacket response = client.authenticate(
request,
RadiusClient.getAuthProtocol(this.protocol.getName()),
this.retries);
LOGGER.debug("RADIUS response from {}: {}",
client.getRemoteInetAddress().getCanonicalHostName(),
response.getClass().getName());
if (response instanceof AccessAccept) {
final AccessAccept acceptedResponse = (AccessAccept) response;
return new RadiusResponse(acceptedResponse.getCode(),
acceptedResponse.getIdentifier(),
acceptedResponse.getAttributes().getAttributeList());
}
} catch (final Exception e) {
throw new PreventedException(e);
} finally {
if (client != null) {
client.close();
}
}
return null;
}
示例9: authenticate
import net.jradius.client.RadiusClient; //导入依赖的package包/类
@Override
public RadiusResponse authenticate(final String username, final String password) throws PreventedException {
final AttributeList attributeList = new AttributeList();
attributeList.add(new Attr_UserName(username));
attributeList.add(new Attr_UserPassword(password));
if (StringUtils.isNotBlank(this.nasIpAddress)) {
attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
}
if (StringUtils.isNotBlank(this.nasIpv6Address)) {
attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
}
if (this.nasPort != -1) {
attributeList.add(new Attr_NASPort(this.nasPort));
}
if (this.nasPortId != -1) {
attributeList.add(new Attr_NASPortId(this.nasPortId));
}
if (this.nasIdentifier != -1) {
attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
}
if (this.nasRealPort != -1) {
attributeList.add(new Attr_NASRealPort(this.nasRealPort));
}
if (this.nasPortType != -1) {
attributeList.add(new Attr_NASPortType(this.nasPortType));
}
RadiusClient client = null;
try {
client = this.radiusClientFactory.newInstance();
final AccessRequest request = new AccessRequest(client, attributeList);
final RadiusPacket response = client.authenticate(
request,
RadiusClient.getAuthProtocol(this.protocol.getName()),
this.retries);
LOGGER.debug("RADIUS response from {}: {}",
client.getRemoteInetAddress().getCanonicalHostName(),
response.getClass().getName());
if (response instanceof AccessAccept) {
final AccessAccept acceptedResponse = (AccessAccept) response;
return new RadiusResponse(acceptedResponse.getCode(),
acceptedResponse.getIdentifier(),
acceptedResponse.getAttributes().getAttributeList());
}
} catch (final Exception e) {
throw new PreventedException(e);
} finally {
if (client != null) {
client.close();
}
}
return null;
}
示例10: authenticate
import net.jradius.client.RadiusClient; //导入依赖的package包/类
@Override
public RadiusResponse authenticate(final String username, final String password) throws Exception {
final AttributeList attributeList = new AttributeList();
attributeList.add(new Attr_UserName(username));
attributeList.add(new Attr_UserPassword(password));
if (StringUtils.isNotBlank(this.nasIpAddress)) {
attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
}
if (StringUtils.isNotBlank(this.nasIpv6Address)) {
attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
}
if (this.nasPort != -1) {
attributeList.add(new Attr_NASPort(this.nasPort));
}
if (this.nasPortId != -1) {
attributeList.add(new Attr_NASPortId(this.nasPortId));
}
if (StringUtils.isNotBlank(this.nasIdentifier)) {
attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
}
if (this.nasRealPort != -1) {
attributeList.add(new Attr_NASRealPort(this.nasRealPort));
}
if (this.nasPortType != -1) {
attributeList.add(new Attr_NASPortType(this.nasPortType));
}
RadiusClient client = null;
try {
client = this.radiusClientFactory.newInstance();
final AccessRequest request = new AccessRequest(client, attributeList);
final RadiusPacket response = client.authenticate(
request,
RadiusClient.getAuthProtocol(this.protocol.getName()),
this.retries);
LOGGER.debug("RADIUS response from [{}]: [{}]",
client.getRemoteInetAddress().getCanonicalHostName(),
response.getClass().getName());
if (response instanceof AccessAccept) {
final List<RadiusAttribute> attributes = response.getAttributes().getAttributeList();
LOGGER.debug("Radius response code [{}] accepted with attributes [{}] and identifier [{}]",
response.getCode(), attributes, response.getIdentifier());
return new RadiusResponse(response.getCode(),
response.getIdentifier(),
attributes);
}
LOGGER.debug("Response is not recognized");
} finally {
if (client != null) {
client.close();
}
}
return null;
}
示例11: connect
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void connect(final InetAddress address, final int port, final int timeout) throws IOException, Exception {
AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
m_radiusClient = new RadiusClient(address, getSecret(), getAuthPort(), getAcctPort(), convertTimeout(timeout));
}
示例12: handle
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof TextOutputCallback)
{
TextOutputCallback toc = (TextOutputCallback)callbacks[i];
switch (toc.getMessageType())
{
case TextOutputCallback.INFORMATION:
System.out.println(toc.getMessage());
break;
case TextOutputCallback.ERROR:
System.out.println("ERROR: " + toc.getMessage());
break;
case TextOutputCallback.WARNING:
System.out.println("WARNING: " + toc.getMessage());
break;
default:
throw new IOException("Unsupported message type: " + toc.getMessageType());
}
}
else if (callbacks[i] instanceof NameCallback)
{
NameCallback nc = (NameCallback)callbacks[i];
System.err.print(nc.getPrompt());
System.err.flush();
nc.setName((new BufferedReader(new InputStreamReader(System.in))).readLine());
}
else if (callbacks[i] instanceof PasswordCallback)
{
PasswordCallback pc = (PasswordCallback)callbacks[i];
System.err.print(pc.getPrompt());
System.err.flush();
pc.setPassword(readPassword(System.in));
}
else if (callbacks[i] instanceof JRadiusCallback)
{
JRadiusCallback rcb = (JRadiusCallback)callbacks[i];
RadiusClient rc = rcb.getRadiusClient();
AttributeList list = new AttributeList();
rcb.setAuthAttributes(list);
rcb.setAcctAttributes(list);
System.err.print("Radius Server: ");
System.err.flush();
rc.setRemoteInetAddress(InetAddress.getByName((new BufferedReader(new InputStreamReader(System.in))).readLine()));
System.err.print("Shared Secret: ");
System.err.flush();
rc.setSharedSecret((new BufferedReader(new InputStreamReader(System.in))).readLine());
System.err.print("Auth Protocol: ");
System.err.flush();
String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
rcb.setRadiusAuthenticator(RadiusClient.getAuthProtocol(input));
promptAttribute("NAS-Identifier", list);
}
else
{
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
}
示例13: setupRequest
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
super.setupRequest(c, p);
init();
}
示例14: getAuthenticator
import net.jradius.client.RadiusClient; //导入依赖的package包/类
private RadiusAuthenticator getAuthenticator() throws Exception
{
String authName = authTypeNames[authTypeComboBox.getSelectedIndex()];
if (authName.startsWith("EAP-T") || authName.startsWith("PEAP"))
{
if (isJava14)
{
throw new Exception(authName + " not available with this Java version");
}
String s[] = authName.split("/");
StringBuffer sb = new StringBuffer(s[0]);
String v = tlsKeyFileTextField.getText();
if (v != null && !"".equals(v))
{
sb.append(":keyFile=").append(v);
}
v = (String)tlsKeyFileTypeComboBox.getSelectedItem();
if (v != null && !"".equals(v))
{
sb.append(":keyFileType=").append(v);
}
v = tlsKeyPasswordTextField.getText();
if (v != null && !"".equals(v))
{
sb.append(":keyPassword=").append(v);
}
v = tlsCAFileTextField.getText();
if (v != null && !"".equals(v))
{
sb.append(":caFile=").append(v);
}
v = (String)tlsCAFileTypeComboBox.getSelectedItem();
if (v != null && !"".equals(v))
{
sb.append(":caFileType=").append(v);
}
v = tlsCAPasswordTextField.getText();
if (v != null && !"".equals(v))
{
sb.append(":caPassword=").append(v);
}
if (tlsTrustAll.isSelected())
{
sb.append(":trustAll=true");
}
if (s.length == 2)
{
sb.append(":innerProtocol=").append(s[1]);
}
authName = sb.toString();
System.out.println("Using Authenticator String: " + authName);
}
return RadiusClient.getAuthProtocol(authName);
}
示例15: afterPropertiesSet
import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception
{
radiusClient = new RadiusClient(InetAddress.getByName(radiusServer), sharedSecret, authPort, acctPort, 60);
if (radiusClient == null) throw new RuntimeException("could not create RadSec proxy radius client");
}