本文整理汇总了Java中org.apache.ws.security.saml.ext.bean.SubjectBean类的典型用法代码示例。如果您正苦于以下问题:Java SubjectBean类的具体用法?Java SubjectBean怎么用?Java SubjectBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubjectBean类属于org.apache.ws.security.saml.ext.bean包,在下文中一共展示了SubjectBean类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.apache.ws.security.saml.ext.bean.SubjectBean; //导入依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
callback.setSamlVersion(SAMLVersion.VERSION_20);
callback.setIssuer(issuer);
SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, confirmationMethod
);
if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) {
try {
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
} catch (Exception ex) {
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
createAndSetStatement(null, callback);
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
}
示例2: createAndSetStatement
import org.apache.ws.security.saml.ext.bean.SubjectBean; //导入依赖的package包/类
/**
* Note that the SubjectBean parameter should be null for SAML2.0
*/
protected void createAndSetStatement(SubjectBean subjectBean, SAMLCallback callback) {
if (statement == Statement.AUTHN) {
AuthenticationStatementBean authBean = new AuthenticationStatementBean();
if (subjectBean != null) {
authBean.setSubject(subjectBean);
}
authBean.setAuthenticationMethod("Password");
callback.setAuthenticationStatementData(Collections.singletonList(authBean));
} else if (statement == Statement.ATTR) {
AttributeStatementBean attrBean = new AttributeStatementBean();
if (subjectBean != null) {
attrBean.setSubject(subjectBean);
}
AttributeBean attributeBean = new AttributeBean();
attributeBean.setSimpleName("role");
attributeBean.setAttributeValues(Collections.singletonList("user"));
attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrBean));
} else {
AuthDecisionStatementBean authzBean = new AuthDecisionStatementBean();
if (subjectBean != null) {
authzBean.setSubject(subjectBean);
}
ActionBean actionBean = new ActionBean();
actionBean.setContents("Read");
authzBean.setActions(Collections.singletonList(actionBean));
authzBean.setResource("endpoint");
authzBean.setDecision(AuthDecisionStatementBean.Decision.PERMIT);
callback.setAuthDecisionStatementData(Collections.singletonList(authzBean));
}
}
示例3: handle
import org.apache.ws.security.saml.ext.bean.SubjectBean; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof SAMLCallback)
{
SAMLCallback callback = (SAMLCallback) callbacks[i];
if (this.saml2)
{
callback.setSamlVersion(SAMLVersion.VERSION_20);
}
callback.setIssuer("sts");
String subjectName = "uid=sts-client,o=jbws-cxf-sts.com";
String subjectQualifier = "www.jbws-cxf-sts.org";
SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, this.confirmationMethod);
if (SAML2Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod)
|| SAML1Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod))
{
try
{
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
}
catch (Exception ex)
{
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean();
attrBean.setSubject(subjectBean);
AttributeBean attributeBean = new AttributeBean();
if (this.saml2)
{
attributeBean.setQualifiedName("subject-role");
}
else
{
attributeBean.setSimpleName("subject-role");
attributeBean.setQualifiedName("http://custom-ns");
}
attributeBean.setAttributeValues(Collections.singletonList("system-user"));
attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrBean));
}
}
}
示例4: handle
import org.apache.ws.security.saml.ext.bean.SubjectBean; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
Message m = PhaseInterceptorChain.getCurrentMessage();
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
callback.setSamlVersion(SAMLVersion.VERSION_20);
callback.setIssuer("http://localhost:8080/samlsvc/");
String subjectName = (String)m.getContextualProperty("saml.subject.name");
if (subjectName == null) {
subjectName = "tomcat";
}
String subjectQualifier = "localhost";
SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, confirmationMethod);
callback.setSubject(subjectBean);
ConditionsBean conditions = new ConditionsBean();
conditions.setAudienceURI("https://sp.example.com/SAML2");
callback.setConditions(conditions);
AuthDecisionStatementBean authDecBean = new AuthDecisionStatementBean();
authDecBean.setDecision(Decision.INDETERMINATE);
authDecBean.setResource("https://sp.example.com/SAML2");
ActionBean actionBean = new ActionBean();
actionBean.setContents("Read");
authDecBean.setActions(Collections.singletonList(actionBean));
callback.setAuthDecisionStatementData(Collections.singletonList(authDecBean));
AuthenticationStatementBean authBean = new AuthenticationStatementBean();
authBean.setSubject(subjectBean);
authBean.setAuthenticationInstant(new DateTime());
authBean.setSessionIndex("123456");
// AuthnContextClassRef is not set
authBean.setAuthenticationMethod(
"urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
callback.setAuthenticationStatementData(
Collections.singletonList(authBean));
/*
AttributeStatementBean attrBean = new AttributeStatementBean();
attrBean.setSubject(subjectBean);
List<String> roles = CastUtils.cast((List<?>)m.getContextualProperty("saml.roles"));
if (roles == null) {
roles = Collections.singletonList("user");
}
List<AttributeBean> claims = new ArrayList<AttributeBean>();
AttributeBean roleClaim = new AttributeBean();
roleClaim.setSimpleName("subject-role");
roleClaim.setQualifiedName(Claim.DEFAULT_ROLE_NAME);
roleClaim.setNameFormat(Claim.DEFAULT_NAME_FORMAT);
roleClaim.setAttributeValues(roles);
claims.add(roleClaim);
List<String> authMethods = CastUtils.cast((List<?>)m.getContextualProperty("saml.auth"));
if (authMethods == null) {
authMethods = Collections.singletonList("password");
}
AttributeBean authClaim = new AttributeBean();
authClaim.setSimpleName("http://claims/authentication");
authClaim.setQualifiedName("http://claims/authentication");
authClaim.setNameFormat("http://claims/authentication-format");
authClaim.setAttributeValues(new ArrayList<Object>(authMethods));
claims.add(authClaim);
attrBean.setSamlAttributes(claims);
callback.setAttributeStatementData(Collections.singletonList(attrBean));
*/
}
}
}
示例5: handle
import org.apache.ws.security.saml.ext.bean.SubjectBean; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof SAMLCallback)
{
SAMLCallback callback = (SAMLCallback) callbacks[i];
if (this.saml2)
{
callback.setSamlVersion(SAMLVersion.VERSION_20);
}
callback.setIssuer("sts");
String subjectName = "uid=sts-client,o=jbws-cxf-sts.com";
String subjectQualifier = "www.jbws-cxf-sts.org";
SubjectBean subjectBean = new SubjectBean(subjectName, subjectQualifier, this.confirmationMethod);
if (SAML2Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod)
|| SAML1Constants.CONF_HOLDER_KEY.equals(this.confirmationMethod))
{
try
{
KeyInfoBean keyInfo = createKeyInfo();
subjectBean.setKeyInfo(keyInfo);
}
catch (Exception ex)
{
throw new IOException("Problem creating KeyInfo: " + ex.getMessage());
}
}
callback.setSubject(subjectBean);
AttributeStatementBean attrBean = new AttributeStatementBean();
attrBean.setSubject(subjectBean);
AttributeBean attributeBean = new AttributeBean();
if (this.saml2)
{
attributeBean.setQualifiedName("subject-role");
}
else
{
attributeBean.setSimpleName("subject-role");
attributeBean.setQualifiedName("http://custom-ns");
}
attributeBean.setAttributeValues(Collections.singletonList("system-user"));
attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrBean));
}
}
}