Package org.opensaml.saml.common.xml

# Class SAMLSchemaBuilder

java.lang.Object
org.opensaml.saml.common.xml.SAMLSchemaBuilder

@ThreadSafe public class SAMLSchemaBuilder extends Object
A convenience builder for creating `Schema`s for validating SAML 1.0, 1.1, and 2.0.

Additional schemas may be included in the resulting object by supplying their locations to an injected `SchemaBuilder` object.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`SAMLSchemaBuilder.SAML1Version`
Identifies which SAML 1.x version is in use.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static String[]`
`baseExtSchemas`
Classpath relative location of SAML extension schemas.
`private static String[]`
`baseXMLSchemas`
Classpath relative location of basic XML schemas.
`private Schema`
`cachedSchema`
Cached copy of the schema produced by the builder.
`private org.slf4j.Logger`
`log`
Logger.
`private static String[]`
`saml10Schemas`
Classpath relative location of SAML 1_0 schemas.
`private static String[]`
`saml11Schemas`
Classpath relative location of SAML 1_1 schemas.
`private String[]`
`saml1xSchemas`
Reference to SAML 1.x schemas to apply.
`private static String[]`
`saml20CommonSchemas`
Classpath relative location of the invariant SAML 2.0 schemas.
`private static String[]`
`saml20Schemas`
Classpath relative location of SAML 2_0 schemas.
`private static String[]`
`saml20StrictSchemas`
Classpath relative location of SAML 2_0 schemas with strict string/anyURI types.
`private String[]`
`saml2Schemas`
Reference to SAML 2.0 schemas to apply.
`private SchemaBuilder`
`schemaBuilder`
The builder to use.
`private static String[]`
`soapSchemas`
Classpath relative location of SOAP 1_1 schemas.
`private boolean`
`unresolvedSchemaFatal`
Flag indicating whether the failure to resolve a schema resource should be considered fatal.

## Constructor Summary

Constructors
Constructor
Description
`SAMLSchemaBuilder(SAMLSchemaBuilder.SAML1Version ver)`
Constructor.
`SAMLSchemaBuilder(SAMLSchemaBuilder.SAML1Version ver, boolean strict)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private void`
`addSchemaToBuilder(String source)`
Load the schema from the specified source and add it to the internal `SchemaBuilder`.
`private void`
`configureBuilder()`
Configure the appropriate `SchemaBuilder` with the right set of schemas.
`Schema`
`getSAMLSchema()`
Get a schema that can validate SAML 1.x, 2.0, and all registered extensions.
`void`
`setSchemaBuilder(SchemaBuilder builder)`
Set a custom `SchemaBuilder` to use.
`void`
`setUnresolvedSchemaFatal(boolean flag)`
Set the flag indicating whether the failure to resolve a schema resource should be considered fatal.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### baseXMLSchemas

@Nonnull @NotEmpty private static String[] baseXMLSchemas
Classpath relative location of basic XML schemas.

### soapSchemas

@Nonnull @NotEmpty private static String[] soapSchemas
Classpath relative location of SOAP 1_1 schemas.

### saml10Schemas

@Nonnull @NotEmpty private static String[] saml10Schemas
Classpath relative location of SAML 1_0 schemas.

### saml11Schemas

@Nonnull @NotEmpty private static String[] saml11Schemas
Classpath relative location of SAML 1_1 schemas.

### saml20CommonSchemas

@Nonnull @NotEmpty private static String[] saml20CommonSchemas
Classpath relative location of the invariant SAML 2.0 schemas.

### saml20Schemas

@Nonnull @NotEmpty private static String[] saml20Schemas
Classpath relative location of SAML 2_0 schemas.

### saml20StrictSchemas

@Nonnull @NotEmpty private static String[] saml20StrictSchemas
Classpath relative location of SAML 2_0 schemas with strict string/anyURI types.

### baseExtSchemas

@Nonnull @NotEmpty private static String[] baseExtSchemas
Classpath relative location of SAML extension schemas.

### log

@Nonnull private org.slf4j.Logger log
Logger.

### unresolvedSchemaFatal

private boolean unresolvedSchemaFatal
Flag indicating whether the failure to resolve a schema resource should be considered fatal.

### cachedSchema

@Nullable private Schema cachedSchema
Cached copy of the schema produced by the builder.

### saml1xSchemas

@Nonnull private String[] saml1xSchemas
Reference to SAML 1.x schemas to apply.

### saml2Schemas

@Nonnull private String[] saml2Schemas
Reference to SAML 2.0 schemas to apply.

### schemaBuilder

private SchemaBuilder schemaBuilder
The builder to use.

## Constructor Details

### SAMLSchemaBuilder

public SAMLSchemaBuilder(@Nonnull @ParameterName(name="ver") SAMLSchemaBuilder.SAML1Version ver)
Constructor.

A default `SchemaBuilder` is constructed, and injected with a `ClasspathResolver` for resolving supplementary schemas.

Parameters:
  `ver` - the SAML 1.x version to use

### SAMLSchemaBuilder

public SAMLSchemaBuilder(@Nonnull @ParameterName(name="ver") SAMLSchemaBuilder.SAML1Version ver, @ParameterName(name="strict") boolean strict)
Constructor.

A default `SchemaBuilder` is constructed, and injected with a `ClasspathResolver` for resolving supplementary schemas.

Parameters:
  `ver` - the SAML 1.x version to use
  `strict` - whether to apply modified schemas with strict string and anyURI type definitions
Since:
  4.1.0

## Method Details

### setUnresolvedSchemaFatal

public void setUnresolvedSchemaFatal(boolean flag)
Set the flag indicating whether the failure to resolve a schema resource should be considered fatal.

Default value: true.

Parameters:
  `flag` - true if should be fatal, false if not

### setSchemaBuilder

public void setSchemaBuilder(@Nonnull SchemaBuilder builder)
Set a custom `SchemaBuilder` to use.

Parameters:
  `builder` - SchemaBuilder to use

### getSAMLSchema

@Nonnull public Schema getSAMLSchema() throws SAXException
Get a schema that can validate SAML 1.x, 2.0, and all registered extensions.

Returns:
  schema
Throws:
  `SAXException` - thrown if a schema object cannot be created

### configureBuilder

private void configureBuilder()
Configure the appropriate `SchemaBuilder` with the right set of schemas.

### addSchemaToBuilder

private void addSchemaToBuilder(@Nonnull String source)
Load the schema from the specified source and add it to the internal `SchemaBuilder`.

Parameters:
  `source` - the schema resource path