package org.jboss.iiop.csiv2;
import org.omg.CORBA.LocalObject;
import org.omg.CORBA.Policy;
import org.omg.CORBA.ORB;
import org.omg.IOP.Codec;
import org.omg.IOP.TaggedComponent;
import org.jboss.iiop.CorbaORBService;
import org.jboss.logging.Logger;
import org.jboss.metadata.IorSecurityConfigMetaData;
public class CSIv2Policy
extends LocalObject
implements Policy
{
static final long serialVersionUID = -8487980590230439410L;
private static final Logger log = Logger.getLogger(CSIv2Policy.class);
public static final int TYPE = 0x87654321;
private TaggedComponent sslTaggedComponent;
private TaggedComponent secTaggedComponent;
public CSIv2Policy(TaggedComponent sslTaggedComponent,
TaggedComponent secTaggedComponent)
{
this.sslTaggedComponent = sslTaggedComponent;
this.secTaggedComponent = secTaggedComponent;
}
public CSIv2Policy(IorSecurityConfigMetaData metadata, Codec codec)
{
if (log.isDebugEnabled())
log.debug(metadata);
try {
ORB orb = ORB.init();
this.sslTaggedComponent =
CSIv2Util.createSSLTaggedComponent(
metadata,
codec,
CorbaORBService.getTheActualSSLPort(),
orb);
this.secTaggedComponent =
CSIv2Util.createSecurityTaggedComponent(
metadata,
codec,
CorbaORBService.getTheActualSSLPort(),
orb);
}
catch (Exception e) {
throw new RuntimeException("Unexpected exception " + e);
}
}
public TaggedComponent getSSLTaggedComponent()
{
return CSIv2Util.createCopy(this.sslTaggedComponent);
}
public TaggedComponent getSecurityTaggedComponent()
{
return CSIv2Util.createCopy(this.secTaggedComponent);
}
public Policy copy()
{
return new CSIv2Policy(getSSLTaggedComponent(),
getSecurityTaggedComponent());
}
public void destroy()
{
this.sslTaggedComponent = null;
this.secTaggedComponent = null;
}
public int policy_type()
{
return TYPE;
}
public String toString()
{
return "CSIv2Policy[" + this.sslTaggedComponent + ", "
+ this.secTaggedComponent + "]";
}
}