Search in sources :

Example 1 with IdpResponse

use of org.apache.cloudstack.api.response.IdpResponse in project cloudstack by apache.

the class ListIdpsCmd method authenticate.

@Override
public String authenticate(String command, Map<String, Object[]> params, HttpSession session, InetAddress remoteAddress, String responseType, StringBuilder auditTrailSb, HttpServletRequest req, HttpServletResponse resp) throws ServerApiException {
    ListResponse<IdpResponse> response = new ListResponse<IdpResponse>();
    List<IdpResponse> idpResponseList = new ArrayList<IdpResponse>();
    for (SAMLProviderMetadata metadata : _samlAuthManager.getAllIdPMetadata()) {
        if (metadata == null) {
            continue;
        }
        IdpResponse idpResponse = new IdpResponse();
        idpResponse.setId(metadata.getEntityId());
        if (metadata.getOrganizationName() == null || metadata.getOrganizationName().isEmpty()) {
            idpResponse.setOrgName(metadata.getEntityId());
        } else {
            idpResponse.setOrgName(metadata.getOrganizationName());
        }
        idpResponse.setOrgUrl(metadata.getOrganizationUrl());
        idpResponse.setObjectName("idp");
        idpResponseList.add(idpResponse);
    }
    response.setResponses(idpResponseList, idpResponseList.size());
    response.setResponseName(getCommandName());
    return ApiResponseSerializer.toSerializedString(response, responseType);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) SAMLProviderMetadata(org.apache.cloudstack.saml.SAMLProviderMetadata) IdpResponse(org.apache.cloudstack.api.response.IdpResponse)

Aggregations

ArrayList (java.util.ArrayList)1 IdpResponse (org.apache.cloudstack.api.response.IdpResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 SAMLProviderMetadata (org.apache.cloudstack.saml.SAMLProviderMetadata)1