Package com.sun.identity.wss.security
Class WSSUtils
- java.lang.Object
-
- com.sun.identity.wss.security.WSSUtils
-
public class WSSUtils extends Object
This class provides util methods for the web services security.
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceBundlebundlestatic Debugdebug
-
Constructor Summary
Constructors Constructor Description WSSUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.xml.security.encryption.EncryptedKeyencryptKey(Document doc, byte[] encryptedKey, X509Certificate cert, String keyWrapAlgorithm)static SSOTokengetAdminToken()static MapgetAgentAttributes(String endpoint, Set attrNames, String type)static StringgetAuthMethodURI(String authModuleName)Returns corresponding Authentication method URI to be set in Assertion.static ElementgetCanonicalElement(Node node)Gets input Node Canonicalizedstatic StringgetCertAlias(String issuer)Returns the trusted certificate alias from the issuer.static X509CertificategetCertificate(SecurityToken securityToken)Returns the certificate present in the security token.static X509CertificategetCertificate(Element keyinfo)static ProviderConfiggetConfigByDnsClaim(String dnsClaim, String agentType)static NodegetDirectChild(Node fNode, String localName, String namespace)static Map<QName,List<String>>getMembershipAttributes(String subjectName, String namespace)Returns the membership attributes for the given subject.static ListgetMemberShips(String pattern)static X509CertificategetMessageCertificate(Element sigElement)Returns the message certificate from the security token reference especially for KeyIdentifier and X509IssuerSerial case.static Map<QName,List<String>>getRequestedClaims(String subjectName, Set claimNames, SSOToken ssoToken)Returns the list of requested claims for the given subjectstatic Map<QName,List<String>>getSAMLAttributes(String subjectName, Set attributeNames, String namespace, SSOToken ssoToken)Returns the SAML Attribute Map>. static KeygetSecretKey(SecurityToken securityToken, String certAlias)Returns the secret key from the security token from SAML1 Assertion.static longgetTimeSkew()static StringgetUserPseduoName(String userName, String nameIDImpl)Returns the user pseduo name from the given nameid mapper.static WSSCacheRepositorygetWSSCacheRepository()static XMLEncryptionManagergetXMLEncryptionManager()static XMLSignatureManagergetXMLSignatureManager()static ElementprependChildElement(Element parent, Element child, boolean addWhitespace, Document doc)static Stringprint(Node node)static voidsetRoles(Subject subject, String user)Sets the memberships for a given user into the JAAS Subject.static jakarta.xml.soap.SOAPMessagetoSOAPMessage(Document document)
-
-
-
Field Detail
-
bundle
public static ResourceBundle bundle
-
debug
public static Debug debug
-
-
Method Detail
-
getCertificate
public static X509Certificate getCertificate(SecurityToken securityToken) throws SecurityException
Returns the certificate present in the security token.- Parameters:
securityToken- the security token.- Returns:
- the certificate.
- Throws:
SecurityException
-
getCertificate
public static X509Certificate getCertificate(Element keyinfo)
-
toSOAPMessage
public static jakarta.xml.soap.SOAPMessage toSOAPMessage(Document document)
-
prependChildElement
public static Element prependChildElement(Element parent, Element child, boolean addWhitespace, Document doc)
-
getXMLEncryptionManager
public static XMLEncryptionManager getXMLEncryptionManager()
-
getXMLSignatureManager
public static XMLSignatureManager getXMLSignatureManager()
-
getAuthMethodURI
public static String getAuthMethodURI(String authModuleName)
Returns corresponding Authentication method URI to be set in Assertion.- Parameters:
authModuleName- name of the authentication module used to authenticate the user.- Returns:
- String corresponding Authentication Method URI to be set in Assertion.
-
setRoles
public static void setRoles(Subject subject, String user)
Sets the memberships for a given user into the JAAS Subject.- Parameters:
subject- the JAAS subject where the role memberships need to be set.user- the user's universal dn
-
getAgentAttributes
public static Map getAgentAttributes(String endpoint, Set attrNames, String type)
-
getAdminToken
public static SSOToken getAdminToken()
-
getMessageCertificate
public static X509Certificate getMessageCertificate(Element sigElement)
Returns the message certificate from the security token reference especially for KeyIdentifier and X509IssuerSerial case.- Parameters:
sigElement- the signature element where the security token ref is present- Returns:
- the X509Certificate
-
getWSSCacheRepository
public static WSSCacheRepository getWSSCacheRepository()
-
getSAMLAttributes
public static Map<QName,List<String>> getSAMLAttributes(String subjectName, Set attributeNames, String namespace, SSOToken ssoToken)
Returns the SAML Attribute Map>. The attribute map is generated from the given SSOToken first and if not found, then it will try to find from the repository. - Parameters:
subjectName- the principal to be used for retrieving the user attributes.attributeNames- set of attribute names for the attribute mapnamespace- the name space for the saml attribute namessoToken- the user's SSOToken.- Returns:
- the saml attributes for the SAML Token specification.
-
getUserPseduoName
public static String getUserPseduoName(String userName, String nameIDImpl)
Returns the user pseduo name from the given nameid mapper.- Parameters:
userName- the authenticated user name.nameIDImpl- the nameid mapper implementation class- Returns:
- the user psueduo name.
-
getMembershipAttributes
public static Map<QName,List<String>> getMembershipAttributes(String subjectName, String namespace)
Returns the membership attributes for the given subject.- Parameters:
subjectName- the authenticated subjectnamespace- the saml attribute namespace.- Returns:
- the SAML attributes for the user memberships.
-
getTimeSkew
public static long getTimeSkew()
-
encryptKey
public static org.apache.xml.security.encryption.EncryptedKey encryptKey(Document doc, byte[] encryptedKey, X509Certificate cert, String keyWrapAlgorithm)
-
getSecretKey
public static Key getSecretKey(SecurityToken securityToken, String certAlias) throws SecurityException
Returns the secret key from the security token from SAML1 Assertion.- Throws:
SecurityException
-
getCertAlias
public static String getCertAlias(String issuer)
Returns the trusted certificate alias from the issuer.
-
getRequestedClaims
public static Map<QName,List<String>> getRequestedClaims(String subjectName, Set claimNames, SSOToken ssoToken)
Returns the list of requested claims for the given subject- Parameters:
subjectName- the subject nameclaimNames- the set of requested claimsssoToken- the user's single sign-on token.- Returns:
- the hashmap of requested claims.
-
getConfigByDnsClaim
public static ProviderConfig getConfigByDnsClaim(String dnsClaim, String agentType)
-
-