/*
The UCT Policy Control Framework
Copyright (C) 2006 - University of Cape Town
Richard Good <rgood@crg.ee.uct.ac.za>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** March 2008*/
package pcrf;
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.apache.xml.serialize.XMLSerializer;
import org.apache.xml.serialize.OutputFormat;
/**
* xcap:
*
* This class defines the XCAP methods for retrieving and modifying policies stored on an XDMS server
* It also defines methods for parsing and reading the XML document
* @author Richard Good
*/public class xcap
{
String policy_db = "";
static private Document dom = null;
String username = "";
String password = "";
int remote_xcap_server; //zero if local one if remote
/**
* Constructor for xcap
* -initialises variables
* @param args
*/
public xcap(String policy_db, String policy, String username, String password, int remote_xcap_server) throws IOException
{
this.username = username;
this.password = password;
this.remote_xcap_server = remote_xcap_server;
/**TO DO fix OpenXCAP to allow different Applications*/
if(remote_xcap_server == 1)
{
this.policy_db = policy_db + "resource-lists/users/" + username + "/resource-lists.xml";
}
else
{
this.policy_db = policy_db + policy + ".xml";
}
parseXML(getXML());
}
/**
* This converts an XML Document into a String used to convey the doc via HTTP
* @param dom The XML document to be converted to a string
* @return xmlStr the String representation of the xml doc
**/
private String XMLDocToString(Document dom)
{
String xmlStr = null;
StringWriter strWriter = null;
XMLSerializer probeMsgSerializer = null;
OutputFormat outFormat = new OutputFormat();
try
{
probeMsgSerializer = new XMLSerializer();
strWriter = new StringWriter();
outFormat = new OutputFormat();
// Setup format settings
outFormat.setVersion("1.0");
outFormat.setEncoding("UTF-8");
outFormat.setIndenting(true);
outFormat.setIndent(4);
// Define a Writer
probeMsgSerializer.setOutputCharStream(strWriter);
// Apply the format settings
probeMsgSerializer.setOutputFormat(outFormat);
// Serialize XML Document
probeMsgSerializer.serialize(dom);
xmlStr = strWriter.toString();
strWriter.close();
}
catch (IOException ioEx)
{
System.out.println("Error " + ioEx);
}
return xmlStr;
}
/**
* This creates the XML parser
**/
private void parseXML(InputStream xmlDoc)
{
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
dom = db.parse(xmlDoc);
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
}
}
/**
* This receives a list of codecs - checks the domain policies and returns whether they are acceptable or not
* @param codecs vector of requested requested codecs
* @return 1 if authorised 0 if not
*/
public int checkCodecs(Vector codecs) throws IOException
{
//fetch and parse the policy XML document
parseXML(getXML());
//get the root elememt
Element docEle = dom.getDocumentElement();
//get all authorised codec id's in a vector
Vector authCodecs = new Vector();
NodeList nl = docEle.getElementsByTagName("rule");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the authorised codec rule
Element rule = (Element)nl.item(i);
String id = rule.getAttribute("id");
if(id.equals("codec authorisation"))
{
NodeList nl3 = rule.getElementsByTagName("conditions");
if(nl3 != null && nl3.getLength() > 0)
{
Element conditions = (Element)nl3.item(0);
NodeList nl1 = conditions.getElementsByTagName("codec_id");
if(nl1 != null && nl1.getLength() > 0)
{
Element codec_id = (Element)nl1.item(0);
NodeList nl2 = codec_id.getElementsByTagName("id");
if(nl2 != null && nl2.getLength() > 0)
{
for(int a = 0 ; a < nl2.getLength();a++)
{
Element ID = (Element)nl2.item(a);
authCodecs.add(ID.getFirstChild().getNodeValue());
}
}
}
}
}
}
}
//check that all requested codecs are authorised
int authorised = 1;
int supported = 0;
for ( int b = 0; b < codecs.size(); b++)
{
supported = 0;
for (int c = 0; c < authCodecs.size(); c++)
{
if(Integer.valueOf(codecs.get(b).toString()).intValue() == Integer.valueOf(authCodecs.get(c).toString()).intValue())
{
supported = 1;
}
}
//Note this is to support dynamic codecs, see RFC 3551
if (supported == 0 && (Integer.valueOf(codecs.get(b).toString()).intValue() < 96 || Integer.valueOf(codecs.get(b).toString()).intValue() > 127))
{
authorised = 0;
}
}
//1 if authorised 0 if not
return authorised;
}
/**
* This receives the orig and term domains
* It checks that both domains are allowed
* @param String orig originating domain
* @param String term terminating domain
* @return 1 if authorised 0 if not
*/
public int checkDomain(String orig, String term) throws IOException
{
//fetch and parse the policy XML document
parseXML(getXML());
//get the root elememt
Element docEle = dom.getDocumentElement();
int orig_authorised = 0;
int term_authorised = 0;
Vector domains = new Vector();
NodeList nl = docEle.getElementsByTagName("rule");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the authorised codec rule
Element rule = (Element)nl.item(i);
String id = rule.getAttribute("id");
if(id.equals("domain authorisation"))
{
NodeList nl3 = rule.getElementsByTagName("conditions");
if(nl3 != null && nl3.getLength() > 0)
{
Element conditions = (Element)nl3.item(0);
NodeList nl1 = conditions.getElementsByTagName("domain");
if(nl1 != null && nl1.getLength() > 0)
{
Element domain = (Element)nl1.item(0);
NodeList nl2 = domain.getElementsByTagName("address");
if(nl2 != null && nl2.getLength() > 0)
{
for(int a = 0 ; a < nl2.getLength();a++)
{
Element address = (Element)nl
没有合适的资源?快使用搜索试试~ 我知道了~
IMS PCRF开源代码
5星 · 超过95%的资源 需积分: 13 52 下载量 194 浏览量
2014-12-04
20:30:22
上传
评论 1
收藏 7.95MB GZ 举报
温馨提示
共197个文件
jsp:61个
java:60个
jar:22个
UCT PCF Policy Control Framework UCT PCF是由南非开普敦大学开发 OpenPCRF openEPC 参考论文:IMS策略与计费控制的分析与设计
资源推荐
资源详情
资源评论
收起资源包目录
IMS PCRF开源代码 (197个子文件)
all-wcprops 613B
BE_dscp_config 928B
pcscf.qos.cfg 16KB
pcscf.qos.rtp.cfg 16KB
compile 55B
compile 55B
EF_dscp_config 919B
entries 941B
filter_rules 1KB
flush_iptables 414B
format 2B
uct_logo.gif 6KB
xalan.jar 1.23MB
xerces.jar 937KB
xercesImpl.jar 906KB
xercesImpl.jar 906KB
xerces-2.4.0.jar 875KB
xerces-2.4.0.jar 875KB
standard-1.0.jar 487KB
mysql-connector-java-3.1.13-bin.jar 446KB
log4j-1.2.13.jar 350KB
log4j-1.2.13.jar 350KB
commons-httpclient.jar 271KB
commons-httpclient.jar 271KB
junit.jar 118KB
junit.jar 118KB
bsf.jar 111KB
servlet-api.jar 95KB
jsp-api.jar 49KB
commons-codec-1.3.jar 46KB
commons-codec-1.3.jar 46KB
commons-logging.jar 37KB
commons-logging.jar 37KB
xsl-1.0.1.jar 13KB
xcap.java 51KB
DecisionEngine.java 32KB
StateMachine.java 25KB
DiameterClientTest.java 24KB
DiameterPeer.java 24KB
AARCommandListener.java 16KB
DomainPolicyProcessor.java 15KB
Constants.java 15KB
RARCommandListener.java 13KB
Communicator.java 13KB
AVP.java 12KB
xcapTest.java 11KB
LinuxRouter.java 11KB
Codec.java 9KB
CCRCommandListener.java 9KB
DataCollectorThread.java 8KB
DiameterMessage.java 7KB
PeerManager.java 6KB
PCRF.java 6KB
PCEF.java 6KB
TransactionWorker.java 6KB
STRCommandListener.java 6KB
DiameterPeerTest.java 5KB
Acceptor.java 5KB
CodecTest.java 5KB
DiameterServerTest.java 4KB
Peer.java 4KB
DiameterException.java 4KB
DiameterException.java 4KB
DiameterBaseException.java 4KB
DiameterBaseException.java 4KB
pcrfDiameterStack.java 4KB
PermanentFailure.java 3KB
PermanentFailure.java 3KB
DiameterWorker.java 3KB
CommandListener.java 3KB
CommandListener.java 3KB
ASRCommandListener.java 3KB
RARCommandListener.java 3KB
DiameterTransaction.java 3KB
GxCommandListener.java 2KB
GxCommandListener.java 2KB
RxCommandListener.java 2KB
DiameterResultCode.java 2KB
DiameterResultCode.java 2KB
MissingAVP.java 2KB
MissingAVP.java 2KB
DiameterCEA.java 2KB
pcefDiameterStack.java 2KB
DiameterCER.java 2KB
TransactionListener.java 2KB
Application.java 2KB
DiameterDWA.java 2KB
DiameterTask.java 2KB
DiameterDPA.java 2KB
DiameterDPR.java 2KB
DiameterDWR.java 2KB
DiameterMessageDecodeException.java 2KB
AVPDecodeException.java 2KB
EventListener.java 2KB
jammie.jpg 210KB
header.jpg 39KB
copyright.jpg 24KB
line.jpg 2KB
add_domains_action.jsp 15KB
add_peps_action.jsp 14KB
共 197 条
- 1
- 2
资源评论
- SaviourJLF2017-05-13新接触的内容。找些资料来看
- xzydaili2016-01-27下载了,还没用,期待能用,正好在学习pcrf
- 快乐的程序猿-哼哼哼2016-12-09下载了,还没用呢
DawsonSally
- 粉丝: 70
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
- 基于Java和LCN分布式事务框架的设计源码 - tx-lcn
- 基于Java和JavaScript的茶叶评级管理系统设计源码 - tea
- IMG_5680.JPG
- IMG_0437.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功