Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
4cb6bc98
Commit
4cb6bc98
authored
Apr 21, 2016
by
michael.simon
Browse files
Need new nodeToString impl
parent
f224e938
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/bootstrap/ApplicationBootstrap.java
View file @
4cb6bc98
...
@@ -19,13 +19,8 @@ import javax.ejb.Singleton;
...
@@ -19,13 +19,8 @@ import javax.ejb.Singleton;
import
javax.ejb.Startup
;
import
javax.ejb.Startup
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
net.shibboleth.utilities.java.support.xml.BasicParserPool
;
import
net.shibboleth.utilities.java.support.xml.ParserPool
;
import
org.opensaml.core.config.ConfigurationService
;
import
org.opensaml.core.config.InitializationException
;
import
org.opensaml.core.config.InitializationException
;
import
org.opensaml.core.config.InitializationService
;
import
org.opensaml.core.config.InitializationService
;
import
org.opensaml.core.xml.config.XMLObjectProviderRegistry
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
edu.kit.scc.webreg.drools.BpmProcessService
;
import
edu.kit.scc.webreg.drools.BpmProcessService
;
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/SamlHelper.java
View file @
4cb6bc98
...
@@ -12,11 +12,11 @@ package edu.kit.scc.webreg.service.saml;
...
@@ -12,11 +12,11 @@ package edu.kit.scc.webreg.service.saml;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.enterprise.context.ApplicationScoped
;
...
@@ -25,16 +25,13 @@ import javax.inject.Named;
...
@@ -25,16 +25,13 @@ import javax.inject.Named;
import
javax.xml.namespace.QName
;
import
javax.xml.namespace.QName
;
import
net.shibboleth.utilities.java.support.xml.BasicParserPool
;
import
net.shibboleth.utilities.java.support.xml.BasicParserPool
;
import
net.shibboleth.utilities.java.support.xml.ParserPool
;
import
net.shibboleth.utilities.java.support.xml.XMLParserException
;
import
net.shibboleth.utilities.java.support.xml.XMLParserException
;
import
org.opensaml.core.config.Configuration
;
import
org.opensaml.core.config.ConfigurationService
;
import
org.opensaml.core.config.ConfigurationService
;
import
org.opensaml.core.xml.XMLObject
;
import
org.opensaml.core.xml.XMLObject
;
import
org.opensaml.core.xml.XMLObjectBuilder
;
import
org.opensaml.core.xml.XMLObjectBuilder
;
import
org.opensaml.core.xml.XMLObjectBuilderFactory
;
import
org.opensaml.core.xml.XMLObjectBuilderFactory
;
import
org.opensaml.core.xml.config.XMLObjectProviderRegistry
;
import
org.opensaml.core.xml.config.XMLObjectProviderRegistry
;
import
org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport
;
import
org.opensaml.core.xml.io.Marshaller
;
import
org.opensaml.core.xml.io.Marshaller
;
import
org.opensaml.core.xml.io.MarshallerFactory
;
import
org.opensaml.core.xml.io.MarshallerFactory
;
import
org.opensaml.core.xml.io.MarshallingException
;
import
org.opensaml.core.xml.io.MarshallingException
;
...
@@ -63,7 +60,8 @@ public class SamlHelper implements Serializable {
...
@@ -63,7 +60,8 @@ public class SamlHelper implements Serializable {
@Inject
@Inject
private
Logger
logger
;
private
Logger
logger
;
protected
SecureRandomIdentifierGenerator
randomIdGen
;
@Inject
private
XMLHelper
xmlHelper
;
protected
MarshallerFactory
marshallerFactory
;
protected
MarshallerFactory
marshallerFactory
;
protected
UnmarshallerFactory
unmarshallerFactory
;
protected
UnmarshallerFactory
unmarshallerFactory
;
...
@@ -72,12 +70,6 @@ public class SamlHelper implements Serializable {
...
@@ -72,12 +70,6 @@ public class SamlHelper implements Serializable {
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
try
{
randomIdGen
=
new
SecureRandomIdentifierGenerator
();
}
catch
(
NoSuchAlgorithmException
e
)
{
logger
.
error
(
"No SecureRandomIdentifierGenerator available"
,
e
);
}
basicParserPool
=
new
BasicParserPool
();
basicParserPool
=
new
BasicParserPool
();
basicParserPool
.
setNamespaceAware
(
true
);
basicParserPool
.
setNamespaceAware
(
true
);
...
@@ -96,7 +88,7 @@ public class SamlHelper implements Serializable {
...
@@ -96,7 +88,7 @@ public class SamlHelper implements Serializable {
}
}
public
String
getRandomId
()
{
public
String
getRandomId
()
{
return
random
IdGen
.
generateIdentifier
();
return
UUID
.
random
UUID
().
toString
();
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -114,7 +106,7 @@ public class SamlHelper implements Serializable {
...
@@ -114,7 +106,7 @@ public class SamlHelper implements Serializable {
public
<
T
extends
XMLObject
>
String
marshal
(
T
t
)
{
public
<
T
extends
XMLObject
>
String
marshal
(
T
t
)
{
try
{
try
{
Element
element
=
toXmlElement
(
t
);
Element
element
=
toXmlElement
(
t
);
return
XML
Helper
.
nodeToString
(
element
);
return
xml
Helper
.
nodeToString
(
element
);
}
catch
(
MarshallingException
e
)
{
}
catch
(
MarshallingException
e
)
{
logger
.
error
(
"No Marshalling possible"
,
e
);
logger
.
error
(
"No Marshalling possible"
,
e
);
return
null
;
return
null
;
...
@@ -124,7 +116,7 @@ public class SamlHelper implements Serializable {
...
@@ -124,7 +116,7 @@ public class SamlHelper implements Serializable {
public
<
T
extends
XMLObject
>
String
prettyPrint
(
T
t
)
{
public
<
T
extends
XMLObject
>
String
prettyPrint
(
T
t
)
{
try
{
try
{
Element
element
=
toXmlElement
(
t
);
Element
element
=
toXmlElement
(
t
);
return
XML
Helper
.
prettyPrintXML
(
element
);
return
xml
Helper
.
prettyPrintXML
(
element
);
}
catch
(
MarshallingException
e
)
{
}
catch
(
MarshallingException
e
)
{
logger
.
error
(
"No Marshalling possible"
,
e
);
logger
.
error
(
"No Marshalling possible"
,
e
);
return
null
;
return
null
;
...
@@ -205,10 +197,6 @@ public class SamlHelper implements Serializable {
...
@@ -205,10 +197,6 @@ public class SamlHelper implements Serializable {
return
attrMap
;
return
attrMap
;
}
}
public
SecureRandomIdentifierGenerator
getRandomIdGen
()
{
return
randomIdGen
;
}
public
MarshallerFactory
getMarshallerFactory
()
{
public
MarshallerFactory
getMarshallerFactory
()
{
return
marshallerFactory
;
return
marshallerFactory
;
}
}
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/XMLHelper.java
0 → 100644
View file @
4cb6bc98
package
edu.kit.scc.webreg.service.saml
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.inject.Named
;
import
org.w3c.dom.DOMConfiguration
;
import
org.w3c.dom.DOMImplementation
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Node
;
import
org.w3c.dom.ls.DOMImplementationLS
;
import
org.w3c.dom.ls.LSOutput
;
import
org.w3c.dom.ls.LSSerializer
;
import
org.w3c.dom.ls.LSSerializerFilter
;
@Named
(
"xmlHelper"
)
@ApplicationScoped
public
class
XMLHelper
{
public
String
nodeToString
(
Node
node
)
{
StringWriter
writer
=
new
StringWriter
();
writeNode
(
node
,
writer
);
return
writer
.
toString
();
}
public
String
prettyPrintXML
(
Node
node
)
{
StringWriter
writer
=
new
StringWriter
();
writeNode
(
node
,
writer
,
getPrettyPrintParams
());
return
writer
.
toString
();
}
private
Map
<
String
,
Object
>
getPrettyPrintParams
()
{
Map
<
String
,
Object
>
prettyPrintParams
=
new
HashMap
<
String
,
Object
>();
prettyPrintParams
.
put
(
"format-pretty-print"
,
Boolean
.
TRUE
);
return
prettyPrintParams
;
}
public
void
writeNode
(
Node
node
,
Writer
output
)
{
writeNode
(
node
,
output
,
null
);
}
public
void
writeNode
(
Node
node
,
Writer
output
,
Map
<
String
,
Object
>
serializerParams
)
{
DOMImplementationLS
domImplLS
=
getLSDOMImpl
(
node
);
LSSerializer
serializer
=
getLSSerializer
(
domImplLS
,
serializerParams
);
LSOutput
serializerOut
=
domImplLS
.
createLSOutput
();
serializerOut
.
setCharacterStream
(
output
);
serializer
.
write
(
node
,
serializerOut
);
}
public
DOMImplementationLS
getLSDOMImpl
(
Node
node
)
{
DOMImplementation
domImpl
;
if
(
node
instanceof
Document
)
{
domImpl
=
((
Document
)
node
).
getImplementation
();
}
else
{
domImpl
=
node
.
getOwnerDocument
().
getImplementation
();
}
DOMImplementationLS
domImplLS
=
(
DOMImplementationLS
)
domImpl
.
getFeature
(
"LS"
,
"3.0"
);
return
domImplLS
;
}
public
LSSerializer
getLSSerializer
(
DOMImplementationLS
domImplLS
,
Map
<
String
,
Object
>
serializerParams
)
{
LSSerializer
serializer
=
domImplLS
.
createLSSerializer
();
serializer
.
setFilter
(
new
LSSerializerFilter
()
{
public
short
acceptNode
(
Node
arg0
)
{
return
FILTER_ACCEPT
;
}
public
int
getWhatToShow
()
{
return
SHOW_ALL
;
}
});
if
(
serializerParams
!=
null
)
{
DOMConfiguration
serializerDOMConfig
=
serializer
.
getDomConfig
();
for
(
String
key
:
serializerParams
.
keySet
())
{
serializerDOMConfig
.
setParameter
(
key
,
serializerParams
.
get
(
key
));
}
}
return
serializer
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment