001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nelson Silva <nelson.silva@inevo.pt> 018 */ 019 020package org.nuxeo.ecm.platform.auth.saml; 021 022import org.opensaml.saml2.core.Attribute; 023import org.opensaml.saml2.core.NameID; 024 025import java.io.Serializable; 026import java.util.List; 027 028/** 029 * @since 6.0 030 */ 031public class SAMLCredential { 032 private final NameID nameID; 033 034 private final List<String> sessionIndexes; 035 036 private String remoteEntityID; 037 038 private String relayState; 039 040 private List<Attribute> attributes; 041 042 private String localEntityID; 043 044 private Serializable additionalData; 045 046 public SAMLCredential(NameID nameID, List<String> sessionIndexes) { 047 this.nameID = nameID; 048 this.sessionIndexes = sessionIndexes; 049 } 050 051 public SAMLCredential(NameID nameID, List<String> sessionIndexes, String remoteEntityID, String relayState, 052 List<Attribute> attributes, String localEntityID, Serializable additionalData) { 053 this.nameID = nameID; 054 this.sessionIndexes = sessionIndexes; 055 this.remoteEntityID = remoteEntityID; 056 this.relayState = relayState; 057 this.attributes = attributes; 058 this.localEntityID = localEntityID; 059 this.additionalData = additionalData; 060 } 061 062 public NameID getNameID() { 063 return nameID; 064 } 065 066 public List<String> getSessionIndexes() { 067 return sessionIndexes; 068 } 069 070 public String getRemoteEntityID() { 071 return remoteEntityID; 072 } 073 074 public Attribute getAttributeByName(String name) { 075 for (Attribute attribute : getAttributes()) { 076 if (name.equalsIgnoreCase(attribute.getName())) { 077 return attribute; 078 } 079 } 080 return null; 081 } 082 083 public List<Attribute> getAttributes() { 084 return attributes; 085 } 086 087 public String getRelayState() { 088 return relayState; 089 } 090 091 public String getLocalEntityID() { 092 return localEntityID; 093 } 094 095 public Serializable getAdditionalData() { 096 return additionalData; 097 } 098}