001: /*
002: * $Id: DynamicApplicationContext.java,v 1.3 2006/09/29 12:04:53 kumarjayanti Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025: */
026:
027: package com.sun.xml.wss.impl.configuration;
028:
029: import java.util.HashMap;
030:
031: import com.sun.xml.wss.impl.policy.StaticPolicyContext;
032: import com.sun.xml.wss.impl.policy.DynamicPolicyContext;
033:
034: /**
035: * Represents a concrete SecurityPolicy identifier context resolved at runtime,
036: * An XWS-Security <code>DynamicPolicyCallback</code> is passed an instance of
037: * a <code>DynamicApplicationContext</code>. A callback Handler handling
038: * DynamicPolicyCallback can make use of information in this context
039: * to dynamically determine the Security policy applicable for a request/response
040: */
041: public class DynamicApplicationContext extends DynamicPolicyContext {
042:
043: private String messageIdentifier = "";
044: private boolean inBoundMessage = false;
045:
046: private StaticPolicyContext context = null;
047:
048: /**
049: * Create an empty DynamicApplicationContext
050: */
051: public DynamicApplicationContext() {
052: }
053:
054: /**
055: * Create a DynamicApplicationContext with an associated
056: * StaticPolicyContext <code>context</code>
057: * @param context the associated StaticPolicyContext
058: */
059: public DynamicApplicationContext(StaticPolicyContext context) {
060: this .context = context;
061: }
062:
063: /**
064: * Set the messageIdentifier for this Message associated with this context
065: * @param messageIdentifier
066: */
067: public void setMessageIdentifier(String messageIdentifier) {
068: this .messageIdentifier = messageIdentifier;
069: }
070:
071: /**
072: * @return messageIdentifier for the Message associated with this context
073: */
074: public String getMessageIdentifier() {
075: return this .messageIdentifier;
076: }
077:
078: /**
079: * Set the Message direction (inbound/outbound) to which this context corresponds to
080: * @param inBound flag indicating the direction of the message
081: */
082: public void inBoundMessage(boolean inBound) {
083: this .inBoundMessage = inBound;
084: }
085:
086: /**
087: * @return true if the context is for an inbound message
088: */
089: public boolean inBoundMessage() {
090: return this .inBoundMessage;
091: }
092:
093: /**
094: * set the associated StaticPolicyContext for this context
095: * @param context StaticPolicyContext
096: */
097: public void setStaticPolicyContext(StaticPolicyContext context) {
098: this .context = context;
099: }
100:
101: /**
102: * @return the associated StaticPolicContext if any, null otherwise
103: */
104: public StaticPolicyContext getStaticPolicyContext() {
105: return context;
106: }
107:
108: /**
109: * @return HashMap of runtime properties in this context
110: */
111: public HashMap getRuntimeProperties() {
112: return properties;
113: }
114:
115: /**
116: * equals operator
117: * @param ctx DynamicApplicationContext with which to compare for equality
118: * @return true if ctx is equal to this DynamicApplicationContext
119: */
120: public boolean equals(DynamicApplicationContext ctx) {
121: boolean b1 = getStaticPolicyContext().equals(
122: ctx.getStaticPolicyContext());
123: if (!b1)
124: return false;
125:
126: boolean b2 = (messageIdentifier.equalsIgnoreCase(ctx
127: .getMessageIdentifier()) && inBoundMessage == ctx.inBoundMessage);
128: if (!b2)
129: return false;
130:
131: return true;
132: }
133: }
|