001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.xml.ws.security.impl.policy;
037:
038: import com.sun.xml.ws.policy.PolicyAssertion;
039: import com.sun.xml.ws.policy.sourcemodel.AssertionData;
040: import java.util.Iterator;
041: import com.sun.xml.ws.policy.AssertionSet;
042: import com.sun.xml.ws.policy.PolicyAssertion;
043: import com.sun.xml.ws.security.policy.SecurityAssertionValidator;
044: import java.util.Collection;
045: import javax.xml.namespace.QName;
046:
047: /**
048: *
049: * @author K.Venugopal@sun.com
050: */
051: public class ValidatorConfiguration extends PolicyAssertion implements
052: com.sun.xml.ws.security.policy.ValidatorConfiguration,
053: SecurityAssertionValidator {
054:
055: private boolean populated = false;
056: private Iterator<PolicyAssertion> ast = null;
057: private static QName cmaxClockSkew = new QName(
058: Constants.SUN_WSS_SECURITY_CLIENT_POLICY_NS, "maxClockSkew");
059: private static QName smaxClockSkew = new QName(
060: Constants.SUN_WSS_SECURITY_SERVER_POLICY_NS, "maxClockSkew");
061: private static QName ctimestampFreshnessLimit = new QName(
062: Constants.SUN_WSS_SECURITY_CLIENT_POLICY_NS,
063: "timestampFreshnessLimit");
064: private static QName stimestampFreshnessLimit = new QName(
065: Constants.SUN_WSS_SECURITY_SERVER_POLICY_NS,
066: "timestampFreshnessLimit");
067: private static QName smaxNonceAge = new QName(
068: Constants.SUN_WSS_SECURITY_SERVER_POLICY_NS, "maxNonceAge");
069: private static QName crevocationEnabled = new QName(
070: Constants.SUN_WSS_SECURITY_CLIENT_POLICY_NS,
071: "revocationEnabled");
072: private static QName srevocationEnabled = new QName(
073: Constants.SUN_WSS_SECURITY_SERVER_POLICY_NS,
074: "revocationEnabled");
075:
076: private AssertionFitness fitness = AssertionFitness.IS_VALID;
077:
078: /** Creates a new instance of ValidatorConfiguration */
079: public ValidatorConfiguration() {
080: }
081:
082: public ValidatorConfiguration(AssertionData name,
083: Collection<PolicyAssertion> nestedAssertions,
084: AssertionSet nestedAlternative) {
085: super (name, nestedAssertions, nestedAlternative);
086: }
087:
088: public Iterator<? extends PolicyAssertion> getValidators() {
089: populate();
090: return ast;
091: }
092:
093: public AssertionFitness validate(boolean isServer) {
094: return populate(isServer);
095: }
096:
097: private void populate() {
098: populate(false);
099: }
100:
101: private synchronized AssertionFitness populate(boolean isServer) {
102: if (!populated) {
103: this .ast = this .getNestedAssertionsIterator();
104: populated = true;
105: }
106: return fitness;
107: }
108:
109: public String getMaxClockSkew() {
110: if (this .getAttributes().containsKey(cmaxClockSkew)) {
111: return this .getAttributeValue(cmaxClockSkew);
112: } else if (this .getAttributes().containsKey(smaxClockSkew)) {
113: return this .getAttributeValue(smaxClockSkew);
114: }
115: return null;
116: }
117:
118: public String getTimestampFreshnessLimit() {
119: if (this .getAttributes().containsKey(ctimestampFreshnessLimit)) {
120: return this .getAttributeValue(ctimestampFreshnessLimit);
121: } else if (this .getAttributes().containsKey(
122: stimestampFreshnessLimit)) {
123: return this .getAttributeValue(stimestampFreshnessLimit);
124: }
125: return null;
126: }
127:
128: public String getMaxNonceAge() {
129: if (this .getAttributes().containsKey(smaxNonceAge)) {
130: return this .getAttributeValue(smaxNonceAge);
131: }
132: return null;
133: }
134:
135: public String getRevocationEnabled() {
136: if (this.getAttributes().containsKey(crevocationEnabled)) {
137: return this.getAttributeValue(crevocationEnabled);
138: } else if (this.getAttributes().containsKey(srevocationEnabled)) {
139: return this.getAttributeValue(srevocationEnabled);
140: }
141: return null;
142: }
143: }
|