本文整理汇总了Java中net.jradius.packet.attribute.AttributeFactory类的典型用法代码示例。如果您正苦于以下问题:Java AttributeFactory类的具体用法?Java AttributeFactory怎么用?Java AttributeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeFactory类属于net.jradius.packet.attribute包,在下文中一共展示了AttributeFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getKeyFromAttributeType
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
protected Serializable getKeyFromAttributeType(RadiusPacket req, long type, boolean required) throws RadiusException
{
RadiusAttribute a = req.findAttribute(type);
if (a == null)
{
if (required)
{
a = AttributeFactory.newAttribute(type, null, false);
throw new RadiusException("Missing required attribute: " + a.getAttributeName());
}
return null;
}
AttributeValue v = a.getValue();
return v.toString();
}
开发者ID:coova,项目名称:jradius,代码行数:18,代码来源:RadiusSessionKeyProvider.java
示例2: setupRequest
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的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);
}
}
开发者ID:coova,项目名称:jradius,代码行数:20,代码来源:EAPTTLSAuthenticator.java
示例3: initialize
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setJMenuBar(getJJMenuBar());
this.setSize(650, 600);
this.setContentPane(getMainContentPane());
this.setTitle("JRadiusSimulator");
this.setVisible(true);
String osName = System.getProperty("os.name");
if (osName.indexOf("Windows") != -1) windows = true;
else windows = false;
logSent = new PrintStream(logConsole.createFilteredStream(LogConsole.CATEGORY_PACKETS_SENT));
logRecv = new PrintStream(logConsole.createFilteredStream(LogConsole.CATEGORY_PACKETS_RECV));
logErr = new PrintStream(logConsole.createFilteredStream(LogConsole.CATEGORY_ERROR));
AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
try { loadConfigFile(configFileUrl); } catch (Exception e) { e.printStackTrace(); }
statusLabel.setText("Ready");
fileMenu.setEnabled(true);
mainTabPane.setEnabled(true);
runButton.setEnabled(true);
}
开发者ID:coova,项目名称:jradius,代码行数:29,代码来源:JRadiusSimulator.java
示例4: createNamedValueCellEditor
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
private JComboBox createNamedValueCellEditor(String attributeName)
{
JComboBox comboBox = (JComboBox)namedValueComponentCache.get(attributeName);
if (comboBox != null) return comboBox;
try
{
RadiusAttribute attribute = AttributeFactory.newAttribute(attributeName);
NamedValue namedValue = (NamedValue)attribute.getValue();
NamedValueMap valueMap = namedValue.getMap();
Long[] possibleValues = valueMap.getKnownValues();
comboBox = new JComboBox();
for (int i=0; i<possibleValues.length;i++)
{
comboBox.addItem(valueMap.getNamedValue(possibleValues[i]));
}
namedValueComponentCache.put(attributeName, comboBox);
}
catch (Exception e) { e.printStackTrace(); }
return comboBox;
}
开发者ID:coova,项目名称:jradius,代码行数:21,代码来源:JRadiusSimulator.java
示例5: updateAccounting
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public void updateAccounting(AccountingRequest acctRequest) throws RadiusException
{
AccountingRequest newRequest = new AccountingRequest(radiusClient, reqList);
AttributeList attrs = acctRequest.getAttributes();
for (Iterator i=attrs.getAttributeList().iterator(); i.hasNext();)
{
RadiusAttribute at = (RadiusAttribute)i.next();
long type = at.getFormattedType();
if (type == Attr_AcctInputOctets.TYPE ||
type == Attr_AcctOutputOctets.TYPE ||
type == Attr_AcctInputGigawords.TYPE ||
type == Attr_AcctOutputGigawords.TYPE ||
type == Attr_AcctInputPackets.TYPE ||
type == Attr_AcctOutputPackets.TYPE ||
type == Attr_AcctTerminateCause.TYPE ||
type == Attr_AcctSessionStartTime.TYPE ||
type == Attr_AcctDelayTime.TYPE ||
type == Attr_AcctSessionTime.TYPE ||
type == Attr_AcctStatusType.TYPE)
newRequest.addAttribute(AttributeFactory.newAttribute(type, at.getValue().getBytes(), false));
}
radiusClient.accounting(newRequest, 2);
}
开发者ID:coova,项目名称:jradius,代码行数:25,代码来源:OTPProxyRequest.java
示例6: processChallenge
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
/**
* EAP requires a challenge/response. The request packet is reset with a new
* RADIUS identifier and the EAP-Message is encoded.
* @throws NoSuchAlgorithmException
* @see net.jradius.client.auth.RadiusAuthenticator#processChallenge(net.jradius.packet.RadiusPacket, net.jradius.packet.RadiusPacket)
*/
public void processChallenge(RadiusPacket p, RadiusPacket r) throws RadiusException, NoSuchAlgorithmException
{
super.processChallenge(p, r);
p.setIdentifier(-1);
byte[] eapReply = AttributeFactory.assembleAttributeList(r.getAttributes(), AttributeDictionary.EAP_MESSAGE);
byte[] eapMessage = doEAP(eapReply);
RadiusAttribute a = p.findAttribute(AttributeDictionary.EAP_MESSAGE);
if (a != null) p.removeAttribute(a);
AttributeFactory.addToAttributeList(p.getAttributes(),
AttributeDictionary.EAP_MESSAGE, eapMessage, p.isRecyclable());
RadiusLog.debug("Sending Challenge:\n" + p.toString());
}
开发者ID:coova,项目名称:jradius,代码行数:24,代码来源:EAPAuthenticator.java
示例7: processRequest
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = MSCHAP.doMSCHAPv1(password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Response"));
attr.setValue(chapResponse);
}
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:MSCHAPv1Authenticator.java
示例8: processRequest
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = CHAP.chapResponse((byte)p.getIdentifier(), password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Password"));
attr.setValue(chapResponse);
}
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:CHAPAuthenticator.java
示例9: setupRequest
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的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);
}
}
}
开发者ID:coova,项目名称:jradius,代码行数:32,代码来源:RadiusAuthenticator.java
示例10: initializeServer
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
/**
* Read the configuration and initialize the JRadiusServer
* @throws SecurityException
* @throws IllegalArgumentException
* @throws ClassNotFoundException
* @throws NoSuchMethodException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
private void initializeServer() throws Exception
{
RadiusLog.info("Initializing JRadius Server....");
for (Iterator i = Configuration.getDictionaryConfigs().iterator(); i.hasNext();)
{
DictionaryConfigurationItem dictionaryConfig = (DictionaryConfigurationItem) i.next();
RadiusLog.info("Loading dictionary: " + dictionaryConfig.getClassName());
AttributeFactory.loadAttributeDictionary((AttributeDictionary)Configuration.getBean(dictionaryConfig.getClassName()));
}
for (ListenerConfigurationItem listenerConfig : Configuration.getListenerConfigs())
{
LinkedBlockingQueue<ListenerRequest> queue = new LinkedBlockingQueue<ListenerRequest>();
createListenerWithConfigAndQueue(listenerConfig, queue);
createProcessorsWithConfigAndQueue(listenerConfig, queue);
}
RadiusLog.info("JRadius Server succesfully Initialized.");
}
开发者ID:coova,项目名称:jradius,代码行数:28,代码来源:JRadiusServer.java
示例11: promptAttribute
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
private void promptAttribute(String attr, AttributeList list)
{
try
{
// Standard Attributes:
System.err.print(attr + ": ");
System.err.flush();
String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
list.add(AttributeFactory.newAttribute(attr, input, "="));
}
catch (Exception e)
{
RadiusLog.error(e.getMessage());
}
}
开发者ID:coova,项目名称:jradius,代码行数:16,代码来源:JAASAuthenticationTest.java
示例12: handle
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
// System.err.println(this.getClass().getName());
RadiusPacket req = request.getRequestPacket();
byte[] packetClass = (byte[])req.getAttributeValue(Attr_Class.TYPE);
byte[][] sessionClass = session.getRadiusClass();
if (packetClass != null || sessionClass != null)
{
if (sessionClass == null)
{
session.addLogMessage(request, "Request has Class attribute when it should not");
}
else
{
session.addLogMessage(request, "Missing Class Attribute (added)");
req.removeAttribute(Attr_Class.TYPE);
for (byte[] a : sessionClass) {
req.addAttribute(AttributeFactory.newAttribute(Attr_Class.TYPE, a, req.isRecyclable()));
}
}
}
if (req instanceof AccessRequest)
{
byte[] sessionState = session.getRadiusState();
if (sessionState != null)
{
// System.out.println("Missing State Attribute (added) "+sessionState.length+" "+sessionState[0]);
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_State.TYPE, sessionState, req.isRecyclable()));
}
}
return false;
}
开发者ID:coova,项目名称:jradius,代码行数:41,代码来源:ProxyClassHandler.java
示例13: handle
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
RadiusPacket req = request.getRequestPacket();
AttributeList ci = request.getConfigItems();
JRadiusSession session = request.getSession();
JRadiusLogEntry logEntry = session.getLogEntry(request);
// We set the type at every stage... the function, in fact,
// only really sets the type when appropriate.
if (logEntry != null)
{
logEntry.init(request, session);
}
// Put some internal values into the ConfigItems for
// easy processing of JRadius reuqests/sessions.
if (ci.get(Attr_JRadiusSessionId.TYPE) == null)
{
ci.add(AttributeFactory.newAttribute(Attr_JRadiusSessionId.TYPE, session.getSessionKey(), false));
}
if (ci.get(Attr_JRadiusRequestId.TYPE) == null)
{
ci.add(AttributeFactory.newAttribute(Attr_JRadiusRequestId.TYPE, Integer.toString(req.getIdentifier()), false));
}
return session.onPreProcessing(request);
}
开发者ID:coova,项目名称:jradius,代码行数:31,代码来源:InitSessionHandler.java
示例14: handle
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
RadiusPacket rep = request.getReplyPacket();
if (!(rep instanceof AccessAccept ||
rep instanceof AccessChallenge)) return false;
Object[] attrs = rep.findAttributes(Attr_Class.TYPE);
if (attrs != null && session.getRadiusClass() == null)
{
byte[][] classes = new byte[attrs.length][];
for (int i = 0; i < attrs.length; i++)
{
RadiusAttribute attribute = (RadiusAttribute) attrs[i];
classes[i] = (byte[]) attribute.getValue().getValueObject();
}
// System.err.println(this.getClass().getName() + " setting radiusClass");
session.setRadiusClass(classes);
}
RadiusAttribute attr = rep.findAttribute(Attr_State.TYPE);
if (attr != null)
{
byte[] val = (byte[]) attr.getValue().getValueObject();
// System.err.println(this.getClass().getName() + " setting radiusState "+val.length+" "+val[0]);
session.setRadiusState(val);
}
rep.overwriteAttribute(AttributeFactory.newAttribute(rep instanceof AccessAccept ? Attr_Class.TYPE : Attr_State.TYPE,
(ClassPrefix + session.getSessionKey()).getBytes(), rep.isRecyclable()));
return false;
}
开发者ID:coova,项目名称:jradius,代码行数:37,代码来源:PostAuthorizeClassHandler.java
示例15: reverseAccounting
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
protected void reverseAccounting(RadiusPacket req) throws RadiusException
{
Long octetsIn = (Long)req.getAttributeValue(Attr_AcctInputOctets.TYPE);
Long octetsOut = (Long)req.getAttributeValue(Attr_AcctOutputOctets.TYPE);
Long gigaIn = (Long)req.getAttributeValue(Attr_AcctInputGigawords.TYPE);
Long gigaOut = (Long)req.getAttributeValue(Attr_AcctOutputGigawords.TYPE);
Long packetsIn = (Long)req.getAttributeValue(Attr_AcctInputPackets.TYPE);
Long packetsOut = (Long)req.getAttributeValue(Attr_AcctOutputPackets.TYPE);
if (octetsIn != null && octetsOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputOctets.TYPE, octetsOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputOctets.TYPE, octetsIn, req.isRecyclable()));
}
if (gigaIn != null && gigaOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputGigawords.TYPE, gigaOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputGigawords.TYPE, gigaIn, req.isRecyclable()));
}
if (packetsIn != null && packetsOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputPackets.TYPE, packetsOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputPackets.TYPE, packetsIn, req.isRecyclable()));
}
}
开发者ID:coova,项目名称:jradius,代码行数:30,代码来源:RadiusSessionHandler.java
示例16: handle
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
RadiusPacket req = request.getRequestPacket();
byte[] bClass = (byte[]) req.getAttributeValue(Attr_Class.TYPE);
if (bClass != null)
{
String sClass = new String(bClass);
if (sClass.startsWith(ClassPrefix))
{
req.removeAttribute(Attr_Class.TYPE);
byte[][] classes = session.getRadiusClass();
if (classes != null)
{
for (byte[] c : classes)
{
RadiusAttribute cattr = AttributeFactory.newAttribute(Attr_Class.TYPE, c, req.isRecyclable());
req.addAttribute(cattr);
}
}
return false;
}
}
session.addLogMessage(request, "Accounting without Class Attribute");
return false;
}
开发者ID:coova,项目名称:jradius,代码行数:32,代码来源:AccountingClassHandler.java
示例17: setupRequest
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的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);
}
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:PEAPAuthenticator.java
示例18: addAttribute
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
public AttributesTableEntry addAttribute(String attributeName) throws RadiusException
{
RadiusAttribute attribute = AttributeFactory.newAttribute(attributeName);
AttributesTableEntry entry = new AttributesTableEntry();
entry.setAttributeName(attributeName);
entry.setValueClass(attribute.getValue().getClass());
entries.add(entry);
return entry;
}
开发者ID:coova,项目名称:jradius,代码行数:10,代码来源:AttributesTableModel.java
示例19: getAddButton
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
/**
* This method initializes addButton
*
* @return javax.swing.JButton
*/
private JButton getAddButton() {
if (addButton == null) {
addButton = new JButton();
addButton.setText("Add");
addButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int rows[] = attributeTree.getSelectionRows();
if (rows != null)
{
for (int i = 0; i < rows.length; i++)
{
TreePath path = attributeTree.getPathForRow(rows[i]);
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getPathComponent(path.getPathCount() - 1);
String attr = (String)node.getUserObject();
try
{
attributesTableModel.addAttribute(AttributeFactory.newAttribute(attr));
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
attributesTableModel.fireTableDataChanged();
}
}
});
}
return addButton;
}
开发者ID:coova,项目名称:jradius,代码行数:36,代码来源:JRadiusSimulator.java
示例20: listAttributes
import net.jradius.packet.attribute.AttributeFactory; //导入依赖的package包/类
/**
* Provides a listing of the names of the missing attributes
* @param sep delimiter to use between attribute names
* @return Returns the list of attribute names as a String
*/
public String listAttributes(String sep)
{
StringBuffer sb = new StringBuffer();
for (Iterator i = missingAttributes.iterator(); i.hasNext(); )
{
Long type = (Long)i.next();
RadiusAttribute a = AttributeFactory.newAttribute(type.longValue(), null, false);
if (a != null) sb.append(sep).append(a.getAttributeName());
}
return sb.substring(sep.length());
}
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:StandardViolatedException.java
注:本文中的net.jradius.packet.attribute.AttributeFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论