Fields Summary |
---|
protected TokenProcessor | tokenProcessor |
protected SignatureTargetCreator | stc |
protected EncryptionTargetCreator | etc |
protected com.sun.xml.ws.security.policy.Binding | binding |
protected XWSSPolicyContainer | policyContainer |
protected com.sun.xml.wss.impl.policy.mls.SignaturePolicy | signaturePolicy |
protected com.sun.xml.wss.impl.policy.mls.EncryptionPolicy | encryptionPolicy |
protected com.sun.xml.ws.security.policy.SupportingTokens | st |
protected IntegrityAssertionProcessor | iAP |
protected EncryptionAssertionProcessor | eAP |
protected ArrayList | spList |
protected ArrayList | epList |
protected com.sun.xml.ws.security.policy.SignedParts | emptySP |
protected boolean | buildSP |
protected boolean | buildEP |
protected PolicyID | pid |
Methods Summary |
---|
protected void | addTargets()
if(binding.getProtectionOrder() == Binding.SIGN_ENCRYPT){
if(spList != null){
populateSignaturePolicy();
}
if(epList != null){
populateEncryptionPolicy();
}
}else{
if(epList != null){
populateEncryptionPolicy();
}
if(spList != null){
populateSignaturePolicy();
}
}
|
protected void | addToPrimarySignature(com.sun.xml.wss.impl.policy.mls.WSSPolicy policy, com.sun.xml.ws.security.policy.Token token)
//no-op
|
protected void | collectSignaturePolicies(com.sun.xml.ws.security.policy.Token token)
if(buildSP){
createSupportingSignature(token);
}
|
protected void | correctSAMLBinding(com.sun.xml.wss.impl.policy.mls.WSSPolicy policy)
//no-op
|
protected void | createSupportingSignature(com.sun.xml.ws.security.policy.Token token)
SignaturePolicy sp = new SignaturePolicy();
sp.setUUID(pid.generateID());
tokenProcessor.addKeyBinding(sp, token,true);
if(binding.getTokenProtection()){
protectToken((WSSPolicy) sp.getKeyBinding(), sp);
}
SignaturePolicy.FeatureBinding spFB = (com.sun.xml.wss.impl.policy.mls.SignaturePolicy.FeatureBinding)sp.getFeatureBinding();
//spFB.setCanonicalizationAlgorithm(CanonicalizationMethod.EXCLUSIVE);
AlgorithmSuite as = null;
as = st.getAlgorithmSuite();
if( as == null){
as = binding.getAlgorithmSuite();
}
SecurityPolicyUtil.setCanonicalizationMethod(spFB, as);
// sp.setKeyBinding(policy);
getSPList().add(sp);
endorseSignature(sp);
|
protected void | encryptToken(com.sun.xml.ws.security.policy.Token token)
if ( token.getTokenId()!= null ) {
EncryptionPolicy.FeatureBinding fb =(EncryptionPolicy.FeatureBinding) encryptionPolicy.getFeatureBinding();
EncryptionTarget et = etc.newURIEncryptionTarget(token.getTokenId());
fb.addTargetBinding(et);
}
|
protected void | endorseSignature(com.sun.xml.wss.impl.policy.mls.SignaturePolicy sp)
//no-op
|
protected java.util.ArrayList | getEPList()
if(epList == null){
epList = new ArrayList<EncryptionPolicy>();
}
return epList;
|
protected com.sun.xml.ws.security.policy.SignedParts | getEmptySignedParts(java.util.Iterator itr)
while(itr.hasNext()){
Target target = (Target)itr.next();
if(PolicyUtil.isSignedParts((PolicyAssertion)target)){
if(SecurityPolicyUtil.isSignedPartsEmpty((SignedParts) target)){
return (SignedParts) target;
}
}
}
return null;
|
protected java.util.ArrayList | getSPList()
if(spList == null){
spList = new ArrayList<SignaturePolicy>();
}
return spList;
|
protected void | populateEncryptionPolicy()
for(EncryptionPolicy ep :epList){
EncryptionPolicy.FeatureBinding epFB = (EncryptionPolicy.FeatureBinding)ep.getFeatureBinding();
Iterator<EncryptedElements> itr = st.getEncryptedElements();
while(itr.hasNext()){
EncryptedElements target = itr.next();
eAP.process(target,epFB);
}
Iterator<EncryptedParts> epr = st.getEncryptedParts();
while(epr.hasNext()){
EncryptedParts target = epr.next();
eAP.process(target,epFB);
}
policyContainer.insert(ep);
}
|
protected void | populateSignaturePolicy()
for(SignaturePolicy sp : spList){
SignaturePolicy.FeatureBinding spFB = (SignaturePolicy.FeatureBinding)sp.getFeatureBinding();
if(emptySP != null){
iAP.process(emptySP,spFB);
}else{
Iterator<SignedParts>itr = st.getSignedParts();
while(itr.hasNext()){
SignedParts target = itr.next();
iAP.process(target,spFB);
}
}
Iterator<SignedElements> itr = st.getSignedElements();
while(itr.hasNext()){
SignedElements target = itr.next();
iAP.process(target,spFB);
}
policyContainer.insert(sp);
}
|
public void | process()
Iterator tokens = st.getTokens();
if(st.getEncryptedParts().hasNext() || st.getEncryptedElements().hasNext()){
buildEP = true;
}
if(st.getSignedElements().hasNext() || st.getSignedParts().hasNext()){
buildSP = true;
}
while(tokens.hasNext()){
Token token = (Token) tokens.next();
WSSPolicy policy = tokenProcessor.getWSSToken(token);
if ( policy.getUUID() != null ) {
addToPrimarySignature(policy,token);
if(PolicyUtil.isUsernameToken((PolicyAssertion) token) && ((UserNameToken)token).hasPassword()){
encryptToken(token);
}
if(PolicyUtil.isSamlToken((PolicyAssertion)token)){
correctSAMLBinding(policy);
}
collectSignaturePolicies(token);
if(buildEP){
EncryptionPolicy ep = new EncryptionPolicy();
ep.setKeyBinding(policy);
getEPList().add(ep);
}
}
//TODO:: Add token to MessagePolicy;
AuthenticationTokenPolicy atp = new AuthenticationTokenPolicy();
atp.setFeatureBinding(policy);
policyContainer.insert(atp);
//TODO: Take care of targets.
addTargets();
}
|
protected void | protectToken(com.sun.xml.wss.impl.policy.mls.WSSPolicy token, com.sun.xml.wss.impl.policy.mls.SignaturePolicy sp)
String uid = token.getUUID();
if ( uid != null ) {
SignatureTargetCreator stc = iAP.getTargetCreator();
SignatureTarget st = stc.newURISignatureTarget(uid);
SecurityPolicyUtil.setName(st, token);
stc.addSTRTransform(st);
SignaturePolicy.FeatureBinding fb = (com.sun.xml.wss.impl.policy.mls.SignaturePolicy.FeatureBinding) sp.getFeatureBinding();
fb.addTargetBinding(st);
}
|