use of org.jboss.jca.common.metadata.ParserException in project wildfly by wildfly.
the class IronJacamarParser method parseCredential.
/**
*
* parse credential tag
*
* @param reader reader
* @return the parse Object
* @throws XMLStreamException in case of error
* @throws ParserException in case of error
* @throws ValidateException in case of error
*/
protected Credential parseCredential(javax.xml.stream.XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException {
String userName = null;
String password = null;
String securityDomain = null;
boolean elytronEnabled = false;
String authenticationContext = null;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY || Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.RECOVER_CREDENTIAL) {
return new CredentialImpl(userName, password, elytronEnabled ? authenticationContext : securityDomain, elytronEnabled, null);
} else if (Credential.Tag.forName(reader.getLocalName()) == Credential.Tag.UNKNOWN) {
throw new ParserException("bundle.unexpectedEndTag(reader.getLocalName())");
}
break;
}
case START_ELEMENT:
{
switch(Credential.Tag.forName(reader.getLocalName())) {
case PASSWORD:
{
password = elementAsString(reader);
break;
}
case USER_NAME:
{
userName = elementAsString(reader);
break;
}
case SECURITY_DOMAIN:
{
securityDomain = elementAsString(reader);
break;
}
case ELYTRON_ENABLED:
{
elytronEnabled = true;
break;
}
case AUTHENTICATION_CONTEXT:
{
authenticationContext = elementAsString(reader);
break;
}
default:
throw new ParserException("bundle.unexpectedElement(reader.getLocalName())");
}
break;
}
}
}
throw new ParserException("bundle.unexpectedEndOfDocument()");
}
use of org.jboss.jca.common.metadata.ParserException in project wildfly by wildfly.
the class IronJacamarParser method parseSecuritySettings.
/**
*
* parse a {@link Security} element
*
* @param reader reader
* @return a {@link Security} object
* @throws XMLStreamException XMLStreamException
* @throws ParserException ParserException
* @throws ValidateException ValidateException
*/
protected Security parseSecuritySettings(javax.xml.stream.XMLStreamReader reader) throws XMLStreamException, ParserException, org.jboss.jca.common.api.validator.ValidateException {
String securityDomain = null;
String securityDomainAndApplication = null;
String authenticationContext = null;
String authenticationContextAndApplication = null;
boolean elytronEnabled = false;
boolean application = org.jboss.jca.common.api.metadata.Defaults.APPLICATION_MANAGED_SECURITY;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (org.jboss.jca.common.api.metadata.ds.DataSource.Tag.forName(reader.getLocalName()) == org.jboss.jca.common.api.metadata.ds.DataSource.Tag.SECURITY) {
return new SecurityImpl(elytronEnabled ? authenticationContext : securityDomain, elytronEnabled ? authenticationContextAndApplication : securityDomainAndApplication, application, elytronEnabled);
} else {
if (Security.Tag.forName(reader.getLocalName()) == Security.Tag.UNKNOWN) {
// FIXME should I use ExtendedStreamReader?
throw new ParserException("unexpectedEndTag(reader.getLocalName())");
}
}
break;
}
case START_ELEMENT:
{
switch(Security.Tag.forName(reader.getLocalName())) {
case SECURITY_DOMAIN:
{
securityDomain = elementAsString(reader);
break;
}
case SECURITY_DOMAIN_AND_APPLICATION:
{
securityDomain = elementAsString(reader);
break;
}
case ELYTRON_ENABLED:
{
elytronEnabled = true;
}
case AUTHENTICATION_CONTEXT:
{
authenticationContext = elementAsString(reader);
break;
}
case AUTHENTICATION_CONTEXT_AND_APPLICATION:
{
authenticationContextAndApplication = elementAsString(reader);
break;
}
case APPLICATION:
{
application = elementAsBoolean(reader);
break;
}
default:
// FIXME same thing here
throw new ParserException("bundle.unexpectedElement(reader.getLocalName())");
}
break;
}
}
}
// FIXME same thing
throw new ParserException("bundle.unexpectedEndOfDocument()");
}
use of org.jboss.jca.common.metadata.ParserException in project wildfly by wildfly.
the class DsXmlParser method parseCredential.
/**
* parse credential tag
*
* @param reader reader
* @return the parse Object
* @throws XMLStreamException in case of error
* @throws ParserException in case of error
* @throws ValidateException in case of error
*/
@Override
protected Credential parseCredential(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException {
String userName = null;
String password = null;
String securityDomain = null;
boolean elytronEnabled = false;
String authenticationContext = null;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY || Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.RECOVER_CREDENTIAL) {
return new CredentialImpl(userName, password, elytronEnabled ? authenticationContext : securityDomain, elytronEnabled, null);
} else {
if (Credential.Tag.forName(reader.getLocalName()) == Credential.Tag.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT:
{
switch(Credential.Tag.forName(reader.getLocalName())) {
case PASSWORD:
{
password = elementAsString(reader);
if (propertyResolver != null && password != null) {
String resolvedPassword = propertyResolver.resolve(password);
if (resolvedPassword != null)
password = resolvedPassword;
}
break;
}
case USER_NAME:
{
userName = elementAsString(reader);
break;
}
case SECURITY_DOMAIN:
{
securityDomain = elementAsString(reader);
break;
}
case ELYTRON_ENABLED:
{
Boolean value = elementAsBoolean(reader);
elytronEnabled = value == null ? true : value;
break;
}
case AUTHENTICATION_CONTEXT:
{
authenticationContext = elementAsString(reader);
break;
}
default:
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
break;
}
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}
use of org.jboss.jca.common.metadata.ParserException in project wildfly by wildfly.
the class DsXmlParser method parseDsSecurity.
/**
* Parse security
*
* @param reader The reader
* @return The result
* @throws javax.xml.stream.XMLStreamException
* XMLStreamException
* @throws org.jboss.jca.common.metadata.ParserException
* ParserException
* @throws org.jboss.jca.common.api.validator.ValidateException
* ValidateException
*/
@Override
protected DsSecurity parseDsSecurity(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException {
String userName = null;
String password = null;
String securityDomain = null;
boolean elytronEnabled = false;
String authenticationContext = null;
Extension reauthPlugin = null;
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY) {
return new DsSecurityImpl(userName, password, elytronEnabled ? authenticationContext : securityDomain, elytronEnabled, null, reauthPlugin);
} else {
if (DsSecurity.Tag.forName(reader.getLocalName()) == DsSecurity.Tag.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT:
{
DsSecurity.Tag tag = DsSecurity.Tag.forName(reader.getLocalName());
switch(tag) {
case PASSWORD:
{
password = elementAsString(reader);
boolean resolved = false;
if (propertyReplacer != null && password != null && password.trim().length() != 0) {
String resolvedPassword = propertyReplacer.replaceProperties(password);
if (resolvedPassword != null) {
password = resolvedPassword;
resolved = true;
}
}
// who learned to use that behavior, pass any unresolved password in to the PropertyResolver
if (!resolved && propertyResolver != null && password != null && password.trim().length() != 0) {
String resolvedPassword = propertyResolver.resolve(password);
if (resolvedPassword != null) {
password = resolvedPassword;
}
}
break;
}
case USER_NAME:
{
userName = elementAsString(reader);
break;
}
case SECURITY_DOMAIN:
{
securityDomain = elementAsString(reader);
break;
}
case ELYTRON_ENABLED:
{
Boolean value = elementAsBoolean(reader);
elytronEnabled = value == null ? true : value;
break;
}
case AUTHENTICATION_CONTEXT:
{
authenticationContext = elementAsString(reader);
break;
}
case REAUTH_PLUGIN:
{
reauthPlugin = parseExtension(reader, tag.getLocalName());
break;
}
default:
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
break;
}
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}
Aggregations