Skip to content
Permalink
Browse files
Removing unnecessary isDebugEnabled checks and using isDebugEnabled()…
… instead of the static variable.
  • Loading branch information
Thilina Mahesh Buddhika committed Feb 19, 2011
1 parent 9d2fc77 commit a1618a1cf43dc17e84becd8852325c9deb65f15f
Showing 12 changed files with 132 additions and 268 deletions.
@@ -52,8 +52,7 @@
public class MessageBuilder {

private static Log log = LogFactory.getLog(MessageBuilder.class);
private static boolean doDebug = log.isDebugEnabled();


public void build(MessageContext msgCtx) throws WSSPolicyException,
RampartException, WSSecurityException, AxisFault {

@@ -136,15 +135,11 @@ public void build(MessageContext msgCtx) throws WSSPolicyException,
}

if(rpd.isTransportBinding()) {
if (doDebug) {
log.debug("Building transport binding");
}
log.debug("Building transport binding");
TransportBindingBuilder building = new TransportBindingBuilder();
building.build(rmd);
} else if(rpd.isSymmetricBinding()) {
if (doDebug) {
log.debug("Building SymmetricBinding");
}
log.debug("Building SymmetricBinding");
SymmetricBindingBuilder builder = new SymmetricBindingBuilder();
builder.build(rmd);
} else {
@@ -17,9 +17,15 @@
package org.apache.rampart;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.*;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultSubCode;
import org.apache.axiom.soap.SOAPFaultValue;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.commons.logging.Log;
@@ -32,18 +38,21 @@
import org.apache.rampart.util.Axis2Util;
import org.apache.rampart.util.RampartUtil;
import org.apache.ws.secpolicy.WSSPolicyException;
import org.apache.ws.security.*;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityEngineResult;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.WSUsernameTokenPrincipal;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.saml.SAMLKeyInfo;
import org.apache.ws.security.saml.SAMLUtil;
import org.opensaml.SAMLAssertion;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.saml2.core.Conditions;
import org.opensaml.saml2.core.Subject;
import org.opensaml.saml2.core.SubjectConfirmationData;
import org.opensaml.saml2.core.Conditions;

import javax.xml.namespace.QName;
import java.security.Principal;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Date;
@@ -62,9 +71,7 @@ public Vector process(MessageContext msgCtx) throws WSSPolicyException,
boolean doDebug = log.isDebugEnabled();
boolean dotDebug = tlog.isDebugEnabled();

if(doDebug){
log.debug("Enter process(MessageContext msgCtx)");
}
log.debug("Enter process(MessageContext msgCtx)");

RampartMessageData rmd = new RampartMessageData(msgCtx, false);

@@ -89,10 +96,8 @@ public Vector process(MessageContext msgCtx) throws WSSPolicyException,
//Convert back to llom since the inflow cannot use llom
msgCtx.setEnvelope(env);
Axis2Util.useDOOM(false);
if(doDebug){
log.debug("Return process MessageContext msgCtx)");
}
return null;
log.debug("Return process MessageContext msgCtx)");
return null;
}


@@ -139,10 +144,8 @@ public Vector process(MessageContext msgCtx) throws WSSPolicyException,
if(rpd.isSymmetricBinding()) {
//Here we have to create the CB handler to get the tokens from the
//token storage
if(doDebug){
log.debug("Processing security header using SymetricBinding");
}
results = engine.processSecurityHeader(rmd.getDocument(),
log.debug("Processing security header using SymetricBinding");
results = engine.processSecurityHeader(rmd.getDocument(),
actorValue,
tokenCallbackHandler,
signatureCrypto,
@@ -157,9 +160,7 @@ public Vector process(MessageContext msgCtx) throws WSSPolicyException,
}

} else {
if(doDebug){
log.debug("Processing security header in normal path");
}
log.debug("Processing security header in normal path");
results = engine.processSecurityHeader(rmd.getDocument(),
actorValue,
tokenCallbackHandler,
@@ -322,9 +323,7 @@ public Vector process(MessageContext msgCtx) throws WSSPolicyException,
", PolicyBasedResultsValidattor took " + (t3 - t2));
}

if(doDebug){
log.debug("Return process(MessageContext msgCtx)");
}
log.debug("Return process(MessageContext msgCtx)");
return results;
}

@@ -53,9 +53,7 @@ public class AsymmetricBindingBuilder extends BindingBuilder {

private static Log log = LogFactory.getLog(AsymmetricBindingBuilder.class);
private static Log tlog = LogFactory.getLog(RampartConstants.TIME_LOG);
private static boolean doDebug = log.isDebugEnabled();
private static boolean dotDebug = tlog.isDebugEnabled();


private Token sigToken;

private WSSecSignature sig;
@@ -79,9 +77,7 @@ public class AsymmetricBindingBuilder extends BindingBuilder {
private Element signatureElement;

public void build(RampartMessageData rmd) throws RampartException {
if (doDebug) {
log.debug("AsymmetricBindingBuilder build invoked");
}
log.debug("AsymmetricBindingBuilder build invoked");

RampartPolicyData rpd = rmd.getPolicyData();
if (rpd.isIncludeTimestamp()) {
@@ -94,16 +90,14 @@ public void build(RampartMessageData rmd) throws RampartException {
this.doSignBeforeEncrypt(rmd);
}

if (doDebug) {
log.debug("AsymmetricBindingBuilder build invoked : DONE");
}
log.debug("AsymmetricBindingBuilder build invoked : DONE");
}

private void doEncryptBeforeSig(RampartMessageData rmd)
throws RampartException {

long t0 = 0, t1 = 0, t2 = 0;
if(dotDebug){
if(tlog.isDebugEnabled()){
t0 = System.currentTimeMillis();
}
RampartPolicyData rpd = rmd.getPolicyData();
@@ -198,7 +192,7 @@ private void doEncryptBeforeSig(RampartMessageData rmd)

RampartUtil.appendChildToSecHeader(rmd, refList);

if(dotDebug){
if(tlog.isDebugEnabled()){
t1 = System.currentTimeMillis();
}

@@ -282,7 +276,7 @@ private void doEncryptBeforeSig(RampartMessageData rmd)
}
}

if(dotDebug){
if(tlog.isDebugEnabled()){
t2 = System.currentTimeMillis();
tlog.debug("Encryption took :" + (t1 - t0)
+", Signature tool :" + (t2 - t1) );
@@ -291,7 +285,7 @@ private void doEncryptBeforeSig(RampartMessageData rmd)
// Check for signature protection
if (rpd.isSignatureProtection() && this.mainSigId != null) {
long t3 = 0, t4 = 0;
if(dotDebug){
if(tlog.isDebugEnabled()){
t3 = System.currentTimeMillis();
}
Vector secondEncrParts = new Vector();
@@ -334,7 +328,7 @@ private void doEncryptBeforeSig(RampartMessageData rmd)
throw new RampartException("errorInEncryption", e);
}
}
if(dotDebug){
if(tlog.isDebugEnabled()){
t4 = System.currentTimeMillis();
tlog.debug("Signature protection took :" + (t4 - t3));
}
@@ -370,7 +364,7 @@ private void doSignBeforeEncrypt(RampartMessageData rmd)
this.setInsertionLocation(null);
}

if(dotDebug){
if(tlog.isDebugEnabled()){
t0 = System.currentTimeMillis();
}

@@ -460,7 +454,7 @@ private void doSignBeforeEncrypt(RampartMessageData rmd)
}
}

if(dotDebug){
if(tlog.isDebugEnabled()){
t1 = System.currentTimeMillis();
}

@@ -592,7 +586,7 @@ private void doSignBeforeEncrypt(RampartMessageData rmd)
}
}

if(dotDebug){
if(tlog.isDebugEnabled()){
t2 = System.currentTimeMillis();
tlog.debug("Signature took :" + (t1 - t0)
+", Encryption took :" + (t2 - t1) );
@@ -608,7 +602,7 @@ private void doSupportingSignature(RampartMessageData rmd, Vector supportingSigP
Element supportingSignatureElement;

long t0 = 0, t1 = 0;
if (dotDebug) {
if (tlog.isDebugEnabled()) {
t0 = System.currentTimeMillis();
}

@@ -644,7 +638,7 @@ private void doSupportingSignature(RampartMessageData rmd, Vector supportingSigP

signatureValues.add(supportingSig.getSignatureValue());

if (dotDebug) {
if (tlog.isDebugEnabled()) {
t1 = System.currentTimeMillis();
tlog.debug("Signature took :" + (t1 - t0));
}
@@ -657,7 +651,7 @@ private void doSignature(RampartMessageData rmd) throws RampartException {
Document doc = rmd.getDocument();

long t0 = 0, t1 = 0;
if(dotDebug){
if(tlog.isDebugEnabled()){
t0 = System.currentTimeMillis();
}
if(rmd.isInitiator()) {
@@ -749,7 +743,7 @@ private void doSignature(RampartMessageData rmd) throws RampartException {
signatureValues.add(sig.getSignatureValue());
}

if(dotDebug){
if(tlog.isDebugEnabled()){
t1 = System.currentTimeMillis();
tlog.debug("Signature took :" + (t1 - t0));
}

0 comments on commit a1618a1

Please sign in to comment.