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:
037: /*
038: * UseKey.java
039: *
040: * Created on February 22, 2006, 6:37 PM
041: *
042: * To change this template, choose Tools | Template Manager
043: * and open the template in the editor.
044: */
045:
046: package com.sun.xml.ws.security.impl.policy;
047:
048: import com.sun.xml.ws.policy.AssertionSet;
049: import com.sun.xml.ws.policy.PolicyAssertion;
050: import com.sun.xml.ws.policy.sourcemodel.AssertionData;
051: import com.sun.xml.ws.security.policy.SecurityAssertionValidator;
052: import java.net.URI;
053: import java.net.URISyntaxException;
054: import java.util.Collection;
055: import java.util.logging.Level;
056: import javax.xml.namespace.QName;
057: import static com.sun.xml.ws.security.impl.policy.Constants.*;
058:
059: /**
060: *
061: * @author Abhijit Das
062: */
063:
064: public class UseKey extends PolicyAssertion implements
065: com.sun.xml.ws.security.policy.UseKey,
066: SecurityAssertionValidator {
067:
068: private static QName sig = new QName("sig");
069: private URI signatureID;
070: private boolean populated = false;
071: private AssertionFitness fitness = AssertionFitness.IS_VALID;
072:
073: /** Creates a new instance of UseKeyIMpl */
074:
075: public UseKey(AssertionData name,
076: Collection<PolicyAssertion> nestedAssertions,
077: AssertionSet nestedAlternative) {
078: super (name, nestedAssertions, nestedAlternative);
079: }
080:
081: public AssertionFitness validate(boolean isServer) {
082: return populate(isServer);
083: }
084:
085: private void populate() {
086: populate(false);
087: }
088:
089: private synchronized AssertionFitness populate(boolean isServer) {
090: if (!populated) {
091: try {
092: this .signatureID = new URI(this .getAttributeValue(sig));
093: } catch (URISyntaxException ex) {
094: logger.log(Level.SEVERE, LogStringsMessages
095: .SP_0102_INVALID_URI_VALUE(this
096: .getAttributeValue(sig)), ex);
097: fitness = AssertionFitness.HAS_INVALID_VALUE;
098: }
099: populated = true;
100: }
101: return fitness;
102: }
103: }
|