/*******************************************************************************
* Copyright 2016 The MITRE Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.mitre.openid.connect.binder.web;
import java.util.ArrayList;
import java.util.List;
import org.mitre.openid.connect.binder.model.IdentityProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController {
@Value( "#{'${idps.names}'.split(',')}" )
private List<String> idpNames;
@Value( "#{'${idps.identifiers}'.split(',')}" )
private List<String> idpIdentifiers;
@RequestMapping(value = "/idps", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<IdentityProvider> getIdps() {
List<IdentityProvider> idpList = new ArrayList<IdentityProvider>();
for( int i=0; i<Math.min(idpNames.size(), idpIdentifiers.size()); ++i ) {
idpList.add(new IdentityProvider(idpNames.get(i), idpIdentifiers.get(i)));
}
return idpList;
}
}