-/*
- * Copyright 2009 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
*/
/**
}
Attribute* decode(
- const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL
+ const vector<string>& ids, const XMLObject* xmlObject, const char* assertingParty=nullptr, const char* relyingParty=nullptr
) const;
private:
void extract(const KeyInfo* k, vector<string>& dest) const {
auto_ptr<Credential> cred (getKeyInfoResolver()->resolve(k, Credential::RESOLVE_KEYS));
if (cred.get()) {
- const char* alg = m_keyInfoHashAlg.get();
- if (!alg || !*alg)
- alg = "SHA1";
dest.push_back(string());
- dest.back() = SecurityHelper::getDEREncoding(*cred.get(), m_hash ? alg : NULL);
+ dest.back() = SecurityHelper::getDEREncoding(*cred.get(), m_hash ? m_keyInfoHashAlg.c_str() : nullptr);
if (dest.back().empty())
dest.pop_back();
}
}
bool m_hash;
- auto_ptr_char m_keyInfoHashAlg;
+ string m_keyInfoHashAlg;
KeyInfoResolver* m_keyInfoResolver;
};
};
KeyInfoAttributeDecoder::KeyInfoAttributeDecoder(const DOMElement* e)
- : AttributeDecoder(e),
- m_hash(false),
- m_keyInfoHashAlg(e ? e->getAttributeNS(NULL, keyInfoHashAlg) : NULL),
- m_keyInfoResolver(NULL) {
- const XMLCh* flag = e ? e->getAttributeNS(NULL, _hash) : NULL;
- m_hash = (flag && (*flag == chLatin_t || *flag == chDigit_1));
- e = e ? XMLHelper::getFirstChildElement(e,_KeyInfoResolver) : NULL;
+ : AttributeDecoder(e),
+ m_hash(XMLHelper::getAttrBool(e, false, _hash)),
+ m_keyInfoHashAlg(XMLHelper::getAttrString(e, "SHA1", keyInfoHashAlg)),
+ m_keyInfoResolver(nullptr) {
+ e = XMLHelper::getFirstChildElement(e,_KeyInfoResolver);
if (e) {
- auto_ptr_char t(e->getAttributeNS(NULL, _type));
- if (t.get() && *t.get())
- m_keyInfoResolver = XMLToolingConfig::getConfig().KeyInfoResolverManager.newPlugin(t.get(), e);
- else
+ string t(XMLHelper::getAttrString(e, nullptr, _type));
+ if (t.empty())
throw UnknownExtensionException("<KeyInfoResolver> element found with no type attribute");
+ m_keyInfoResolver = XMLToolingConfig::getConfig().KeyInfoResolverManager.newPlugin(t.c_str(), e);
}
}
if (!xmlObject || !XMLString::equals(saml1::Attribute::LOCAL_NAME, xmlObject->getElementQName().getLocalPart())) {
log.warn("XMLObject type not recognized by KeyInfoAttributeDecoder, no values returned");
- return NULL;
+ return nullptr;
}
auto_ptr<SimpleAttribute> attr(new SimpleAttribute(ids));
}
else {
log.warn("XMLObject type not recognized by KeyInfoAttributeDecoder, no values returned");
- return NULL;
+ return nullptr;
}
}
}
}
- return dest.empty() ? NULL : _decode(attr.release());
+ return dest.empty() ? nullptr : _decode(attr.release());
}